ConversationHelper
Helper class for chat conversations
isUserParticipantOfConversation(conversation) => boolean#
Checks whether the current user is participant of the conversation passed.
Parameters:
conversation: ConversationState
The conversation state object
Returns:
boolean
true if the current user is participant of the conversation passed, false if not
Example:
import { ConversationHelper, StateHelper } from "@twilio/flex-ui";const conversationState = StateHelper.getConversationStateForTask(task);console.log(ConversationHelper.isUserParticipantOfConversation(conversationState));
getEmailParticipants(conversation) => Array<Array.<string>, Array.<string>>#
Returns the conversation's email participants.
Parameters:
conversation: ConversationState
The conversation state object
Returns:
Array<Array.<string>, Array.<string>>
The returned array has two items:
- at index 0 it's an array of strings with the "to" email participants.
- at index 1 it's an array of strings with the "cc" email participants.
Example:
import { ConversationHelper, StateHelper } from "@twilio/flex-ui";const conversationState = StateHelper.getConversationStateForTask(task);const [to, cc] = ConversationHelper.getEmailParticipants(conversationState);
lastMessage: MessageState#
Returns the last chat message object.
Example:
import { ConversationHelper, StateHelper } from "@twilio/flex-ui";const conversationState = StateHelper.getConversationStateForTask(task);const conversationHelper = new ConversationHelper(conversationState);console.log(conversationHelper.lastMessage);
typers: Array<ParticipantState>#
Gets all conversation participants who are currently typing (except you).
Example:
import { ConversationHelper, StateHelper } from "@twilio/flex-ui";const conversationState = StateHelper.getConversationStateForTask(task);const conversationHelper = new ConversationHelper(conversationState);console.log(conversationHelper.typers);
isCustomerOnline: boolean#
Returns true if the customer is online, false if not.
Example:
import { ConversationHelper, StateHelper } from "@twilio/flex-ui";const conversationState = StateHelper.getConversationStateForTask(task);const conversationHelper = new ConversationHelper(conversationState);console.log(conversationHelper.isCustomerOnline);
conversationType: null | string#
Returns the conversation type. If not found, it returns the channel type. Otherwise, returns null.
Example:
import { ConversationHelper, StateHelper } from "@twilio/flex-ui";const conversationState = StateHelper.getConversationStateForTask(task);const conversationHelper = new ConversationHelper(conversationState);console.log(conversationHelper.conversationType); // Returns conversation type