Create a conversation
Open a new conversation with your avatar and get the ID you use to send messages.
A conversation groups the messages exchanged between one customer and your avatar. Create one before sending the first message, then reuse its ID for every message in that session.
Each conversation belongs to a lead, the contact record of the customer. If you do not say who the customer is, Tolky creates a new lead. If you send your own customer ID (externalId), every conversation of that customer stays under the same lead, so the avatar and your team see the full history.
When to use it
- At the start of each new service session in your site, app or own chat.
- When you want a specific avatar to answer: pass its sub slug. Without it, the main avatar of the account answers.
ReferenceTechnical details
POST /api/externalAPIs/public/tolkyReasoning/conversations/create
Authentication: host token. The account comes from the token.
| Parameter | Type | Required | Description |
|---|---|---|---|
subSlug | string | No | Sub slug of the avatar that answers. Without it, or if no avatar matches, the main avatar is used. Send the same value in Send a message. |
externalId | string | No | Your ID for the customer. If a lead with this ID exists in your account, the conversation is linked to it. Otherwise a new lead is created with this ID. |
leadId | string (UUID) | No | Links the conversation to an existing Tolky lead. Returns 404 if the lead does not exist. |
userName | string | No | Saved as the lead name. Applied when you also send externalId. |
email | string | No | Saved on the lead. Applied when you also send externalId. |
Linking to an existing lead (by leadId or externalId) clears the "human help requested" flag of that lead and its conversations, so the avatar answers again.
curl -X POST "https://api.tolky.to/api/externalAPIs/public/tolkyReasoning/conversations/create" \
-H "Authorization: Bearer $TOLKY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"subSlug": "support",
"externalId": "customer-1042",
"userName": "Ana Souza"
}'{
"code": 200,
"message": "OK",
"data": {
"leadId": "9b1d4c7e-...",
"conversationId": "3f0c2a8e-...",
"sessionId": "c7a2f0d1-..."
}
}| Field | Description |
|---|---|
conversationId | ID of the new conversation. Use it in every message. |
leadId | Lead the conversation belongs to. |
sessionId | Technical session created with the conversation. |
| Status | When |
|---|---|
400 | The token does not resolve to an account. |
404 | The leadId you sent does not exist. |
500 | The conversation could not be created. |
Next step
Send a message with the conversationId you received.