onSummary
Lifecycle hook invoked when a post-prompt summary is received after a conversation ends. Override this method in a subclass to process summaries — for example, saving them to a CRM, triggering follow-up workflows, or logging call outcomes.
A post-prompt must be configured via
setPostPrompt()
for summaries to be generated. With a dynamic config callback set, this runs on the
request’s configured copy of the agent. A summary delivery must carry the token the
SDK adds to the post-prompt URL for that call, or it is refused with 403.
The default implementation does nothing. You must override it in a subclass or set a
setPostPromptUrl()
to receive summaries at an external endpoint.
Parameters
summary
The summary object generated by the AI based on your post-prompt instructions.
null if no summary could be extracted from the response.
rawData
The complete raw POST data from the post-prompt request, including metadata
like call_id and the full AI response.
Returns
void | Record<string, unknown> | Promise<void | Record<string, unknown>> — For a
request whose action is fetch_conversation, return the conversation (for
example { conversation_summary: '...' }); the post-prompt endpoint sends it back
instead of { success: true }. Otherwise the return value is ignored.