Deepgram.Agent.WebSocket (Deepgram v0.1.0)
View SourceWebSocket client for AI voice agent interactions.
This module provides a WebSocket client that can connect to Deepgram's AI voice agent service for real-time conversational AI interactions.
Summary
Functions
Builds WebSocket headers for authentication.
Builds the WebSocket URL for agent connection.
Closes the agent session.
Injects a message into the agent conversation.
Sends a keepalive message to maintain the connection.
Responds to a function call from the agent.
Sends audio data to the agent.
Sends a text message to the agent.
Starts a WebSocket connection for AI voice agent interactions.
Updates the agent's configuration.
Types
@type state() :: %{ client: Deepgram.Client.t(), settings: Deepgram.Types.Agent.settings_options(), callback_pid: pid() | nil, connected: boolean(), keepalive_ref: reference() | nil }
Functions
Builds WebSocket headers for authentication.
Builds the WebSocket URL for agent connection.
@spec close(pid()) :: :ok
Closes the agent session.
@spec inject_message(pid(), Deepgram.Types.Agent.inject_message_options()) :: :ok
Injects a message into the agent conversation.
@spec keepalive(pid()) :: :ok
Sends a keepalive message to maintain the connection.
Responds to a function call from the agent.
Sends audio data to the agent.
Sends a text message to the agent.
@spec start_link( Deepgram.Client.t(), Deepgram.Types.Agent.settings_options(), pid() | nil ) :: {:ok, pid()} | {:error, any()}
Starts a WebSocket connection for AI voice agent interactions.
Parameters
client
- ADeepgram.Client
structsettings
- Agent configuration settingscallback_pid
- Optional PID to receive messages (defaults to caller)
Examples
iex> client = Deepgram.new(api_key: "your-api-key")
iex> settings = %{agent: %{...}, ...}
iex> {:ok, agent} = Deepgram.Agent.WebSocket.start_link(client, settings)
{:ok, #PID<...>}
@spec update_settings(pid(), Deepgram.Types.Agent.settings_options()) :: :ok
Updates the agent's configuration.