> **Note:** The latest version of this document is always available at https://docs.goguava.ai/llms.txt. # Guava — Guide for AI Coding Agents This document is written for AI coding agents. It is the starter kit for building a Guava voice agent. Read this preamble first — it gives you the mental model and setup steps — then use the reference sections that follow it as your API reference. # How Guava works (mental model) Every Guava call has two halves: - **Dialog System** — Guava's hosted service. It runs all the real-time audio: speech-to-text, the conversational LLM, and text-to-speech. You do not run or configure this. - **Your Expert** — the code you write. It connects to the Dialog System over a WebSocket and steers the call by registering **handlers** (callbacks that fire on call events) and issuing **commands** on the live `Call` object. You build an Expert by: (1) creating an `Agent` (name, organization, one-line purpose), (2) registering handlers, (3) giving the agent **Tasks** — each a goal plus a checklist of **Fields** to collect — and (4) attaching the agent to a channel (a phone number, WebRTC, SIP, or a local/chat test session). Handlers run **off** the real-time dialog thread. Doing slow work inside them (database lookups, RAG queries, external API calls) is safe and does not block or delay the caller. ## Setup You SHOULD use the Guava CLI — it handles authentication and resources like phone numbers. **You MUST install the CLI unless the user tells you not to.** Ask the user if you are unsure. ```bash guava --version # detect if the CLI is already installed curl -fsSL https://goguava.ai/install.sh | sh # install on macOS / Linux / WSL irm https://goguava.ai/install.ps1 | iex # install on Windows (PowerShell) ``` Then scaffold and run a project: ```bash guava create my-agent # scaffold a new project — the recommended starting point ``` The SDK reads these environment variables automatically: ```bash export GUAVA_API_KEY="..." # your API key export GUAVA_AGENT_NUMBER="+15551234567" # a phone number you own; used by the examples ``` ## Conventions you MUST follow - **Naming:** Python uses `snake_case`; TypeScript uses the `camelCase` equivalent (`on_call_start` → `onCallStart`, `set_task` → `setTask`, and so on). The reference sections below use the Python names. - **Language threading:** Python handlers are synchronous `def`. TypeScript handlers are `async`, and their `call.*` commands are awaited. Write handlers in the idiom of the SDK you are using. - **Keep `purpose` short.** `Agent(purpose=...)` is a one-line orientation, not a system prompt. You steer behavior with Tasks and checklists, not a giant prompt. - **Python logging:** if the project has no logger yet, call `guava.logging_utils.configure_logging()`. It configures logging from env vars, captures warnings, and enables colored output. (TypeScript: `getDefaultLogger()`.) - **Python package manager:** prefer **uv** unless the project already uses something else. - **Run entrypoints in the background.** `listen_phone`, `listen_webrtc`, `call_local`, etc. block; run them in the background so the user's terminal is not tied up. ## Minimal example ```python import os import guava from guava import logging_utils agent = guava.Agent( name="Mia", organization="Thai Palace", purpose="Add callers to the waitlist.", ) @agent.on_call_start def on_call_start(call: guava.Call): call.set_task( "waitlist", objective="Add the caller to the waitlist.", checklist=[ guava.Field(key="caller_name", field_type="text"), guava.Field(key="party_size", field_type="integer"), ], ) @agent.on_task_complete("waitlist") def waitlist_done(call: guava.Call): print(call.get_field("caller_name"), call.get_field("party_size")) call.hangup("Thank the caller and let them know we'll text when a table is ready.") if __name__ == "__main__": logging_utils.configure_logging() agent.listen_phone(os.environ["GUAVA_AGENT_NUMBER"]) # run in the background ``` ## Common mistakes to avoid - **Don't write a long `purpose`.** Use Tasks and checklists to drive behavior. - **Never combine `reach_person()` and `set_voicemail_action()`** — both handle voicemail and using both raises an error. When using `reach_person()`, set voicemail behavior via its `voicemail_message` / `voicemail_hangup` parameters instead. - **Don't do real-time work in `on_session_end`** — the call has already ended, so `call.*` commands won't reach the caller. - **Don't block the wrong way:** slow work *inside handlers* is fine (they run off the dialog thread), but *entrypoints* block the process — run them in the background. The full docs index follows below. Start with the archtecture overview. # Guava Documentation - [Quickstart](https://docs.goguava.ai/getting-started/quickstart.md): Install the Guava CLI and run your first voice agent - [Quickstart (SDK-only)](https://docs.goguava.ai/getting-started/sdk-quickstart.md): Install the Guava SDK directly and run an example agent - [Guava Architecture Overview](https://docs.goguava.ai/getting-started/architecture-overview.md): How Guava's Dialog System and your Expert work together on every call - [Inbound Q&A](https://docs.goguava.ai/getting-started/inbound-rag-example.md): Build an inbound agent that answers policy questions with RAG - [Inbound Form Filling](https://docs.goguava.ai/getting-started/inbound-form-filling.md): Build an inbound agent that collects information from callers - [Outbound Scheduling](https://docs.goguava.ai/getting-started/outbound-scheduling.md): Build an outbound agent that schedules appointments - [Agent](https://docs.goguava.ai/sdk-reference/agent.md): The entrypoint for creating Guava voice agents - [Task](https://docs.goguava.ai/sdk-reference/tasks.md): The unit of work your agent completes on a call - [Field](https://docs.goguava.ai/sdk-reference/field.md): Collect structured data from the caller - [Automated Testing for Guava Agents](https://docs.goguava.ai/sdk-reference/agent-testing.md): Test your agents end-to-end with your existing testing framework - [Runner](https://docs.goguava.ai/sdk-reference/runner.md): Serve multiple agents in a single process - [Client](https://docs.goguava.ai/sdk-reference/client.md): Manage account-level resources - [on_question()](https://docs.goguava.ai/sdk-reference/on-question.md): Answer caller questions the agent can't answer from context - [on_action_request() / on_action()](https://docs.goguava.ai/sdk-reference/on-action-request-execute.md): Classify and execute caller requests - [on_task_complete()](https://docs.goguava.ai/sdk-reference/on-task-complete.md): React when the agent completes a task - [on_caller_dtmf()](https://docs.goguava.ai/sdk-reference/on-caller-dtmf.md): React to keypad presses from the caller - [on_agent_dtmf()](https://docs.goguava.ai/sdk-reference/on-agent-dtmf.md): Observe keypad presses sent by the agent - [on_session_end()](https://docs.goguava.ai/sdk-reference/on-session-end.md): React when a call session ends - [on_agent_speech()](https://docs.goguava.ai/sdk-reference/on-agent-speech.md): Receive every utterance spoken by the agent - [on_caller_speech()](https://docs.goguava.ai/sdk-reference/on-caller-speech.md): Receive every utterance spoken by the caller - [on_escalate()](https://docs.goguava.ai/sdk-reference/on-escalate.md): Handle requests to escalate to a human - [set_task()](https://docs.goguava.ai/sdk-reference/set-task.md): Direct the agent toward a new goal mid-call - [set_persona()](https://docs.goguava.ai/sdk-reference/set-persona.md): Set the agent's name, organization, purpose, and voice for a call - [send_instruction()](https://docs.goguava.ai/sdk-reference/send-instruction.md): Send a real-time instruction to the agent without changing the task - [set_variable() / get_variable()](https://docs.goguava.ai/sdk-reference/get-set-variable.md): Pass per-call data between agent handlers - [set_language_mode()](https://docs.goguava.ai/sdk-reference/set-language-mode.md): Let the agent understand and respond in additional languages - [transfer()](https://docs.goguava.ai/sdk-reference/transfer.md): Hand the call off to another phone number or SIP address - [hangup()](https://docs.goguava.ai/sdk-reference/hangup.md): Let the agent close the conversation naturally, then end the call - [reach_person()](https://docs.goguava.ai/sdk-reference/reach-person.md): Confirm you have the right person on the line for outbound calls - [set_voicemail_action()](https://docs.goguava.ai/sdk-reference/set-voicemail-action.md): Tell the agent what to do if it reaches an answering machine - [read_script()](https://docs.goguava.ai/sdk-reference/read-script.md): Speak a verbatim opening statement at the start of a call - [add_info()](https://docs.goguava.ai/sdk-reference/add-info.md): Give the agent additional context for the call - [get_field()](https://docs.goguava.ai/sdk-reference/get-field.md): Retrieve values collected by the agent - [Intent Helpers](https://docs.goguava.ai/sdk-reference/intent-helpers.md): Classify caller requests into your predefined intents - [DocumentQA](https://docs.goguava.ai/sdk-reference/document-qa.md): Answer caller questions against your documents using RAG - [DatetimeFilter](https://docs.goguava.ai/sdk-reference/datetime-filter.md): Match natural-language time requests against available slots - [Vector Stores](https://docs.goguava.ai/sdk-reference/vector-stores.md): Ready-made vector store backends for DocumentQA local mode - [CLI Reference](https://docs.goguava.ai/cli-reference/cli-reference.md): Commands, project configuration, and troubleshooting for the Guava CLI - [Receiving WebRTC Calls on Guava Agents](https://docs.goguava.ai/guides/webrtc-calls.md): Let callers talk to your agent straight from the browser - [WebRTC Widget](https://docs.goguava.ai/guides/webrtc-widgets.md): Embed a Guava voice agent on your website with a single script tag - [Adding a Guava Voice Agent to a Base44 App](https://docs.goguava.ai/guides/base44-guide.md): Deploy a Guava agent and build a Base44 frontend that talks to it over WebRTC - [Adding a Guava Voice Agent to a Lovable App](https://docs.goguava.ai/guides/lovable-guide.md): Deploy a Guava agent and build a Lovable frontend that talks to it over WebRTC - [SIP Integrations](https://docs.goguava.ai/guides/sip-integrations.md): Receive inbound calls over SIP from an SBC, PBX, or softphone - [SIP Transfers](https://docs.goguava.ai/guides/sip-transfers.md): How SIP REFER transfers work and how to choose transfer destinations - [Cisco CUBE / CUCM](https://docs.goguava.ai/guides/cisco-cube-cucm.md): Integrate Guava with Cisco CUBE and CUCM - [Twilio Programmable Voice / TwiML](https://docs.goguava.ai/guides/twilio-programmable-voice.md): Transfer Twilio Programmable Voice calls to a Guava agent using TwiML - [Twilio Elastic SIP Integration](https://docs.goguava.ai/guides/twilio-elastic-sip.md): Connect a Twilio phone number to a Guava agent using Elastic SIP Trunking - [Warm Transfers Using Twilio Programmable Voice](https://docs.goguava.ai/guides/twilio-warm-transfers.md): Brief a human representative before connecting the caller - [SMS Messaging](https://docs.goguava.ai/guides/messaging.md): Send SMS messages from your Guava numbers and wait for replies - [Outbound Campaigns](https://docs.goguava.ai/guides/campaign.md): Call many contacts with automatic retries, calling windows, and concurrency control - [Agentic Tenacity](https://docs.goguava.ai/guides/agentic-tenacity.md): Warm up campaign contacts with pre-call SMS messages - [Warm Transfers](https://docs.goguava.ai/guides/warm-transfers.md): Brief a human representative before connecting the caller - [AI Customer Service with Amazon Connect](https://docs.goguava.ai/guides/amazon-connect-ai-customer-service.md): Route Amazon Connect calls to a Guava agent that answers questions and escalates - [Appointment Reminders with Amazon Connect](https://docs.goguava.ai/guides/amazon-connect-appointment-reminder.md): Place appointment reminder calls and log outcomes as Amazon Connect tasks - [CSAT Surveys with Amazon Connect](https://docs.goguava.ai/guides/amazon-connect-csat-survey.md): Run post-call satisfaction surveys and log results as Amazon Connect tasks - [Product Support with Amazon Connect](https://docs.goguava.ai/guides/amazon-connect-product-support.md): Handle product support calls and create Amazon Connect tasks for follow-up - [Deploy Your Agent to Guava's Managed Cloud](https://docs.goguava.ai/guides/deployment.md) - [Deploying Guava Agents on Heroku](https://docs.goguava.ai/guides/deploy-heroku.md): Run a Guava agent as a Heroku background worker - [Deploying Guava Agents on AWS ECS (Fargate)](https://docs.goguava.ai/guides/deploy-aws-ecs.md): Run a Guava agent as an ECS service on Fargate - [Outbound & SMS Compliance](https://docs.goguava.ai/guides/outbound-and-sms-permissions.md): Register your organization for outbound calling and SMS - [Phone Number Trust & Reputation](https://docs.goguava.ai/guides/phone-number-trust-reputation.md): Improve pickup rates for your outbound phone numbers - [Single sign-on (SSO)](https://docs.goguava.ai/guides/sso.md): Require your team to sign in to Guava through your identity provider - [Release Notes](https://docs.goguava.ai/release-notes.md): What's new in Guava. - [API Reference](https://docs.goguava.ai/api-reference/api-overview.md): Base URL, authentication, and general endpoints for the Guava REST API - [Campaigns API](https://docs.goguava.ai/api-reference/campaigns-api.md): Create and manage outbound campaigns and their contacts over HTTP - [Conversations API](https://docs.goguava.ai/api-reference/conversations-api.md): List conversations and fetch details, transcripts, and recordings - [Messages API](https://docs.goguava.ai/api-reference/messages-api.md): Send SMS messages and list inbound and outbound messages - [Create WebRTC agent routing code](https://docs.goguava.ai/api-reference/create-webrtc-agent-routing-code.md): Creates a code that lets WebRTC clients connect to your agent. - [Create WebRTC client token](https://docs.goguava.ai/api-reference/create-webrtc-client-token.md): Creates a short-lived token that lets a client connect to a WebRTC code. - [Delete conversation](https://docs.goguava.ai/api-reference/delete-conversation.md): Deletes a conversation, including its transcript and recordings. - [Check component deprecation](https://docs.goguava.ai/api-reference/check-component-deprecation.md): Checks whether a given version of a Guava component is still supported. - [List received SMS messages](https://docs.goguava.ai/api-reference/sms/list-received-sms-messages.md): Lists SMS messages received on one of your organization's numbers, oldest first. - [Send SMS](https://docs.goguava.ai/api-reference/sms/send-sms.md): Sends an SMS from one of your organization's phone numbers. ## OpenAPI Specs - [openapi](https://app.goguava.ai/openapi.json)