callsystem

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package callsystem provides a Twilio implementation of callsystem.CallSystem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	// contains filtered or unexported fields
}

Call implements callsystem.Call for Twilio calls.

func (*Call) Answer

func (c *Call) Answer(ctx context.Context) error

Answer answers an inbound call.

func (*Call) AttachAgent

func (c *Call) AttachAgent(ctx context.Context, session agent.Session) error

AttachAgent attaches a voice agent to handle the call.

func (*Call) DetachAgent

func (c *Call) DetachAgent(ctx context.Context) error

DetachAgent detaches the voice agent.

func (*Call) Direction

func (c *Call) Direction() callsystem.CallDirection

Direction returns inbound or outbound.

func (*Call) Duration

func (c *Call) Duration() time.Duration

Duration returns the call duration.

func (*Call) From

func (c *Call) From() string

From returns the caller ID.

func (*Call) Hangup

func (c *Call) Hangup(ctx context.Context) error

Hangup ends the call.

func (*Call) ID

func (c *Call) ID() string

ID returns the call identifier.

func (*Call) SetTransport

func (c *Call) SetTransport(conn omnitransport.Connection)

SetTransport sets the transport connection (called when Media Streams connects).

func (*Call) StartTime

func (c *Call) StartTime() time.Time

StartTime returns when the call started.

func (*Call) Status

func (c *Call) Status() callsystem.CallStatus

Status returns the current call status.

func (*Call) To

func (c *Call) To() string

To returns the called number.

func (*Call) Transport

func (c *Call) Transport() omnitransport.Connection

Transport returns the underlying transport connection.

type Option

type Option func(*options)

Option configures the Provider.

func WithAccountSID

func WithAccountSID(sid string) Option

WithAccountSID sets the Twilio Account SID.

func WithAuthToken

func WithAuthToken(token string) Option

WithAuthToken sets the Twilio Auth Token.

func WithPhoneNumber

func WithPhoneNumber(number string) Option

WithPhoneNumber sets the default outbound phone number.

func WithWebhookURL

func WithWebhookURL(url string) Option

WithWebhookURL sets the webhook URL for incoming calls.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider implements callsystem.CallSystem using Twilio.

func New

func New(opts ...Option) (*Provider, error)

New creates a new Twilio CallSystem provider.

func (*Provider) Close

func (p *Provider) Close() error

Close shuts down the call system.

func (*Provider) Configure

func (p *Provider) Configure(config callsystem.CallSystemConfig) error

Configure configures the call system.

func (*Provider) GetCall

func (p *Provider) GetCall(ctx context.Context, callID string) (callsystem.Call, error)

GetCall retrieves a call by ID.

func (*Provider) HandleIncomingWebhook

func (p *Provider) HandleIncomingWebhook(callSID, from, to string) (callsystem.Call, string, error)

HandleIncomingWebhook processes a Twilio incoming call webhook. This should be called from your HTTP handler.

func (*Provider) HandleStatusCallback

func (p *Provider) HandleStatusCallback(callSID, status string)

HandleStatusCallback processes a Twilio status callback webhook.

func (*Provider) ListCalls

func (p *Provider) ListCalls(ctx context.Context) ([]callsystem.Call, error)

ListCalls lists active calls.

func (*Provider) MakeCall

func (p *Provider) MakeCall(ctx context.Context, to string, opts ...callsystem.CallOption) (callsystem.Call, error)

MakeCall initiates an outbound call.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

func (*Provider) OnIncomingCall

func (p *Provider) OnIncomingCall(handler callsystem.CallHandler)

OnIncomingCall sets the handler for incoming calls.

func (*Provider) SendSMS

func (p *Provider) SendSMS(ctx context.Context, to, body string) (*callsystem.SMSMessage, error)

SendSMS sends an SMS message using the default phone number.

func (*Provider) SendSMSFrom

func (p *Provider) SendSMSFrom(ctx context.Context, to, from, body string) (*callsystem.SMSMessage, error)

SendSMSFrom sends an SMS message from a specific phone number.

func (*Provider) Transport

func (p *Provider) Transport() *transport.Provider

Transport returns the transport provider for Media Streams.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL