SuperDialog provides a structured conversation engine - a dialog flow is a graph of states and transitions, and the DialogMachine executes it turn-by-turn. When plugged into an Unpod Session, the machine automatically receives user speech and generates responses without any manual routing code.
create_dialog_flow calls an LLM once to build the flow graph from a natural-language prompt. The LLM is not invoked at runtime - only when building the flow.
import asynciofrom superdialog import create_dialog_flowasync def main(): flow = await create_dialog_flow( prompt=( "You are Sarah, a scheduling assistant for PrimeCare clinic. " "Greet the caller, ask for their name, check if they need to book, " "reschedule, or cancel an appointment, collect necessary details, " "confirm the action, and end the call politely." ), llm="anthropic/claude-haiku-4-5", ) flow.save("clinic.json")asyncio.run(main())
Tools are Python functions the dialog machine can call during a turn - CRM lookups, database writes, external APIs:
from superdialog import DialogMachine, Flow, PythonToolfrom unpod import AgentRunner, CallContextdef check_availability(date: str, time: str) -> dict: """Check appointment availability for a given date and time.""" return calendar_api.check(date, time)def book_appointment(name: str, date: str, time: str) -> str: """Book an appointment and return a confirmation number.""" return calendar_api.book(name=name, date=date, time=time)flow = Flow.load("clinic.json")async def handle_call(ctx: CallContext) -> None: ctx.session.dialog_machine = DialogMachine( flow=flow, llm="anthropic/claude-haiku-4-5", tools=[ PythonTool.of(check_availability), PythonTool.of(book_appointment), ], ) await ctx.session.run()
Or use the @tool decorator:
from superdialog.tools import tool@tooldef check_availability(date: str, time: str) -> dict: """Check appointment availability for a given date and time.""" return calendar_api.check(date, time)# Decorated function is already a PythonTool - pass directly:ctx.session.dialog_machine = DialogMachine( flow=flow, llm="anthropic/claude-haiku-4-5", tools=[check_availability],)
from openai import AsyncOpenAIfrom unpod.adapters import OpenAIAdapterctx.session.dialog_machine = OpenAIAdapter( client=AsyncOpenAI(), model="gpt-4o-mini", system_prompt="You are a helpful support agent.",)
import anthropicfrom unpod.adapters import AnthropicAdapterctx.session.dialog_machine = AnthropicAdapter( client=anthropic.AsyncAnthropic(), model="claude-haiku-4-5-20251001", system_prompt="You are a helpful support agent.",)