Doc Analyzer
Extract structured data from a conversation or any dialogue, using a schema you define or one of your forms.
Doc Analyzer reads a dialogue and returns the data you asked for as JSON. Point it at a conversation, paste a transcript, or send a list of messages, and say what to extract: the customer's budget, the reason for contact, whether they agreed to a visit.
Use it when you need answers about conversations in your own system, for example to fill a CRM, to tag finished calls or to review a batch of chats.
Two steps
Describe what you want
Analyze
With a form, you can also save the result to it, so the values show up for the contact just like values the avatar captured.
ReferenceTechnical details
Both endpoints use a host token (Authorization: Bearer $TOLKY_TOKEN).
Analyze dialogue
POST /api/externalAPIs/public/docAnalyzer/analyzeDialogue
| Name | Type | Required | Description |
|---|---|---|---|
instructions | string | Yes | What to look for and how to interpret it. |
schema | object | Yes, or formCatalogId | A JSON Schema, or a function definition with name, description and parameters. |
formCatalogId | string | Yes, or schema | Use one of your forms as the schema. See Forms. |
conversationId | string | No | Analyze this conversation. |
dialogue | string or array | No | Text, a list of { "role", "content" } messages (role is user, assistant or system), or a list of conversation IDs. |
recordFormData | boolean | No | Save the result to the form. Requires formCatalogId. |
leadId | string | No | Contact to save the values to, when recordFormData is true. Taken from the conversation when omitted. |
avatarId | string | No | Avatar for the saved values. Taken from the conversation when omitted. |
model | string | No | Model to use. Leave it out to use the default. |
curl -X POST "https://api.tolky.to/api/externalAPIs/public/docAnalyzer/analyzeDialogue" \
-H "Authorization: Bearer $TOLKY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"instructions": "Extract the city and the budget the customer mentioned.",
"schema": {
"type": "object",
"properties": {
"city": { "type": "string" },
"budget": { "type": "number" }
}
},
"dialogue": [
{ "role": "user", "content": "I live in Campinas and can spend up to 3000." },
{ "role": "assistant", "content": "Great, I will look for options." }
]
}'{
"code": 200,
"message": "OK",
"data": {
"data": { "city": "Campinas", "budget": 3000 },
"rawResult": { },
"error": null,
"metrics": { "elapsedMs": 1840 }
}
}| Field | Description |
|---|---|
data | The extracted values, following your schema. |
rawResult | The model's raw answer, for debugging. |
error | null, or the reason the analysis failed. |
metrics.elapsedMs | Time spent, in milliseconds. |
formDataRecorded | Only with recordFormData: insertedCount, updatedCount, skippedCount and skipped. |
A failed analysis still answers HTTP 200, with data: null and the reason in error. Always check error.
Build instruction
POST /api/externalAPIs/public/docAnalyzer/buildInstructionFromNatural
| Name | Type | Required | Description |
|---|---|---|---|
instruction | string | Yes | What you want to capture, in plain language. |
dialogue | string or array | No | A sample dialogue that helps interpret the request. |
contextData | any | No | Extra context for the interpretation. |
email | string | No | Fallback e-mail. Used as targetEmail when the instruction does not mention a valid one. |
curl -X POST "https://api.tolky.to/api/externalAPIs/public/docAnalyzer/buildInstructionFromNatural" \
-H "Authorization: Bearer $TOLKY_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "instruction": "I want to know the customer city and budget, and send the result to sales@example.com" }'{
"code": 200,
"message": "OK",
"data": {
"jsonSchema": {
"type": "object",
"additionalProperties": false,
"properties": {
"city": { "type": "string" },
"budget": { "type": "number" },
"email": { "type": "string", "format": "email" }
},
"required": ["email"]
},
"generalInstructions": "Capture the customer's city and budget.",
"fallbackInstructions": "",
"targetEmail": "sales@example.com",
"rawCapture": { }
}
}| Field | Description |
|---|---|
jsonSchema | Schema ready to send to Analyze dialogue. It always includes a required email property. |
generalInstructions | A short, clear version of your request, ready to use as instructions. |
fallbackInstructions | Filled only when the request was unclear: what to clarify. |
targetEmail | E-mail found in the instruction, or the fallback email. null when there is no valid one. |
rawCapture | The raw interpretation, for debugging. |
Errors
| Code | When |
|---|---|
400 | Missing instructions or instruction, neither schema nor formCatalogId, schema that is not an object, or recordFormData without formCatalogId. |
500 | Unexpected error. |