rich-application-94483
05/22/2026, 4:14 PMtall-airline-16756
05/22/2026, 4:15 PMtall-airline-16756
05/22/2026, 4:15 PM{{metadata.key}} you can use in the Agent Builder.
Sources: Agent Builder | LiveKit Documentation | Collect structured data with LiveKit Agents | LiveKit, with interactive elementsrich-application-94483
05/22/2026, 4:16 PMtall-airline-16756
05/22/2026, 4:16 PMChatContext, call an LLM, and POST the summary to your endpoint.
1) Example summarization prompts (pick one and paste into the system message)
• Short: "Summarize the conversation in 2–3 sentences, focusing on the caller's issue, actions taken, and final outcome."
• Action-oriented: "Produce 4–6 bullet points: caller problem, troubleshooting steps, resolution status, follow-up actions, and owner with deadlines if applicable."
• Customer-facing: "Write a 3–4 sentence customer-friendly summary explaining what was discussed, what was resolved, and next steps."
• Internal detailed: "Create a 5–7 sentence internal summary including caller context, key timestamps, decisions, unresolved items, and recommended next actions with priority."
2) Minimal Python example using LiveKit SDK patterns
from livekit.agents import llm, ChatContext
import aiohttp
import asyncio
async def generate_call_summary(summarizer: llm.LLM, chat_ctx: ChatContext, system_prompt: str) -> str:
summary_ctx = ChatContext()
summary_ctx.add_message(role="system", content=system_prompt)
for item in chat_ctx.items:
if item.type == "message" and item.role in ("user", "assistant"):
text = (item.text_content or "").strip()
if text:
summary_ctx.add_message(role=item.role, content=text)
response = await summarizer.chat(chat_ctx=summary_ctx).collect()
return response.text.strip() if response.text else ""
async def send_summary_to_endpoint(summary: str, job_id: str, room_id: str, room_name: str, endpoint: str):
payload = {
"job_id": job_id,
"room_id": room_id,
"room": room_name,
"summary": summary
}
async with aiohttp.ClientSession() as session:
async with session.post(endpoint, json=payload) as resp:
await resp.text()
# Usage example
async def on_call_end(summarizer, chat_ctx, job_id, room_id, room_name, endpoint):
system_prompt = "Summarize the conversation in 2–3 sentences, focusing on the caller's issue, actions taken, and final outcome."
summary = await generate_call_summary(summarizer, chat_ctx, system_prompt)
await send_summary_to_endpoint(summary, job_id, room_id, room_name, endpoint)
3) Key tips
• Use a system message to control tone/format.
• Only include user and assistant messages in the summary context to avoid tool/instruction noise.
• Trigger summarization when the agent determines the call is complete (your logic: task completion, silence detection, or explicit hangup).
If you want, tell me:
• which prompt style you prefer and
• whether you’d like the summary as sentences, bullets, or JSON fields —
and I’ll return a one-line system prompt tailored to that style and an optional variant that injects template variables like {{metadata.case_id}}.
Sources: Agents and handoffs | LiveKit Documentation | How to Use the Supervisor Pattern for Multi-Agent Voice AI Systems | LiveKi..., with interactive elements