gateway

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DrainBody

func DrainBody(r io.Reader) ([]byte, error)

DrainBody is a helper for tests.

func MergeDialogPayloadQuery

func MergeDialogPayloadQuery(raw string, payload []byte) (string, error)

MergeDialogPayloadQuery merges a JSON payload object into the dialog URL query as payload=.

func MergeDialogQueryParams

func MergeDialogQueryParams(raw, apiKey, apiSecret, agentID string) (string, error)

MergeDialogQueryParams adds apiKey/apiSecret/agentId query parameters.

func RedactDialogDialURL

func RedactDialogDialURL(u string) string

RedactDialogDialURL redacts sensitive query values for logs.

Types

type Client

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

Client streams dialog events to a dialog app and executes commands on a Session.

func NewClient

func NewClient(cfg ClientConfig) (*Client, error)

NewClient validates cfg. The WebSocket is opened by Start.

func (*Client) Bind

func (c *Client) Bind(sess *dialog.Session)

Bind attaches the voice session that receives commands from the dialog plane.

func (*Client) Close

func (c *Client) Close(reason string)

Close sends call.ended and closes the WebSocket. Idempotent.

func (*Client) ForwardTransferRequest

func (c *Client) ForwardTransferRequest(target string)

ForwardTransferRequest notifies the dialog app of a transfer request.

func (*Client) PushDTMF

func (c *Client) PushDTMF(digit string, end bool)

PushDTMF forwards a DTMF digit to the dialog app.

func (*Client) SendEvent

func (c *Client) SendEvent(ev dialog.Event) error

SendEvent forwards a voice-plane event to the dialog WebSocket.

func (*Client) Start

func (c *Client) Start(ctx context.Context) error

Start dials the dialog WebSocket and starts the command read loop.

type ClientConfig

type ClientConfig struct {
	URL              string
	CallID           string
	HandshakeHeaders http.Header
	DialTimeout      time.Duration

	OnHangup   func(reason string)
	OnASRFinal func(text string)
	OnTTSStart func(utteranceID, text string)
	OnTurn     func(dialog.TurnEvent)

	ReconnectAttempts       int
	ReconnectInitialBackoff time.Duration
	HoldTextFirst           string
	HoldTextRetry           string
	HoldTextGiveUp          string
}

ClientConfig configures a per-call dialog WebSocket client.

Jump to

Keyboard shortcuts

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