Developers
ENPT

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

Write it in plain language, for example "I want the customer's city and budget". Build instruction turns that into a schema and clear instructions. You can skip this step if you already have a schema.

Analyze

Send the schema, or the ID of one of your forms, with the instructions and the dialogue. Analyze dialogue returns the extracted data.

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

NameTypeRequiredDescription
instructionsstringYesWhat to look for and how to interpret it.
schemaobjectYes, or formCatalogIdA JSON Schema, or a function definition with name, description and parameters.
formCatalogIdstringYes, or schemaUse one of your forms as the schema. See Forms.
conversationIdstringNoAnalyze this conversation.
dialoguestring or arrayNoText, a list of { "role", "content" } messages (role is user, assistant or system), or a list of conversation IDs.
recordFormDatabooleanNoSave the result to the form. Requires formCatalogId.
leadIdstringNoContact to save the values to, when recordFormData is true. Taken from the conversation when omitted.
avatarIdstringNoAvatar for the saved values. Taken from the conversation when omitted.
modelstringNoModel 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 }
  }
}
FieldDescription
dataThe extracted values, following your schema.
rawResultThe model's raw answer, for debugging.
errornull, or the reason the analysis failed.
metrics.elapsedMsTime spent, in milliseconds.
formDataRecordedOnly 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

NameTypeRequiredDescription
instructionstringYesWhat you want to capture, in plain language.
dialoguestring or arrayNoA sample dialogue that helps interpret the request.
contextDataanyNoExtra context for the interpretation.
emailstringNoFallback 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": { }
  }
}
FieldDescription
jsonSchemaSchema ready to send to Analyze dialogue. It always includes a required email property.
generalInstructionsA short, clear version of your request, ready to use as instructions.
fallbackInstructionsFilled only when the request was unclear: what to clarify.
targetEmailE-mail found in the instruction, or the fallback email. null when there is no valid one.
rawCaptureThe raw interpretation, for debugging.

Errors

CodeWhen
400Missing instructions or instruction, neither schema nor formCatalogId, schema that is not an object, or recordFormData without formCatalogId.
500Unexpected error.

Previous

Forms (FormFlow)

Next

Manager Learning