Create
Create new conversations and choose who speaks first (agent, user, or an external event).
Prerequisites
Valid JWT for the acting user (see Authentication)
service_id
for the target serviceOrganization ID
Create a new conversation and start it. The user must not have any unfinished conversations that belong to the same service.
Permissions
This endpoint requires the following permissions:
Conversation.CreateConversation
for the new conversation.
This endpoint may be impacted by the following permissions:
CurrentAgentActionEvent
s are only emitted if the authenticated user has theConversation:GetInteractionInsights
permission.
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 ^$
.
^.*$
The format of the audio response, if response_format
is set to voice
.
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.
[]
The identifier of the service to create a conversation in.
^[a-f0-9]{24}$
The version set of the service to use. If not provided, the release
version set is used.
release
The initial user or agent inner thought message to send to the service. If not provided, the conversation will start with an agent message.
The type of the initial_message
. Can only be specified if initial_message
is provided.
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.
Attempting to start a conversation when other unfinished conversations exist, or the preferred language does not support voice response, or the audio_format
field is not set when voice output is requested.
Invalid authorization credentials.
Missing required permissions.
Specified organization, service, or version set is not found.
A related operation is in progress.
Invalid request path parameter or request body failed validation.
The user has exceeded the rate limit of 5 requests per minute for this endpoint.
The service is going through temporary maintenance.
POST /v1/{organization}/conversation/?response_format=text HTTP/1.1
Host: api.amigo.ai
Authorization: Bearer YOUR_SECRET_TOKEN
X-ORG-ID: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 121
{
"service_id": "text",
"service_version_set_name": "release",
"initial_message": "text",
"initial_message_type": "user-message"
}
{
"type": "conversation-created",
"conversation_id": "text"
}
Authentication & Token Management
All requests must include Authorization: Bearer <AUTH-TOKEN-OF-USER>
. See the Authentication guide for patterns and token refresh recommendations.
Agent-First Conversations
When no initial_message
is provided, the agent sends the first message.
curl --request POST \
--url 'https://api.amigo.ai/v1/<YOUR-ORG-ID>/conversation/?response_format=text' \
--header 'Authorization: Bearer <AUTH-TOKEN-OF-USER>' \
--header 'Accept: application/x-ndjson' \
--header 'Content-Type: application/json' \
--data '{
"service_version_set_name": "release",
"service_id": "<SERVICE-ID>"
}'
User-First Conversations
Start with a user message using initial_message
and initial_message_type: "user-message"
.
curl --request POST \
--url 'https://api.amigo.ai/v1/<YOUR-ORG-ID>/conversation/?response_format=text' \
--header 'Authorization: Bearer <AUTH-TOKEN-OF-USER>' \
--header 'Accept: application/x-ndjson' \
--header 'Content-Type: application/json' \
--data '{
"service_version_set_name": "release",
"service_id": "<SERVICE-ID>",
"initial_message": "Hello, I need help with my account settings",
"initial_message_type": "user-message"
}'
External Event Messages
Start with an external system event using initial_message_type: "external-event"
.
curl --request POST \
--url 'https://api.amigo.ai/v1/<YOUR-ORG-ID>/conversation/?response_format=text' \
--header 'Authorization: Bearer <AUTH-TOKEN-OF-USER>' \
--header 'Accept: application/x-ndjson' \
--header 'Content-Type: application/json' \
--data '{
"service_version_set_name": "release",
"service_id": "<SERVICE-ID>",
"initial_message": "URGENT: System failure detected in payment processing",
"initial_message_type": "external-event"
}'
Example Response Stream
The response is an NDJSON stream with events. See the full list in Conversations → Events.
{"type":"conversation-created","conversation_id":"67d871c23eb91293ecfae8b0"}
{"type":"new-message","message":"Hi","message_metadata":[],"stop":false,"sequence_number":1,"message_id":"67d871c23eb91293ecfae8b2"}
{"type":"new-message","message":" there! How can I help you today?","message_metadata":[],"stop":false,"sequence_number":2,"message_id":"67d871c23eb91293ecfae8b2"}
{"type":"interaction-complete"}
Tips
Conversation Management
Store the
conversation_id
from theconversation-created
event for subsequent callsAlways process events until
interaction-complete
Handle
error
events by retrying the interaction
Last updated
Was this helpful?