AgentsAgentBase

on_summary

View as MarkdownOpen in Claude

Callback method 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 set_post_prompt() for summaries to be generated.

The default implementation does nothing. You must override it in a subclass or set a set_post_prompt_url() to receive summaries at an external endpoint.

Parameters

summary
Optional[dict[str, Any]]Required

The summary object generated by the AI based on your post-prompt instructions. None if no summary could be extracted from the response.

raw_data
Optional[dict[str, Any]]Defaults to None

The complete raw POST data from the post-prompt request, including metadata like call_id and the full AI response.

Returns

None

Example

1from signalwire import AgentBase
2
3class SupportAgent(AgentBase):
4 def __init__(self):
5 super().__init__(name="support", route="/support")
6 self.set_prompt_text("You are a helpful customer support agent.")
7 self.set_post_prompt("""
8 Summarize this call as JSON:
9 - intent: caller's primary intent
10 - resolved: yes/no/partial
11 - sentiment: positive/neutral/negative
12 """)
13
14 def on_summary(self, summary, raw_data=None):
15 if summary:
16 call_id = raw_data.get("call_id") if raw_data else "unknown"
17 print(f"Call {call_id} summary: {summary}")
18 # save_to_database(call_id, summary)
19
20agent = SupportAgent()
21agent.run()