jido_chat_x adapts X/Twitter Direct Messages to the Jido.Chat.Adapter contract.
The adapter is built on xdk-elixir for API calls.
Installation
def deps do
[
{:jido_chat_x, "~> 0.1"}
]
endFeature surface
- Numeric X user ids can be used as outbound DM rooms.
- Existing DM conversations use
conversation:{dm_conversation_id}. send_message/3sends text DMs by participant id or conversation id.post_message/3sends text/markdown payloads as plain DM text.send_file/3supports remote file/media URLs by appending links to the DM text.- Local file paths and in-memory binary uploads are intentionally rejected until the media upload flow is live-tested.
fetch_message/3,fetch_messages/2, anddelete_message/3use the XDK Direct Messages API.open_dm/2returns the numeric user id as a sendable DM room.- Account Activity webhooks verify CRC and POST signatures, parse DM events, and route through
Jido.Chat.process_event/4.
X Direct Messages do not support message edits, reactions, modals, or ephemeral messages through this adapter.
Live testing
Set:
RUN_LIVE_X_TESTS=true
RUN_LIVE_X_SEND_TESTS=false
X_CONSUMER_KEY=
X_CONSUMER_SECRET=
X_ACCESS_TOKEN=
X_ACCESS_TOKEN_SECRET=
X_TEST_RECIPIENT_ID=
RUN_LIVE_X_TESTS=true enables read-only credential verification. Set
RUN_LIVE_X_SEND_TESTS=true only when you want the test suite to create a real DM
to X_TEST_RECIPIENT_ID. The authenticated X user must be able to send a DM to
that recipient.
Run:
mix test --include live
Webhook setup
X Account Activity webhooks are required for real-time DM ingress.
- Configure a webhook URL for your runtime route, for example
/api/webhooks/x - The route must answer CRC GET checks with an HMAC-SHA256
response_token - POST requests must be verified with
x-twitter-webhooks-signature - Subscribe the authenticated user account to Account Activity events
The adapter deduplicates should be handled by the runtime using the DM event id.