Skip to main content
Looking for a drop-in widget? Check out our widgets guide.
Callers can talk to your agent straight from the browser over WebRTC, with no phone number needed.

At a Glance

  1. Create a WebRTC code (grtc-...).
  2. Attach your agent to that code using agent.listen_webrtc("grtc-...").
  3. Start a call from the browser using new Call({ webrtcCode: "grtc-..." }).start().

Create a WebRTC code

A WebRTC code (grtc-...) is like a phone number, but for WebRTC calls. It’s used to route calls from a browser client to your agent. Create one with the Guava CLI.
Alternatively, open the WebRTC page in the Guava dashboard and click Create Code.

Attach your agent to the code

Call listen_webrtc with your code. Like listen_phone, it blocks and handles incoming calls until the process exits.
agent.py

Install the WebRTC SDK

The WebRTC client is included in the TypeScript SDK and runs in the browser.

Start a call

Create a Call with your WebRTC code and call start(). The browser asks for microphone permission, then connects to your agent.
Browsers only allow microphone access after a user gesture, so start the call from something like a click handler. Use onStateChange to update your UI, and hangup() to end the call.

Passing Through Metadata to the Agent

Use customPayload to send metadata from the browser to your agent, such as the signed-in user or the current page.
Your agent receives the payload as custom_payload on the incoming call’s info.
agent.py

Sending and Receiving Messages

During a call, the browser and your agent can exchange JSON messages, for example to react to what the user does on the page or to update your UI from the agent. In the browser, use sendMessage to send a message to the agent, and onMessage to receive messages from it.
Your agent receives browser messages in on_webrtc_message, and sends messages to the browser with call.send_webrtc_message.
agent.py