Skip to navigation

AI post-prompt callback

View as MarkdownOpen in Claude

Sent to your ai.post_prompt_url when the AI session ends. It carries the agent’s answer to your post_prompt alongside the full record of the call: the conversation, the tool calls, the timings, and the token counts. This is the one report you get per call, so store the body verbatim and extract only the fields you query. Nothing you return in the response is read.

Read action first. It is post_conversation on the end-of-call report described here. The same URL also receives fetch_conversation when the agent starts with a stored conversation (save_conversation with a conversation_id), asking your endpoint to return that conversation; that request carries the call and session fields but none of the summary fields. Answer it with the stored conversation_summary.

The conversation appears three times. call_log is the filtered view, with interrupted segments consolidated. raw_call_log is unfiltered and append-only, and is the only place barge-in detail survives. call_timeline is a flat stream of typed events aligned to raw_call_log.

amazon_bedrock agents send a different report. Write your handler against the Bedrock post-prompt callback instead.

Payload

The payload of this webhook request is an object.
content_typestringRequired

The content type of the request body. Always text/json.

content_dispositionstringRequired

How the body is delivered. agent.summary on the end-of-call report, agent.load_conversation on a request for a stored conversation.

conversation_typeenumRequired

The kind of conversation the agent ran: a call, or a text conversation held over the AI chat endpoint.

Allowed values:
call_idstringRequired
The ID of the call. On a chat conversation this carries the conversation id instead.
app_namestringRequired
The name of your AI application.
ai_session_idstringRequired
The ID of the AI session on the call.
actionenumRequired

What the request is asking of you. post_conversation is the end-of-call report; fetch_conversation asks your endpoint to return a stored conversation.

Allowed values:
project_idstringOptional
Your project ID, when available.
space_idstringOptional
Your Space ID, when available.
ai_id_tagstringOptional
A stable fingerprint of the model the agent ran. Two calls that used the same model share it, so you can group reports by model without recording the model name. Omitted when the session had no model.
conversation_idstringOptional
The conversation ID, when the agent was configured with one.
call_loglist of objectsOptional

The conversation, filtered: interrupted segments are consolidated and evicted entries dropped. Included when action is post_conversation.

raw_call_loglist of objectsOptional

The conversation, unfiltered and append-only. Interruption detail appears here and nowhere else. Included when action is post_conversation.

call_timelinelist of objectsOptional

A flat stream of typed events aligned to raw_call_log, for replaying the call in order. Included when the session produced any.

previous_contextslist of lists of objectsOptional
Conversations from before each context switch, oldest first, one array of messages per switch. Included only when the agent switched context during the call.
hard_timeoutbooleanOptional

Always true when present, meaning the session ended because it hit its configured time limit rather than finishing on its own. Omitted otherwise.

call_start_datelongOptional
When the call was created, as a Unix timestamp in microseconds.
call_answer_datelongOptional

When the call was answered, as a Unix timestamp in microseconds. 0 when it never was.

call_end_datelongOptional
When the call ended, as a Unix timestamp in microseconds.
ai_start_datelongOptional
When the AI session started, as a Unix timestamp in microseconds.
call_ended_bystringOptional
Who or what ended the call. Included when the session recorded it.
ai_end_datelongOptional
When the AI session ended, as a Unix timestamp in microseconds. Omitted when the session was still running.
caller_id_namestringOptional
The caller's name, when available.
caller_id_numberstringOptional
The caller's number, when available.
timeslist of objectsOptional

Per-response performance metrics, one entry per generated reply. Included once the session has any.

SWMLVarsobjectOptional
SWML variables for the call. Included when the call carries SWML state.
SWMLCallobjectOptional
SWML call state. Included when the call carries SWML state.
post_prompt_dataobjectOptional

The agent’s answer to your post_prompt. Included when action is post_conversation.

global_dataobjectOptional

The session’s final global_data. Alongside anything you seeded, the session adds caller_id_name and caller_id_number when the call carries them. Included when action is post_conversation.

swaig_loglist of objectsOptional

Every tool call the agent made, in order. Included when action is post_conversation.

total_minutesintegerOptional

The number of billable minutes, rounded up to at least one. Included when you enable enable_accounting.

total_input_tokensintegerOptional

Input tokens the session consumed. Included when you enable enable_accounting.

total_output_tokensintegerOptional

Output tokens the session produced. Included when you enable enable_accounting.

total_wire_input_tokensintegerOptional

Input tokens counted against the model, which differs from total_input_tokens when the conversation was trimmed. Included when you enable enable_accounting.

total_wire_input_tokens_per_minutedoubleOptional

total_wire_input_tokens divided by total_minutes. Included when you enable enable_accounting.

total_wire_output_tokensintegerOptional

Output tokens counted against the model. Included when you enable enable_accounting.

total_wire_output_tokens_per_minutedoubleOptional

total_wire_output_tokens divided by total_minutes. Included when you enable enable_accounting.

total_tts_charsintegerOptional

Characters sent to text-to-speech. Included when you enable enable_accounting.

total_tts_chars_per_mindoubleOptional

total_tts_chars divided by total_minutes. Included when you enable enable_accounting.

total_asr_minutesdoubleOptional

Minutes of audio sent to speech recognition. Included when you enable enable_accounting.

total_asr_cost_factordoubleOptional

total_asr_minutes divided by total_minutes. Included when you enable enable_accounting.

conversation_summarystringOptional

A plain-language summary of the conversation, for storing against conversation_id and handing back on the next fetch_conversation. Included when you enable save_conversation and set a conversation_id.

Response

200
Webhook received