Conversational
/chat
POST
https://ai.api.answerly.io/chat
Triggers the agent to generate a response based on the provided message.
Request Body
agentId
string
Required
The ID of your agent. You can read more about how to get the agent ID by clicking here.
conversationId
string
Required
The ID of your conversation. You can leave this field as an empty string, if you want to initiate a new conversation.
message
string
Required
The message that you want the agent to respond to.
channel
string
Required
The channel that you need the response for.
Possible properties:
Possible properties:
web
responseStyle
string
Required
The style that you want the response to be in.
Possible properties:
Possible properties:
plaintext
markdown
html
actionRequest
string
Required
actionRequest is a key that has been created for future use, and does not have any particular effect at this time.
Please use the same value for this key as shown on the example to the right.
Please use the same value for this key as shown on the example to the right.
Example
curl --request POST \
--url https://ai.api.answerly.io/chat/ \
--header 'Content-Type: application/json' \
--data '{
"agentId": "YOUR_AGENT_ID",
"conversationId":"",
"message": "YOUR_MESSAGE",
"channel": "web",
"responseStyle": "html",
"actionRequest": {
"name": "conversational"
}
}'
Return (success)
status
boolean
A boolean indicating the success or failure of the request.
data.conversationId
string
Represents the ID for your conversation. If no conversation ID was provided, this field will display the newly assigned conversation ID.
data.messages
string[]
An array containing responses from the agent.
These responses represent paragraphs, or collection of paragraphs, and collectively form the complete message sent by the agent.
These responses represent paragraphs, or collection of paragraphs, and collectively form the complete message sent by the agent.
data.actionResponse
string[]
actionResponse is a key that has been created for future use, and does not have any particular effect at this time.
data.meta.tokens.conversational
number
The amount of tokens spent to generate the agent response.
data.meta.tokens.functional
number
The amount of tokens spent on AI features, such as human takeover detection.
data.meta.tokens.embeddings
number
The amount of tokens spent on converting your message into a vector embedding.
data.meta.source.$.dataItemId
number
The ID of the data item that helped the agent generate the response.
data.meta.source.$.cosineDistanceScore
number
The coisine similarity score between your message, and the data item's content.
Example
{
"status": true,
"data": {
"conversationId": "NEW_CONVERSATION_ID",
"messages": [
"AGENT_MESSAGE_PART_1",
"AGENT_MESSAGE_PART_2"
],
"actionResponse": {
"name": "conversational"
},
"meta": {
"tokens": {
"conversational": 556,
"functional": 143,
"embeddings": 4
},
"source": [
{
"dataItemId": "e85e1a83-187b-4d2e-a160-7632af8465c1",
"cosineDistanceScore": 0.18312443394210398
}
]
}
}
}
Return (failure)
status
boolean
A boolean indicating the success or failure of the request.
data
string
An error message returned by the server.
Example
{
"status": false,
"data": "An agent with that ID was not found"
}