Skip to main content

Class: PlivoSmsChannelAdapter

Defined in: packages/agentos/src/io/channels/adapters/PlivoSmsChannelAdapter.ts:65

Channel adapter for SMS backed by Plivo.

Capabilities: text. (MMS media is out of scope for this adapter.)

Extends​

Constructors​

Constructor​

new PlivoSmsChannelAdapter(opts?): PlivoSmsChannelAdapter

Defined in: packages/agentos/src/io/channels/adapters/PlivoSmsChannelAdapter.ts:98

Parameters​

opts?​
fetchImpl?​

{(input, init?): Promise<Response>; (input, init?): Promise<Response>; }

Override the global fetch (inject a mock in tests).

maxNonces?​

number

How many nonces are remembered at once; past it the oldest is forgotten first. Default: 10,000.

nonceTtlMs?​

number

How long the nonce of an accepted callback is remembered, in milliseconds. Default: 24 hours.

retryConfig?​

Partial<RetryConfig>

Connection retry tuning (see BaseChannelAdapter).

Returns​

PlivoSmsChannelAdapter

Overrides​

BaseChannelAdapter.constructor

Properties​

auth​

protected auth: ChannelAuthConfig & object | undefined

Defined in: packages/agentos/src/io/channels/adapters/BaseChannelAdapter.ts:97

Stored auth config so reconnect() can re-use it.

Inherited from​

BaseChannelAdapter.auth


capabilities​

readonly capabilities: readonly ChannelCapability[]

Defined in: packages/agentos/src/io/channels/adapters/PlivoSmsChannelAdapter.ts:68

Declared capabilities of this adapter.

Overrides​

BaseChannelAdapter.capabilities


connectedSince​

protected connectedSince: string | undefined

Defined in: packages/agentos/src/io/channels/adapters/BaseChannelAdapter.ts:92

Inherited from​

BaseChannelAdapter.connectedSince


displayName​

readonly displayName: "Plivo SMS" = 'Plivo SMS'

Defined in: packages/agentos/src/io/channels/adapters/PlivoSmsChannelAdapter.ts:67

Human-readable display name (e.g., "WhatsApp Business").

Overrides​

BaseChannelAdapter.displayName


errorMessage​

protected errorMessage: string | undefined

Defined in: packages/agentos/src/io/channels/adapters/BaseChannelAdapter.ts:93

Inherited from​

BaseChannelAdapter.errorMessage


platform​

readonly platform: ChannelPlatform = 'plivo'

Defined in: packages/agentos/src/io/channels/adapters/PlivoSmsChannelAdapter.ts:66

Platform this adapter serves.

Overrides​

BaseChannelAdapter.platform


platformInfo​

protected platformInfo: Record<string, unknown> = {}

Defined in: packages/agentos/src/io/channels/adapters/BaseChannelAdapter.ts:94

Inherited from​

BaseChannelAdapter.platformInfo


retryConfig​

protected readonly retryConfig: RetryConfig

Defined in: packages/agentos/src/io/channels/adapters/BaseChannelAdapter.ts:101

Inherited from​

BaseChannelAdapter.retryConfig


status​

protected status: ChannelConnectionStatus = 'disconnected'

Defined in: packages/agentos/src/io/channels/adapters/BaseChannelAdapter.ts:91

Inherited from​

BaseChannelAdapter.status

Methods​

doConnect()​

protected doConnect(auth): Promise<void>

Defined in: packages/agentos/src/io/channels/adapters/PlivoSmsChannelAdapter.ts:114

Establish the platform connection using the supplied credentials. Called by initialize after state has been set to connecting. Must throw on failure — the base class handles retry and state changes.

Parameters​

auth​

ChannelAuthConfig & object

Returns​

Promise<void>

Overrides​

BaseChannelAdapter.doConnect


doSendMessage()​

protected doSendMessage(conversationId, content): Promise<ChannelSendResult>

Defined in: packages/agentos/src/io/channels/adapters/PlivoSmsChannelAdapter.ts:172

Deliver a message to the external platform. Called by sendMessage only when the adapter is connected.

Parameters​

conversationId​

string

content​

MessageContent

Returns​

Promise<ChannelSendResult>

Overrides​

BaseChannelAdapter.doSendMessage


doShutdown()​

protected doShutdown(): Promise<void>

Defined in: packages/agentos/src/io/channels/adapters/PlivoSmsChannelAdapter.ts:220

Release platform resources (close WebSocket, stop polling, etc.). Called by shutdown before the state transitions to disconnected.

Returns​

Promise<void>

Overrides​

BaseChannelAdapter.doShutdown


emit()​

protected emit(event): void

Defined in: packages/agentos/src/io/channels/adapters/BaseChannelAdapter.ts:265

Emit an event to all matching subscribers. Subclasses call this when the platform SDK receives an inbound event.

Parameters​

event​

ChannelEvent

Returns​

void

Inherited from​

BaseChannelAdapter.emit


emitConnectionChange()​

protected emitConnectionChange(): void

Defined in: packages/agentos/src/io/channels/adapters/BaseChannelAdapter.ts:296

Convenience helper: emit a connection_change event with the current status. Called automatically by setStatus.

Returns​

void

Inherited from​

BaseChannelAdapter.emitConnectionChange


getConnectionInfo()​

getConnectionInfo(): ChannelConnectionInfo

Defined in: packages/agentos/src/io/channels/adapters/BaseChannelAdapter.ts:205

Get the current connection status and metadata.

Returns​

ChannelConnectionInfo

Inherited from​

BaseChannelAdapter.getConnectionInfo


handleIncomingWebhook()​

handleIncomingWebhook(body, meta?): void

Defined in: packages/agentos/src/io/channels/adapters/PlivoSmsChannelAdapter.ts:259

Handle an inbound Plivo SMS webhook. The host forwards Plivo's request here.

When signature verification is enabled (the default), the request must carry a valid Plivo signature over the URL Plivo requested, and each callback is accepted once: a request whose nonce was already accepted is dropped. Anything else is dropped as well (fail closed).

What a valid signature proves depends on its family:

  • V3 covers the URL, its query, the params and the nonce, so From, Text and MessageUUID are the ones Plivo sent.
  • V2 covers the URL and the nonce only. It does not authenticate From, Text or MessageUUID: whoever holds one callback's signature and nonce can send them again over a different body. Plivo's messaging documentation describes V2 for message callbacks.

The nonce memory narrows that replay; it does not end it. It holds the callbacks this process accepted, for nonceTtlMs (24 hours by default) and maxNonces of them at most, and a restart empties it. Plivo's signatures carry no timestamp, so a callback sent again after its nonce is forgotten, or one this process never accepted, is accepted. Do not let an inbound message authorize an action by its sender number alone.

Parameters​

body​

Record<string, unknown>

Parsed form body of Plivo's inbound-message POST. For a GET callback the params are read from the query string of meta.url, whose values win over body.

meta?​

Request metadata needed to verify the signature.

headers?​

Record<string, string | string[] | undefined>

method?​

string

url?​

string

The exact externally-visible URL Plivo requested (must byte-match); for a GET callback, with its query string.

Returns​

void


hasCapability()​

protected hasCapability(cap): boolean

Defined in: packages/agentos/src/io/channels/adapters/BaseChannelAdapter.ts:312

Check whether this adapter declares a specific capability.

Parameters​

cap​

ChannelCapability

Returns​

boolean

Inherited from​

BaseChannelAdapter.hasCapability


initialize()​

initialize(auth): Promise<void>

Defined in: packages/agentos/src/io/channels/adapters/BaseChannelAdapter.ts:151

Initialize the adapter with auth credentials. If already connected this will shut down the existing connection first (idempotent).

Parameters​

auth​

ChannelAuthConfig

Returns​

Promise<void>

Inherited from​

BaseChannelAdapter.initialize


on()​

on(handler, eventTypes?): () => void

Defined in: packages/agentos/src/io/channels/adapters/BaseChannelAdapter.ts:248

Register an event handler. Returns an unsubscribe function.

Parameters​

handler​

ChannelEventHandler

eventTypes?​

ChannelEventType[]

Returns​

(): void

Returns​

void

Inherited from​

BaseChannelAdapter.on


reconnect()​

reconnect(): Promise<void>

Defined in: packages/agentos/src/io/channels/adapters/BaseChannelAdapter.ts:186

Manually trigger a reconnection attempt using stored credentials. Useful for UI-driven "reconnect" buttons.

Returns​

Promise<void>

Inherited from​

BaseChannelAdapter.reconnect


sendMessage()​

sendMessage(conversationId, content): Promise<ChannelSendResult>

Defined in: packages/agentos/src/io/channels/adapters/BaseChannelAdapter.ts:218

Send a message to a conversation on the external platform.

Parameters​

conversationId​

string

Platform-native conversation/chat ID.

content​

MessageContent

Message content to send.

Returns​

Promise<ChannelSendResult>

The platform-assigned message ID.

Inherited from​

BaseChannelAdapter.sendMessage


sendTypingIndicator()​

sendTypingIndicator(_conversationId, _isTyping): Promise<void>

Defined in: packages/agentos/src/io/channels/adapters/BaseChannelAdapter.ts:234

Default stub — platforms that support typing indicators should override.

Parameters​

_conversationId​

string

_isTyping​

boolean

Returns​

Promise<void>

Inherited from​

BaseChannelAdapter.sendTypingIndicator


setStatus()​

protected setStatus(newStatus, error?): void

Defined in: packages/agentos/src/io/channels/adapters/BaseChannelAdapter.ts:319

Transition to a new connection status and emit an event.

Parameters​

newStatus​

ChannelConnectionStatus

error?​

string

Returns​

void

Inherited from​

BaseChannelAdapter.setStatus


shutdown()​

shutdown(): Promise<void>

Defined in: packages/agentos/src/io/channels/adapters/BaseChannelAdapter.ts:166

Gracefully shut down the adapter and release all resources.

Returns​

Promise<void>

Inherited from​

BaseChannelAdapter.shutdown