curl --request POST \
--url https://api.example.com/api/chat \
--header 'Content-Type: application/json' \
--data '
{
"message": "<string>"
}
'{
"text": "<string>",
"audio_base64": {}
}Send a message to the AI caller and receive a response with text and audio
curl --request POST \
--url https://api.example.com/api/chat \
--header 'Content-Type: application/json' \
--data '
{
"message": "<string>"
}
'{
"text": "<string>",
"audio_base64": {}
}/api/context first to set the business description and scenario.
null if:{
"error": "Set a business description first (use /api/context)"
}
{
"error": "No message provided"
}
# First, set context
curl -X POST http://localhost:5000/api/context \
-H "Content-Type: application/json" \
-d '{
"description": "We are a pizza restaurant.",
"scenario": "order a large pepperoni pizza"
}'
# Then send a message
curl -X POST http://localhost:5000/api/chat \
-H "Content-Type: application/json" \
-d '{
"message": "Thank you for calling Pizza Palace. How can I help you?"
}'
{
"text": "Hi, I'd like to order a large pepperoni pizza for delivery, please.",
"audio_base64": "SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4Ljc2LjEwMAAAAAAAAAAAAAAA//tQAAAAAAAA..."
}
build_caller_prompt()“You are simulating a real customer contacting the business below. The other side is the company, an operator, or an IVR. Stay in character as the caller/customer, try to complete the task, and avoid escalating to a human unless the flow requires it.”Followed by the business description and caller goal.
JBFqnCBsd6RMkjVDRZzbeleven_turbo_v2_5null for audio_base64 but doesn’t failOPENAI_API_KEY is not set in environment variables, the AI returns:
"I'd like to know more about your business. (Set OPENAI_API_KEY in .env for full conversation.)"
"I had trouble responding: [error message]"
session["messages"] as an array of message objectsrole (“system”, “user”, or “assistant”) and content fields/api/chat calls until /api/context is called again