Get a list of messages from a conversation.
OptionalpageSize: numbernumber of messages per page.
OptionalanchorMessageIndex: numbermessage index to rely on when fetching the messages. Depending on direction will either get messages until, or after this anchorMessageIndex index.
Optionaldirection: MessagesDirectiondirection in which the messages will be sorted - last to first or vice versa.
Pages with messages.
FlexSdkError with the following error code(s):
import { createClient, AddConversationEventListener } from "@twilio/flex-sdk";
const client = await createClient("SDK_TOKEN");
const addConversationEventListener = new AddConversationEventListener("conversationAdded", (conversation) => {
conversation.getMessages();
})
client.execute(addConversationEventListener)
Send a message to a conversation.
passed message either as a SendTextMessageOptions or SendEmailMessageOptions
A message index in conversation or a null.
FlexSdkError with the following error code(s):
import { createClient, AddConversationEventListener } from "@twilio/flex-sdk";
const client = await createClient("SDK_TOKEN");
const addConversationEventListener = new AddConversationEventListener("conversationAdded", (conversation) => {
conversation.sendMessage({body: "hello world!"});
})
client.execute(addConversationEventListener)
Send that worker is currently typing
Promise which resolves when the operation is completed
FlexSdkError with the following error code(s):
import { createClient } from "@twilio/flex-sdk";
import { GetConversationByTask } from "@twilio/flex-sdk/actions/Conversation";
const client = await createClient("SDK_TOKEN");
const getConversationByTask = new GetConversationByTask(
"WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
);
const conversation = await client.execute(getConversationByTask);
await conversation.sendTyping();
Interface for managing a Twilio Conversation.
To listen for events in a particular conversation, we can use the conversation.conversation property, which is an instance of
TwilioConversation.Example