Sending a message to an Agent
Sends the visitor's message and returns the agent's reply. The Accept header picks how the reply comes
back:
Accept | Reply |
|---|---|
application/json (or none) | All at once, as JSON: the Markdown and the files the agent shared. |
text/event-stream | Streamed as it is written. See Streaming below. |
text/markdown | All at once, as Markdown. Shared files appear as images or links where they were written. |
text/plain | All at once, as plain text without Markdown, for places such as SMS. The agent shares no files. |
Any other type returns 406.
Authenticate with the participant's token. The message is sent as that participant, who must take part in
the conversation; anyone else gets 403.
Streaming
The reply is a stream of data: lines, each holding one JSON event, and ends with data: [DONE]. Append
the delta of every text_delta event to show the reply as it is written. An embed_file event is a file
the agent shared. Ignore event types you don't use; new ones may be added.
data: {"type":"stream_start", …}data: {"type":"text_start","message_id":"…", …}data: {"type":"text_delta","message_id":"…","delta":"Here's ", …}data: {"type":"text_delta","message_id":"…","delta":"our menu.", …}data: {"type":"embed_file","name":"menu.pdf","mime_type":"application/pdf","url":"…", …}data: {"type":"stream_end","reason":"stop", …}data: [DONE]participantTokenAuthorizationBearer <token>A participant's token, from the conversation's _embedded.participants, sent as
Authorization: Bearer <token>. Used to send and list messages as that participant, in every conversation
they take part in. It lasts 90 days.
conversation*stringThe conversation's id.
uuidapplication/json- body
content*stringThe visitor's message.
length <= 10000context?array<>What the agent should know for this message only, such as the visitor's current page and local time.
items <= 20The agent's reply.
response?stringdata: lines, each a JSON stream event, ending with data: [DONE].
curl -N -X POST "https://api.rundispatch.ai/v1/conversations/$CONVERSATION_ID/messages" \ -H "Authorization: Bearer $PARTICIPANT_TOKEN" \ -H "Accept: text/event-stream" \ -H "Content-Type: application/json" \ -d '{"content": "Do you deliver on Sundays?"}'{ "data": { "markdown": "Here's our menu.\n\n[menu.pdf](https://files.rundispatch.ai/menu.pdf?signature=4f9c2e7a)", "attachments": [ { "id": "0199c1a2-3b4c-7d5e-8f60-718293a4b5c6", "type": "file", "name": "menu.pdf", "mime_type": "application/pdf", "url": "https://files.rundispatch.ai/menu.pdf?signature=4f9c2e7a", "preview_url": null, "download_url": "https://files.rundispatch.ai/menu.pdf?download=1&signature=4f9c2e7a", "expires_at": "2026-10-13T09:00:00+00:00" } ] }}