Documentation
¶
Overview ¶
Package callsystem provides integrations with telephony and meeting platforms.
Index ¶
- type Call
- type CallDirection
- type CallHandler
- type CallOption
- func WithAgent(config *agent.Config) CallOption
- func WithFrom(from string) CallOption
- func WithMachineDetection() CallOption
- func WithObserver(observer observability.VoiceObserver) CallOption
- func WithRecording() CallOption
- func WithStatusCallback(url string) CallOption
- func WithTimeout(timeout time.Duration) CallOption
- func WithWhisper(message string) CallOption
- type CallOptions
- type CallStatus
- type CallSystem
- type CallSystemConfig
- type Client
- func (c *Client) AddProvider(p CallSystem)
- func (c *Client) Close() error
- func (c *Client) GetCall(ctx context.Context, callID string, providerName ...string) (Call, error)
- func (c *Client) ListProviders() []string
- func (c *Client) MakeCall(ctx context.Context, to string, opts ...CallOption) (Call, error)
- func (c *Client) Primary() (CallSystem, bool)
- func (c *Client) Provider(name string) (CallSystem, bool)
- func (c *Client) SetFallbacks(names ...string) error
- func (c *Client) SetPrimary(name string) error
- type Meeting
- type MeetingOption
- type MeetingSystem
- type ObservableCallSystem
- type Participant
- type SMSMessage
- type SMSProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Call ¶
type Call interface {
// ID returns the call identifier.
ID() string
// Direction returns inbound or outbound.
Direction() CallDirection
// Status returns the current call status.
Status() CallStatus
// From returns the caller ID.
From() string
// To returns the called number.
To() string
// StartTime returns when the call started.
StartTime() time.Time
// Duration returns the call duration.
Duration() time.Duration
// Answer answers an inbound call.
Answer(ctx context.Context) error
// Hangup ends the call.
Hangup(ctx context.Context) error
// Transport returns the underlying transport connection.
Transport() transport.Connection
// AttachAgent attaches a voice agent to handle the call.
AttachAgent(ctx context.Context, session agent.Session) error
// DetachAgent detaches the voice agent.
DetachAgent(ctx context.Context) error
}
Call represents a phone or video call.
type CallDirection ¶
type CallDirection string
CallDirection indicates inbound or outbound call.
const ( // Inbound is an incoming call. Inbound CallDirection = "inbound" // Outbound is an outgoing call. Outbound CallDirection = "outbound" )
type CallHandler ¶
CallHandler is called when a new call arrives.
type CallOption ¶
type CallOption func(*CallOptions)
CallOption configures an outbound call.
func WithAgent ¶
func WithAgent(config *agent.Config) CallOption
WithAgent automatically attaches a voice agent to the call.
func WithMachineDetection ¶
func WithMachineDetection() CallOption
WithMachineDetection enables answering machine detection.
func WithObserver ¶ added in v0.6.0
func WithObserver(observer observability.VoiceObserver) CallOption
WithObserver sets a voice observer for call events.
func WithStatusCallback ¶
func WithStatusCallback(url string) CallOption
WithStatusCallback sets a webhook URL for status updates.
func WithTimeout ¶
func WithTimeout(timeout time.Duration) CallOption
WithTimeout sets the call timeout.
func WithWhisper ¶
func WithWhisper(message string) CallOption
WithWhisper sets a whisper message for the agent.
type CallOptions ¶
type CallOptions struct {
From string
Timeout time.Duration
MachineDetect bool
Record bool
Whisper string
AgentConfig *agent.Config
StatusCallback string
Observer observability.VoiceObserver
}
CallOptions holds parsed options for MakeCall. Exported so provider implementations can access option values.
type CallStatus ¶
type CallStatus string
CallStatus represents the call state.
const ( // StatusRinging indicates the call is ringing. StatusRinging CallStatus = "ringing" // StatusAnswered indicates the call is connected. StatusAnswered CallStatus = "answered" // StatusEnded indicates the call has ended. StatusEnded CallStatus = "ended" // StatusFailed indicates the call failed. StatusFailed CallStatus = "failed" // StatusBusy indicates the line was busy. StatusBusy CallStatus = "busy" // StatusNoAnswer indicates no answer. StatusNoAnswer CallStatus = "no_answer" )
type CallSystem ¶
type CallSystem interface {
// Name returns the call system name.
Name() string
// Configure configures the call system.
Configure(config CallSystemConfig) error
// OnIncomingCall sets the handler for incoming calls.
OnIncomingCall(handler CallHandler)
// MakeCall initiates an outbound call.
MakeCall(ctx context.Context, to string, opts ...CallOption) (Call, error)
// GetCall retrieves a call by ID.
GetCall(ctx context.Context, callID string) (Call, error)
// ListCalls lists active calls.
ListCalls(ctx context.Context) ([]Call, error)
// Close shuts down the call system.
Close() error
}
CallSystem defines the interface for telephony/meeting integrations.
type CallSystemConfig ¶
type CallSystemConfig struct {
// AccountSID is the account identifier (Twilio, etc).
AccountSID string
// AuthToken is the authentication token.
AuthToken string //nolint:gosec // G117: field intentionally stores credential
// APIKey is an API key (alternative to AuthToken).
APIKey string //nolint:gosec // G117: field intentionally stores credential
// APISecret is the API secret.
APISecret string //nolint:gosec // G117: field intentionally stores credential
// WebhookURL is the URL for incoming webhooks.
WebhookURL string
// PhoneNumber is the default outbound caller ID.
PhoneNumber string
// Region is the service region.
Region string
// Observer receives voice events for observability.
// If nil, no events are emitted.
Observer observability.VoiceObserver
}
CallSystemConfig configures a call system integration.
type Client ¶ added in v0.6.0
type Client struct {
// contains filtered or unexported fields
}
Client manages multiple CallSystem providers with fallback support.
func NewClient ¶ added in v0.6.0
func NewClient(providers ...CallSystem) *Client
NewClient creates a new Client with the given providers. The first provider becomes the primary by default.
func (*Client) AddProvider ¶ added in v0.6.0
func (c *Client) AddProvider(p CallSystem)
AddProvider adds a provider to the client.
func (*Client) GetCall ¶ added in v0.6.0
GetCall retrieves a call by ID from the specified provider. If no provider is specified, searches all providers.
func (*Client) ListProviders ¶ added in v0.6.0
ListProviders returns the names of all registered providers.
func (*Client) MakeCall ¶ added in v0.6.0
MakeCall initiates an outbound call using the primary provider. If the primary fails and fallbacks are configured, it tries each fallback in order.
func (*Client) Primary ¶ added in v0.6.0
func (c *Client) Primary() (CallSystem, bool)
Primary returns the primary provider.
func (*Client) Provider ¶ added in v0.6.0
func (c *Client) Provider(name string) (CallSystem, bool)
Provider returns a specific provider by name.
func (*Client) SetFallbacks ¶ added in v0.6.0
SetFallbacks sets the fallback providers in order.
func (*Client) SetPrimary ¶ added in v0.6.0
SetPrimary sets the primary provider by name.
type Meeting ¶
type Meeting interface {
// ID returns the meeting identifier.
ID() string
// Title returns the meeting title.
Title() string
// Participants returns current participants.
Participants() []Participant
// Transport returns the transport connection.
Transport() transport.Connection
// AttachAgent attaches a voice agent to the meeting.
AttachAgent(ctx context.Context, session agent.Session) error
// DetachAgent detaches the voice agent.
DetachAgent(ctx context.Context) error
// Leave leaves the meeting.
Leave(ctx context.Context) error
}
Meeting represents a video/audio meeting.
type MeetingOption ¶
type MeetingOption func(*meetingOptions)
MeetingOption configures meeting join behavior.
func WithDisplayName ¶
func WithDisplayName(name string) MeetingOption
WithDisplayName sets the bot display name.
func WithMeetingAgent ¶
func WithMeetingAgent(config *agent.Config) MeetingOption
WithMeetingAgent attaches a voice agent to the meeting.
type MeetingSystem ¶
type MeetingSystem interface {
// Name returns the meeting system name.
Name() string
// JoinMeeting joins an existing meeting.
JoinMeeting(ctx context.Context, meetingID string, opts ...MeetingOption) (Meeting, error)
// LeaveMeeting leaves a meeting.
LeaveMeeting(ctx context.Context, meetingID string) error
// ListMeetings lists active meetings.
ListMeetings(ctx context.Context) ([]Meeting, error)
}
MeetingSystem defines the interface for meeting platform integrations.
type ObservableCallSystem ¶ added in v0.6.0
type ObservableCallSystem interface {
CallSystem
observability.Observable
}
ObservableCallSystem extends CallSystem with observability support. Providers that support observability should implement this interface.
type Participant ¶
type Participant struct {
// ID is the participant identifier.
ID string
// Name is the participant display name.
Name string
// IsMuted indicates if audio is muted.
IsMuted bool
// IsBot indicates if this is a bot participant.
IsBot bool
}
Participant represents a meeting participant.
type SMSMessage ¶ added in v0.6.0
type SMSMessage struct {
// ID is the provider-specific message identifier.
ID string
// To is the recipient phone number (E.164 format).
To string
// From is the sender phone number (E.164 format).
From string
// Body is the message content.
Body string
// Status is the message delivery status.
Status string
}
SMSMessage represents a sent or received SMS message.
type SMSProvider ¶ added in v0.6.0
type SMSProvider interface {
// SendSMS sends an SMS message.
SendSMS(ctx context.Context, to, body string) (*SMSMessage, error)
// SendSMSFrom sends an SMS message from a specific number.
SendSMSFrom(ctx context.Context, to, from, body string) (*SMSMessage, error)
}
SMSProvider defines the interface for sending SMS messages. CallSystem implementations that support SMS should also implement this interface.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package providertest provides conformance tests for CallSystem provider implementations.
|
Package providertest provides conformance tests for CallSystem provider implementations. |