Alexa.DefaultMessageProvider Class

The DefaultMessageProvider class implements the MessageProvider interface for devices that run your web app in a WebView. These devices support URL interception and script injection. The class sends messages to the device as HTTP GET requests to JSON-encoded URLs. The device sends messages to the web app by running a known function in the page. By default, the function is window.__dispatchMessage.

Implements

MessageProvider

Constructors

constructor

new DefaultMessageProvider(options?): DefaultMessageProvider

Initializes the message provider with the given options. In most cases, users should not have to supply their own options for these values.

Parameters

Name Type Description
options? Object  
options.apiUrl? string Target URL to which messages are sent. Defaults to a target URL that sends messages to the device to be handled.
options.dispatchFunc? string JavaScript function name that will be called by the device to pass messages from the device to the JavaScript client. Defaults to __dispatchMessage
options.urlLengthLimit? number Maximum number of characters allowed in URL when sending messages, including all query parameters.

Returns

DefaultMessageProvider

Properties

DEFAULT_RATELIMIT_MAX_REQUEST_PER_SEC

static DEFAULT_RATELIMIT_MAX_REQUEST_PER_SEC: number

HEADER_RATELIMIT_LIMIT

static HEADER_RATELIMIT_LIMIT: string[]

HEADER_RATELIMIT_NEXTREQUEST

static HEADER_RATELIMIT_NEXTREQUEST: string[]

HEADER_RATELIMIT_REMAINING

static HEADER_RATELIMIT_REMAINING: string[]

HEADER_RATELIMIT_RESET

static HEADER_RATELIMIT_RESET: string[]

Methods

receive

receive(callback): void

Register the callback for when events from the device are received.

Parameters

Name Type Description
callback (message: Message<any>) => void Function to be called whenever a message is received from the device. Function should take Message as a parameter to receive the contents of the message.

Returns

void

Implementation of

MessageProvider.receive


send

send(command, payload?): Promise<MessageSendResponse>

Sends the command and payload to the device or service responsible for handling events.

Parameters

Name Type Description
command string Command name used to route events to the correct device or service handler.
payload? any Data to be used with the command by the device or service.

Returns

Promise<MessageSendResponse>

A promise that contains the send message result once resolved.

Implementation of

MessageProvider.send


Was this page helpful?

Last updated: Nov 20, 2026