Skip to main content
This agent answers the phone for a salon. It asks for the caller’s number and keeps it in typed call state. If the number is not valid, the library refuses it and the agent asks again. You need the library with a framework extra. See Installation. The agent hears and speaks through SLNG: Soniox for speech to text and Fish Audio for text to speech. It uses OpenAI for the model. Set SLNG_API_KEY, SLNG_WORLD_PART (your SLNG project’s region, like eu-north) and OPENAI_API_KEY.

The agent

Run it

Install the plugins your framework needs next to the library:
LiveKit console talks to your microphone. Use dev in its place to connect to a LiveKit server. For Pipecat, open http://localhost:7860 and talk.

Try it

Say “My number is six one two, three four five.” That is not a full number. The save is refused, and the agent asks for the number again. Then give a full number with its country code. The agent keeps it.

What the code does

  1. State is a Pydantic model. It holds what the call remembers. Phone is a value type from the library. It checks the number and stores it in E.164.
  2. CallState(State) keeps one live copy of that model for the call.
  3. AgentSpec describes the agent: its prompt, and here save_values=True. It reads the same on both frameworks. save_values=True gives the model a save_values tool. Each save is checked against State. A wrong value comes back to the model with a reason it can act on.
  4. On LiveKit, UnmuteAgent runs the spec as a normal LiveKit Agent. On Pipecat, UnmuteFlows runs it in your pipeline. Each takes the call’s state beside the spec.
  5. Speech to text, the model, text to speech and turn detection stay framework plugins. SLNG’s plugins carry Soniox and Fish Audio. VOICE is a Fish Audio voice id. On LiveKit, stt.attach_to_session(session) lets speech to text close each caller turn as soon as the caller stops. See SLNG.

Where to go next

Pick one path.

Build a salon agent

Grow this agent one piece per page: a greeting, a tool, task steps, a handoff and traces.

Add one piece to your agent

Keep your own LiveKit or Pipecat agent, and add only the parts you need.