Send a message
Send the customer's message to the avatar and receive its answer in the same call.
This is the main call of the API. You send what the customer wrote, the avatar reads the conversation history, its instructions, its knowledge base and its automations, and the answer comes back in the response.
The answer arrives twice: as plain text and split into parts (text, images, links) ready to show in a chat. The customer message and the answer are saved in the conversation and appear in Conversations in the platform.
When to use it
- Every time the customer writes in your own channel (site, app, chat).
- To give the avatar information it cannot see, such as the customer's plan or last order, send it as context for that turn.
- To make the avatar resume a quiet conversation on its own, send the call without a question.
ReferenceTechnical details
POST /api/externalAPIs/public/tolkyReasoning/callReasoning
Authentication: host token. The account comes from the token; a hostId in the body is replaced by it.
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationId | string (UUID) | Yes | Conversation created with Create a conversation. |
question | string or null | No | What the customer wrote. Without it, the avatar resumes the conversation on its own (see rebounce). |
subSlug | string | No | Sub slug of the avatar that answers. Without it, or if no avatar matches, the main avatar answers. |
contextData | string | No | Extra information for this turn only, such as data from your system. |
dialogueInsertString | string | No | Extra instruction for the avatar for this turn only. |
userData | object | No | Who the customer is. See below. |
reasoningConfig | object | No | Options for this turn. See below. |
userData fields, all optional strings: externalUserId, tolkyUserId, tolkyLeadId, userName, email (a valid e-mail or an empty string), phone.
reasoningConfig fields, all optional:
| Field | Type | Description |
|---|---|---|
mediaInstructions | string | How to describe media in the message (images, video, audio, documents), for example what to focus on. |
rebounce | boolean | The avatar continues the conversation without a customer question. Turned on automatically when question is empty. |
rebounceInstructions | string | What the avatar should aim for when it resumes the conversation. |
rePromptInstructions | string | Extra guidance for the step that rewrites the customer's question before answering. |
saveAssistantResponse | boolean | Default true. With false, the answer is returned but not saved in the conversation. |
returnDialogue | boolean | Default false. Returns the full conversation in conversation. |
tolkyCompleteLog | boolean | Default false. Returns the full processing log in tolkyCompleteLog. |
replaceDomainName | string | Replaces the word "tolky" in the returned log with this text. |
curl -X POST "https://api.tolky.to/api/externalAPIs/public/tolkyReasoning/callReasoning" \
-H "Authorization: Bearer $TOLKY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"conversationId": "3f0c2a8e-...",
"question": "Do you deliver on Saturdays?",
"contextData": "Customer plan: Premium. City: Curitiba.",
"userData": { "externalUserId": "customer-1042", "userName": "Ana Souza" }
}'{
"code": 200,
"message": "OK",
"data": {
"assistantResponse": {
"string": "Yes, we deliver on Saturdays from 9am to 1pm.",
"wppParsed": [{ "type": "text", "content": "Yes, we deliver on Saturdays from 9am to 1pm." }],
"isAudio": false,
"mediaDescriptionArray": []
},
"conversationId": "3f0c2a8e-...",
"leadId": "9b1d4c7e-...",
"askHumanHelp": false,
"createdMessageIds": ["5e8a1b2c-...", "7d3f9a0b-..."],
"responseStatus": { "ok": true, "message": null, "avatarMessage": null }
}
}The example shows the main fields. The full response has more, listed below.
Reading the answer
Show assistantResponse.string if your channel accepts plain text, or go through wppParsed to send each part (text, image, link) in its own bubble. Check askHumanHelp: when it is true, the customer asked for a person and your team should take over.
Response fieldsTechnical details
| Field | Description |
|---|---|
assistantResponse.string | The answer as text (with markdown). |
assistantResponse.wppParsed | The answer split into parts. Each item has type and content; images, links and audio also carry url and description. Types: text, image, site, audio, boleto (bank slip line), pix (Pix copy-and-paste code). |
assistantResponse.isAudio | true when the answer should be sent as audio. |
assistantResponse.mediaDescriptionArray | Descriptions of the media the customer sent. |
conversationId, sessionId, hostId, userId, leadId | IDs related to this turn. |
askHumanHelp | true when the lead is waiting for a person. |
tickets | Ticket linked to the conversation: ticketId, ticketDescription. |
createdMessageIds | IDs of the messages created in this turn. Use them in Investigate an answer. |
question | The question as processed. |
conversation | Full conversation, only with returnDialogue: true. Otherwise empty. |
tokensControl | Tokens used, per model: model, tokens. |
jsonArray, agentsLog, restStatus | Results of automations and agents run in this turn. |
mcp | MCP servers and tools used in this turn: status, connections, chosen_tools, results, error. |
tolkyCompleteLog | Processing log. Full only with tolkyCompleteLog: true. |
requestControlId | Internal ID of this request, useful when you contact support. |
responseStatus | ok, message and avatarMessage. avatarMessage explains when the main avatar answered because no subSlug matched. |
| Status | When |
|---|---|
400 | Invalid body, for example conversationId is not a UUID. |
503 | The avatar could not produce an answer (responseStatus.ok is false). The body carries the data plus errorDetails. |
500 | Unexpected error. |
The call can take several seconds. See Conventions for timeouts and retries.