Developers
ENPT

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.

ParameterTypeRequiredDescription
subSlugstringNoSub 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.
externalIdstringNoYour 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.
leadIdstring (UUID)NoLinks the conversation to an existing Tolky lead. Returns 404 if the lead does not exist.
userNamestringNoSaved as the lead name. Applied when you also send externalId.
emailstringNoSaved 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-..."
  }
}
FieldDescription
conversationIdID of the new conversation. Use it in every message.
leadIdLead the conversation belongs to.
sessionIdTechnical session created with the conversation.
StatusWhen
400The token does not resolve to an account.
404The leadId you sent does not exist.
500The conversation could not be created.

Next step

Send a message with the conversationId you received.

Previous

Conventions

Next

Send a message