Skip to main content

Examples

Complete Request/Response Example

Request

curl -X POST https://api.example.com/v2/dialog_analyses \
-H "Content-Type: application/json" \
-H "X-Api-Key: YOUR_API_KEY" \
-d '{
"input": {
"messages": [
{"text": "Hello, can you hear me?", "originator": "bot"},
{"text": "Yes, I can!", "originator": "user"},
{"text": "Where are you calling from?", "originator": "bot"},
{"text": "I just moved to London last week", "originator": "user"}
],
"language": "English",
"current_profile": {
"location": "Paris",
"age": null
},
"profile_schema": {
"location": {"type": "string", "description": "User current city"},
"age": {"type": "string", "description": "User age"}
},
"feedback_schema": {
"summary": {"type": "string", "description": "Brief conversation summary"},
"sentiment": {"type": "string", "description": "Overall user sentiment"}
}
}
}'

Initial Response

{
"id": "/v2/dialog_analyses/123",
"state": "in-progress",
"created_at": "2024-12-06T15:30:00.000Z"
}

Status Check

curl -X GET https://api.example.com/v2/dialog_analyses/123 \
-H "X-Api-Key: YOUR_API_KEY"

Completed Response

{
"id": "/v2/dialog_analyses/123",
"state": "completed",
"created_at": "2024-12-06T15:30:00.000Z",
"server_runtime": 8,
"output": {
"profile": {
"location": "London",
"age": null
},
"feedback": {
"summary": "User confirmed they recently relocated to London.",
"sentiment": "Positive"
}
}
}

Example with Numeric Feedback

Request

{
"input": {
"messages": [
{"text": "How was your experience today?", "originator": "bot"},
{"text": "It was okay, nothing special", "originator": "user"}
],
"language": "English",
"current_profile": {
"satisfaction_level": null
},
"profile_schema": {
"satisfaction_level": {"type": "string", "description": "User satisfaction: low, medium, or high"}
},
"feedback_schema": {
"nps_score": {"type": "integer", "description": "Net Promoter Score estimate 0-10"},
"needs_followup": {"type": "boolean", "description": "Whether user needs additional support"}
}
}
}

Response

{
"id": "/v2/dialog_analyses/456",
"state": "completed",
"created_at": "2024-12-06T16:00:00.000Z",
"server_runtime": 5,
"output": {
"profile": {
"satisfaction_level": "medium"
},
"feedback": {
"nps_score": 6,
"needs_followup": false
}
}
}

Example with Extra Prompt Text

Request

{
"input": {
"messages": [
{"text": "Tell me about yourself", "originator": "bot"},
{"text": "I'm a software developer working remotely", "originator": "user"}
],
"language": "English",
"current_profile": {
"occupation": null,
"work_style": null
},
"profile_schema": {
"occupation": {"type": "string", "description": "User job title or profession"},
"work_style": {"type": "string", "description": "remote, hybrid, or office"}
},
"feedback_schema": {
"topics_mentioned": {"type": "string", "description": "Comma-separated list of topics"}
},
"prompt_extra_text": "For work_style, only use values: remote, hybrid, or office. If unclear, use the most likely option based on context."
}
}

Response

{
"id": "/v2/dialog_analyses/789",
"state": "completed",
"created_at": "2024-12-06T16:30:00.000Z",
"server_runtime": 6,
"output": {
"profile": {
"occupation": "software developer",
"work_style": "remote"
},
"feedback": {
"topics_mentioned": "profession, work arrangement"
}
}
}