sendAppMessage(data, recipient)

Sends a message to other participants, or another specific participant, during the call.

data should be a javascript object that can be serialized into JSON. Data sent must be within the 4kb size limit.

recipient represents who should receive the message. It can accept a single participant session_id, an array of session_ids, or "*". The "*" value is the default, and means that the message is a "broadcast" message intended for all participants.

Note that the recipient address is the session_id, not the user_id.

Messages are delivered to participants currently in the call. They are not stored. If a recipient is not in the call when the message is sent, the recipient will never receive the message.

Broadcast messages are not delivered to the sender of the message.

Returns this.

You can listen for these messages by installing a handler for the app-message event.

sendAppMessage() in action

We used sendAppMessage() to add chat to our React call object demo app: