Interact
Send user messages to an active conversation and process streaming responses.
Send a Message
Send a new user message to the conversation. The endpoint will perform analysis and generate an agent message in response.
If request_format
is text
, the request body must follow multipart/form-data
with precise one form field called recorded_message
that corresponds to UTF-8 encoded
bytes of the text message. If request_format
is voice
, the entire request body must be the bytes of the voice recording in audio/wav
or audio/mpeg
(MP3) format. The body
can be sent as a stream, and the endpoint will start processing chunks as they're received, which will reduce latency.
A UserMessageAvailableEvent
will be the first event in the response, which includes the user message if it's sent as text, or the transcribed message if it's sent as voice.
A series of CurrentAgentActionEvent
s will follow, which indicates steps in the agent's thinking process. Then the agent message is generated sequentially in pieces, with each piece
being sent as a NewMessageEvent
in the response. After all the pieces are sent, an InteractionCompleteEvent
is sent. The response might end here, or, if the conversation automatically
ends (for instance, because the user message indicates the user wants to end the session), an EndSessionEvent
would be emitted, while the conversation is marked as finished and the post-conversation
analysis asynchronously initiated. The connection will then terminate.
Any further action on the conversation is only allowed after the connection is terminated.
A 200 status code doesn't indicate the successful completion of this endpoint, because the status code is transmitted before the stream starts. At any point during the stream,
an ErrorEvent
might be sent, which indicates that an error has occurred. The connection will be immediately closed after.
This endpoint can only be called on a conversation that has started but not finished.
Permissions
This endpoint requires the following permissions:
User:UpdateUserInfo
on the user who started the conversation.Conversation:InteractWithConversation
on the conversation.
This endpoint may be impacted by the following permissions:
CurrentAgentActionEvent
s are only emitted if the authenticated user has theConversation:GetInteractionInsights
permission.
The identifier of the conversation to send a message to.
^[a-f0-9]{24}$
The format in which the user message is delivered to the server.
The format of the response that will be sent to the user.
A regex for filtering the type of the current agent action to return. By default, all are returned. If you don't want to receive any events, set this to a regex that matches nothing, for instance ^$
.
^.*$
Configuration for the user message audio. This is only required if request_format
is set to voice
.
The format of the audio response, if response_format
is set to voice
.
The content type of the request body, which must be multipart/form-data
followed by a boundary.
^multipart\/form-data; boundary=.+$
The Mongo cluster name to perform this request in. This is usually not needed unless the organization does not exist yet in the Amigo organization infra config database.
[]
Succeeded. The response will be a stream of events in JSON format separated by newlines. The server will transmit an event as soon as one is available, so the client should respond to the events as soon as one arrives, and keep listening until the server closes the connection.
The user message is empty, or the preferred language does not support voice transcription or response, or the audio_format
field is not set when voice output is requested, or the timestamps for external event messages are not in the past, or the timestamps for external event messages are inconsistent with the conversation.
Invalid authorization credentials.
Missing required permissions.
Specified organization or conversation is not found.
The specified conversation is already finished, or a related operation is in process.
The format of the supplied audio file is not supported.
Invalid request path parameter failed validation.
The user has exceeded the rate limit of 15 requests per minute for this endpoint.
The service is going through temporary maintenance.
POST /v1/{organization}/conversation/{conversation_id}/interact?request_format=text&response_format=text HTTP/1.1
Host: api.amigo.ai
Authorization: Bearer YOUR_SECRET_TOKEN
X-ORG-ID: YOUR_API_KEY
content-type: text
Accept: */*
{
"type": "interaction-complete",
"message_id": "text",
"interaction_id": "text",
"full_message": "text",
"conversation_completed": true
}
curl --request POST \
--url 'https://api.amigo.ai/v1/<YOUR-ORG-ID>/conversation/<CONVERSATION-ID>/interact?request_format=text&response_format=text' \
--header 'Authorization: Bearer <AUTH-TOKEN-OF-USER>' \
--header 'Accept: application/x-ndjson' \
--header 'Content-Type: multipart/form-data' \
--form 'recorded_message=Hello! Please tell me a fun fact.'
Best Practices
Streaming Best Practices
Always iterate the stream until
interaction-complete
Treat
error
events as a rollback of the interaction; log and retry as neededUse timeouts/abort controllers to bound request duration
Keep track of returned IDs for diagnostics
Dynamic Behavior → Metric Evaluation
For how to react to current-agent-action
events (dynamic behavior triggered) and evaluate metrics, see:
Conversations: Events → System Integration Flow (conversations-events.md#system-integration-flow)
That page includes a sequence diagram and API examples for metric/evaluate
.
Finish the Conversation
See Lifecycle & Finish to manually end a conversation and handle dangling sessions.
Last updated
Was this helpful?