Skip to main content

Callback Request for post_prompt_url

Request Parameters for post_prompt_url

SignalWire will make a request to the post_prompt_url with the following parameters:

NameTypeDescription
actionstringAction that prompted this request. The value will be "post_conversation".
ai_end_datenumberTimestamp indicating when the AI session ended.
ai_session_idstringA unique identifier for the AI session.
ai_start_datenumberTimestamp indicating when the AI session started.
app_namestringName of the application that originated the request.
call_answer_datenumberTimestamp indicating when the call was answered.
call_end_datenumberTimestamp indicating when the call ended.
call_idstringID of the call.
call_logobjectThe complete log of the call, as a JSON object.
call_log.contentstringContent of the call log entry.
call_log.rolestringRole associated with the call log entry (e.g., "system", "assistant", "user").
call_start_datenumberTimestamp indicating when the call started.
caller_id_namestringName associated with the caller ID.
caller_id_numberstringNumber associated with the caller ID.
content_dispositionstringDisposition of the content.
content_typestringType of content. The value will be text/swaig.
post_prompt_dataobjectThe answer from the AI agent to the post_prompt. The object contains the three following fields.
post_prompt_data.parsedobjectIf a JSON object is detected within the answer, it is parsed and provided here.
post_prompt_data.rawstringThe raw data answer from the AI agent.
post_prompt_data.substitutedstringThe answer from the AI agent, excluding any JSON.
project_idstringID of the Project.
space_idstringID of the Space.
SWMLVarsobjectA collection of variables related to SWML.
swaig_logobjectA log related to SWAIG functions.
total_input_tokensnumberRepresents the total number of input tokens.
total_output_tokensnumberRepresents the total number of output tokens.
versionstringVersion number.

Post Prompt Callback Request Example

Below is a json example of the callback request that is sent to the post_prompt_url:

{
"total_output_tokens": 119,
"caller_id_name": "[CALLER_NAME]",
"SWMLVars": {
"ai_result": "success",
"answer_result": "success"
},
"call_start_date": 1694541295773508,
"project_id": "[PROJECT_ID]",
"call_log": [
{
"content": "[AI INITIAL PROMPT/INSTRUCTIONS]",
"role": "system"
},
{
"content": "[AI RESPONSE]",
"role": "assistant"
},
{
"content": "[USER RESPONSE]",
"role": "user"
}
],
"ai_start_date": 1694541297950440,
"call_answer_date": 1694541296799504,
"version": "2.0",
"content_disposition": "Conversation Log",
"conversation_id": "[CONVERSATION_ID]",
"space_id": "[SPACE_ID]",
"app_name": "swml app",
"swaig_log": [
{
"post_data": {
"content_disposition": "SWAIG Function",
"conversation_id": "[CONVERSATION_ID]",
"space_id": "[SPACE_ID]",
"meta_data_token": "[META_DATA_TOKEN]",
"app_name": "swml app",
"meta_data": {},
"argument": {
"raw": "{\n \"target\": \"[TRANSFER_TARGET]\"\n}",
"substituted": "",
"parsed": [
{
"target": "[TRANSFER_TARGET]"
}
]
},
"call_id": "[CALL_ID]",
"content_type": "text/swaig",
"ai_session_id": "[AI_SESSION_ID]",
"caller_id_num": "[CALLER_NUMBER]",
"caller_id_name": "[CALLER_NAME]",
"project_id": "[PROJECT_ID]",
"purpose": "Use to transfer to a target",
"argument_desc": {
"type": "object",
"properties": {
"target": {
"description": "the target to transfer to",
"type": "string"
}
}
},
"function": "transfer",
"version": "2.0"
},
"command_name": "transfer",
"epoch_time": 1694541334,
"command_arg": "{\n \"target\": \"[TRANSFER_TARGET]\"\n}",
"url": "https://example.com/here",
"post_response": {
"action": [
{
"say": "This is a say message!"
},
{
"SWML": {
"sections": {
"main": [
{
"connect": {
"to": "+1XXXXXXXXXX"
}
}
]
},
"version": "1.0.0"
}
},
{
"stop": true
}
],
"response": "transferred to [TRANSFER_TARGET], the call has ended"
}
}
],
"total_input_tokens": 5627,
"caller_id_num": "[CALLER_NUMBER]",
"call_id": "[CALL_ID]",
"call_end_date": 1694541335435503,
"content_type": "text/swaig",
"action": "post_conversation",
"post_prompt_data": {
"substituted": "[SUMMARY_MESSAGE_PLACEHOLDER]",
"parsed": [],
"raw": "[SUMMARY_MESSAGE_PLACEHOLDER]"
},
"ai_end_date": 1694541335425164,
"ai_session_id": "[AI_SESSION_ID]"
}

Responding to Post Prompt Requests

The response to the callback request should be a JSON object with the following parameters:

{
"response": "ok"
}