Adds a conversation event listener to the client.
The name of the event to listen for (e.g. "conversationAdded").
The event listener function to be called when the event occurs.
A promise that resolves to an object containing the unsubscribe function to remove the listener.
FlexSdkError with the following error code(s):
import { createClient } from "@twilio/flex-sdk";import { AddConversationEventListener } from "@twilio/flex-sdk/actions/Conversation";async function addConversationEventListener() { const client = await createClient("SDK_TOKEN"); const addConversationEventListener = new AddConversationEventListener("conversationAdded", (conversation) => { // Handle incoming conversation }); const result = await client.execute(addConversationEventListener); return result;} Copy
import { createClient } from "@twilio/flex-sdk";import { AddConversationEventListener } from "@twilio/flex-sdk/actions/Conversation";async function addConversationEventListener() { const client = await createClient("SDK_TOKEN"); const addConversationEventListener = new AddConversationEventListener("conversationAdded", (conversation) => { // Handle incoming conversation }); const result = await client.execute(addConversationEventListener); return result;}
Adds a conversation event listener to the client.
Param: eventName
The name of the event to listen for (e.g. "conversationAdded").
Param: listener
The event listener function to be called when the event occurs.
Returns
A promise that resolves to an object containing the unsubscribe function to remove the listener.
Throws
FlexSdkError with the following error code(s):
Example