Messages
Messages
Clients can send and receive arbitrary data messages to a bot.
Messages differ from actions in that they are not associated with a specific service and do not return a promise.
Messages are used by a voice client for passing an instruction to a bot that typical results in a callback or event.
Examples of messages include:
updateConfig
describeConfig
describeActions
Developers can build their own messages and create handlers to respond to messages received from a bot either by extending VoiceClient
with their own class or by building a helper.
sendMessage()
This is a “fire and forget” function to send an arbitrary message to a bot. It does not wait for a response, so nothing is returned.
Most clients will not use this function directly. They will use actions and helper methods, instead.
It is up to the transport layer to pack and unpack messages, send messages over the wire, and deliver messages to the SDK so that events can be emitted.
voiceClient.sendMessage(message);
Anatomy of a message
{
label: "rtvi-ai",
type: "EVENT_TYPE",
data: { EVENT_TYPE_DATA }
}
// example message dispatch
voiceClient.sendMessage({
label: "rtvi-ai",
type: "myMessage",
data: {
"hello": "world"
}
});