Documentation
¶
Overview ¶
Package voicetools provides voice call control tools for AI agents.
These tools enable AI agents to perform telephony operations during voice conversations, including call transfers, hold management, agent consultation, and conferencing.
Available Tools ¶
- transfer_call: Transfer the call to another number or agent queue
- hold_call: Place the caller on hold
- unhold_call: Take the caller off hold
- consult_agent: Query a specialist agent without transferring
- add_to_conference: Add another participant to the call
Usage ¶
// Create a CallContext with your telephony transport ctx := voicetools.NewCallContext(call, transport, agentRegistry) // Create the voice skill with all tools skill := voicetools.NewVoiceSkill(ctx) // Register with MCP server server.RegisterSkill(skill)
Integration ¶
The tools require a CallContext that provides access to:
- The current call (for call metadata)
- The telephony transport (for SIP/WebRTC operations)
- An agent registry (for specialist agent lookup)
See the context.go file for interface definitions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoCallContext is returned when CallContext is not available. ErrNoCallContext = errors.New("call context not available") // ErrNoTransport is returned when TelephonyTransport is not available. ErrNoTransport = errors.New("telephony transport not available") // ErrNoRegistry is returned when AgentRegistry is not available. ErrNoRegistry = errors.New("agent registry not available") // ErrAgentNotFound is returned when a specified agent is not found. ErrAgentNotFound = errors.New("agent not found") // ErrInvalidParameter is returned when a parameter is invalid. ErrInvalidParameter = errors.New("invalid parameter") )
Common errors.
Functions ¶
This section is empty.
Types ¶
type AgentConfig ¶
type AgentConfig struct {
// ID is the agent identifier.
ID string
// Name is a human-readable name.
Name string
// Description describes what the agent specializes in.
Description string
// Capabilities lists what the agent can do.
Capabilities []string
}
AgentConfig describes a specialist agent.
type AgentRegistry ¶
type AgentRegistry interface {
// GetAgent returns an agent configuration by ID.
GetAgent(id string) (AgentConfig, bool)
// ListAgents returns all available agent IDs.
ListAgents() []string
// ConsultAgent sends a query to a specialist agent and returns the response.
ConsultAgent(agentID, query string, context map[string]any) (string, error)
}
AgentRegistry provides access to specialist agents.
type Call ¶
type Call interface {
// ID returns the call identifier.
ID() string
// From returns the caller's phone number (E.164 format).
From() string
// To returns the called number (E.164 format).
To() string
// Direction returns "inbound" or "outbound".
Direction() string
// Duration returns the call duration.
Duration() time.Duration
// Metadata returns call metadata.
Metadata() map[string]string
}
Call represents the current voice call.
type CallContext ¶
type CallContext interface {
// GetCall returns the current call information.
GetCall() Call
// GetTransport returns the telephony transport for call control.
GetTransport() TelephonyTransport
// GetAgentRegistry returns the registry for specialist agents.
GetAgentRegistry() AgentRegistry
}
CallContext provides access to the current call and telephony operations.
func NewCallContext ¶
func NewCallContext(call Call, transport TelephonyTransport, registry AgentRegistry) CallContext
NewCallContext creates a new CallContext.
type ConferenceTool ¶
type ConferenceTool struct {
// contains filtered or unexported fields
}
ConferenceTool adds participants to a conference call.
func NewConferenceTool ¶
func NewConferenceTool(callCtx CallContext) *ConferenceTool
NewConferenceTool creates a new add_to_conference tool.
func (*ConferenceTool) Description ¶
func (t *ConferenceTool) Description() string
Description returns the tool description.
func (*ConferenceTool) Parameters ¶
func (t *ConferenceTool) Parameters() map[string]skill.Parameter
Parameters returns the tool parameters.
type ConsultAgentTool ¶
type ConsultAgentTool struct {
// contains filtered or unexported fields
}
ConsultAgentTool queries a specialist agent without transferring the call.
func NewConsultAgentTool ¶
func NewConsultAgentTool(callCtx CallContext) *ConsultAgentTool
NewConsultAgentTool creates a new consult_agent tool.
func (*ConsultAgentTool) Description ¶
func (t *ConsultAgentTool) Description() string
Description returns the tool description.
func (*ConsultAgentTool) Name ¶
func (t *ConsultAgentTool) Name() string
Name returns the tool name.
func (*ConsultAgentTool) Parameters ¶
func (t *ConsultAgentTool) Parameters() map[string]skill.Parameter
Parameters returns the tool parameters.
type HoldCallTool ¶
type HoldCallTool struct {
// contains filtered or unexported fields
}
HoldCallTool places the caller on hold.
func NewHoldCallTool ¶
func NewHoldCallTool(callCtx CallContext) *HoldCallTool
NewHoldCallTool creates a new hold_call tool.
func (*HoldCallTool) Description ¶
func (t *HoldCallTool) Description() string
Description returns the tool description.
func (*HoldCallTool) Parameters ¶
func (t *HoldCallTool) Parameters() map[string]skill.Parameter
Parameters returns the tool parameters.
type TelephonyTransport ¶
type TelephonyTransport interface {
// Transfer transfers the call to another destination.
// target: E.164 phone number or queue ID
// announce: message to play to the target before connecting (optional)
// warm: if true, stay on line until target answers
Transfer(callID, target string, announce string, warm bool) error
// Hold places the call on hold.
// music: URL to hold music or "default" for provider default
Hold(callID string, music string) error
// Unhold takes the call off hold.
Unhold(callID string) error
// Conference creates or joins a conference.
// participants: E.164 numbers to add to the conference
Conference(callID string, participants []string) error
// Mute mutes the caller's audio.
Mute(callID string) error
// Unmute unmutes the caller's audio.
Unmute(callID string) error
// Hangup ends the call.
Hangup(callID string) error
}
TelephonyTransport provides call control operations.
type TransferCallTool ¶
type TransferCallTool struct {
// contains filtered or unexported fields
}
TransferCallTool transfers the call to another number or agent queue.
func NewTransferCallTool ¶
func NewTransferCallTool(callCtx CallContext) *TransferCallTool
NewTransferCallTool creates a new transfer_call tool.
func (*TransferCallTool) Description ¶
func (t *TransferCallTool) Description() string
Description returns the tool description.
func (*TransferCallTool) Name ¶
func (t *TransferCallTool) Name() string
Name returns the tool name.
func (*TransferCallTool) Parameters ¶
func (t *TransferCallTool) Parameters() map[string]skill.Parameter
Parameters returns the tool parameters.
type UnholdCallTool ¶
type UnholdCallTool struct {
// contains filtered or unexported fields
}
UnholdCallTool takes the caller off hold.
func NewUnholdCallTool ¶
func NewUnholdCallTool(callCtx CallContext) *UnholdCallTool
NewUnholdCallTool creates a new unhold_call tool.
func (*UnholdCallTool) Description ¶
func (t *UnholdCallTool) Description() string
Description returns the tool description.
func (*UnholdCallTool) Parameters ¶
func (t *UnholdCallTool) Parameters() map[string]skill.Parameter
Parameters returns the tool parameters.
type VoiceSkill ¶
VoiceSkill is a skill that provides voice call control tools.
func NewVoiceSkill ¶
func NewVoiceSkill(callCtx CallContext) *VoiceSkill
NewVoiceSkill creates a new voice control skill with all tools.