Documentation Index
Fetch the complete documentation index at: https://developers.autoplay.ai/llms.txt
Use this file to discover all available pages before exploring further.
Auto-generated from
autoplay_sdk/skills/. Edit the source SKILL.md and run python scripts/sync_skill_docs.py..md · Open raw file · Install via CLI: autoplay-install-skills
Chatbot — Intercom
Read autoplay-core first for install, credentials, and the stream wiring pattern.
Scoping pattern for Intercom
Intercom has a persistentconversation_id. You must link it to the Autoplay session_id before context can be delivered.
- Populate
conv_mapfrom your Intercom webhook handler (Step 1) - Call
await writer.on_session_linked(session_id, conversation_id)immediately after each link write_actions_cbguards onconv_map.get(session_id)— actions before the link are buffered, not dropped- The first link is sticky — never re-link the same session
Step 1 — Register Intercom webhooks
In Intercom: Settings → Integrations → Developer Hub → Your app → Webhooks Subscribe to:conversation.user.createdconversation.user.replied
X-Hub-Signature-256 with your client_secret, extract conversation_id, resolve session_id from the user identity, then populate conv_map and call on_session_linked.
Step 2 — Implement IntercomWriter
- Access token: Developer Hub → Your app → Authentication
- Admin ID: Admins API
Step 3 — Wire AsyncAgentContextWriter
await writer.on_session_linked(session_id, conversation_id)
Reference
- Full tutorial: https://developers.autoplay.ai/recipes/intercom-tutorial
- Chatbot writer SDK docs: https://developers.autoplay.ai/sdk/chatbot-writer
- Agent context SDK docs: https://developers.autoplay.ai/sdk/agent-context
Known Pitfalls
Gap 1 — Circular import from autoplay_sdk.integrations.intercom
The cycle that existed:
proactive_trigger_canonical_url_ping_pong and
proactive_trigger_canonical_url_ping_pong_projects_either_leg were moved to
autoplay_sdk.proactive.triggers._url_predicates. intercom.py re-imports and
re-exports both functions so all existing callers are unaffected.
If you write custom triggers: never import both
autoplay_sdk.integrations.intercom and any autoplay_sdk.proactive module at
the module top level in the same file. Use a deferred (inside-function) import
as a fallback if you must cross the boundary.
Gap 2 — Proactive popup only fires on widget-initiated conversations
POST /conversations with from: {type: "user"} creates a conversation visible
in the admin inbox only — it does not trigger a notification popup in the
Messenger widget for the end user.
The popup fires only when the admin replies to a conversation the user
genuinely initiated through the widget (captured via the
conversation.user.created webhook and stored in Redis as
intercom_conv:{session_id}).
Correct proactive sequence:
- User opens the Messenger widget and sends any message → Intercom fires
conversation.user.createdwebhook. - Webhook handler stores
conv_idin Redis keyed tosession_id: trigger_notification.pyreads the realconv_idfrom Redis and POSTs thequick_replyadmin reply into it:- Intercom surfaces the admin reply as a popup notification in the widget.
Gap 3 — Proactive config JSON schema and routing pattern
Theintegration_config["proactive_intercom"] field is a list of trigger
config objects (v2 format). Each entry has a messages array of chip rows.
user_tour_exists/user_tour_id (v2) and
offers_tour/flow_id (v1) are accepted by the parser.
SDK helpers from proactive_intercom_config.py:
Gap 4 — API version header table
Use the correct header builder per operation. Reusing2.11 for quick_reply
silently breaks tappable buttons.
| Operation | Helper | Intercom-Version |
|---|---|---|
POST /contacts/search | intercom_rest_json_headers() | 2.11 |
POST /conversations | intercom_rest_json_headers() | 2.11 |
POST /conversations/{id}/reply (quick_reply) | intercom_quick_reply_http_headers() | Unstable |
DELETE /conversations/{id} | intercom_delete_conversation_headers() | 2.15 |
Gap 5 — Redis URL differs between Docker and local dev
REDIS_URL=redis://redis:6379 uses the Docker Compose service name and will fail
when running the connector outside Docker (e.g. local uvicorn or tests).
Recommended fix — add this normalization wherever you initialise the Redis client:
redis:6379) and transparently
rewrites the URL to localhost everywhere else.