Developers
ENPT

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.

ParameterTypeRequiredDescription
conversationIdstring (UUID)YesConversation created with Create a conversation.
questionstring or nullNoWhat the customer wrote. Without it, the avatar resumes the conversation on its own (see rebounce).
subSlugstringNoSub slug of the avatar that answers. Without it, or if no avatar matches, the main avatar answers.
contextDatastringNoExtra information for this turn only, such as data from your system.
dialogueInsertStringstringNoExtra instruction for the avatar for this turn only.
userDataobjectNoWho the customer is. See below.
reasoningConfigobjectNoOptions 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:

FieldTypeDescription
mediaInstructionsstringHow to describe media in the message (images, video, audio, documents), for example what to focus on.
rebouncebooleanThe avatar continues the conversation without a customer question. Turned on automatically when question is empty.
rebounceInstructionsstringWhat the avatar should aim for when it resumes the conversation.
rePromptInstructionsstringExtra guidance for the step that rewrites the customer's question before answering.
saveAssistantResponsebooleanDefault true. With false, the answer is returned but not saved in the conversation.
returnDialoguebooleanDefault false. Returns the full conversation in conversation.
tolkyCompleteLogbooleanDefault false. Returns the full processing log in tolkyCompleteLog.
replaceDomainNamestringReplaces 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
FieldDescription
assistantResponse.stringThe answer as text (with markdown).
assistantResponse.wppParsedThe 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.isAudiotrue when the answer should be sent as audio.
assistantResponse.mediaDescriptionArrayDescriptions of the media the customer sent.
conversationId, sessionId, hostId, userId, leadIdIDs related to this turn.
askHumanHelptrue when the lead is waiting for a person.
ticketsTicket linked to the conversation: ticketId, ticketDescription.
createdMessageIdsIDs of the messages created in this turn. Use them in Investigate an answer.
questionThe question as processed.
conversationFull conversation, only with returnDialogue: true. Otherwise empty.
tokensControlTokens used, per model: model, tokens.
jsonArray, agentsLog, restStatusResults of automations and agents run in this turn.
mcpMCP servers and tools used in this turn: status, connections, chosen_tools, results, error.
tolkyCompleteLogProcessing log. Full only with tolkyCompleteLog: true.
requestControlIdInternal ID of this request, useful when you contact support.
responseStatusok, message and avatarMessage. avatarMessage explains when the main avatar answered because no subSlug matched.
StatusWhen
400Invalid body, for example conversationId is not a UUID.
503The avatar could not produce an answer (responseStatus.ok is false). The body carries the data plus errorDetails.
500Unexpected error.

The call can take several seconds. See Conventions for timeouts and retries.

Previous

Create a conversation

Next

Conversation details