LWC Methods for Enhanced Messaging in Lightning Experience
The Conversation Toolkit API for Enhanced Messaging provides methods to interact with a Messaging customer from a Lightning web component (LWC). These methods apply to Lightning web components in Lightning Experience only.
The Conversation Toolkit API is designed for Enhanced Messaging channels, which includes Messaging for In-App and Web, Enhanced Apple, Enhanced Facebook Messenger, Enhanced WhatsApp, Enhanced SMS, and Partner Messaging.
These methods help developers customize the agent experience and how users and other components interact with the conversation component on a page. For example, if you want to customize how an agent composes a message, you can create a messaging composer to draft and send a message during the conversation. These methods only work with an open Messaging Session record page in the console or standard app. If the record is not open, the methods don’t work.
Use only rendered components with the Conversation Toolkit APIs. If you use a component that doesn’t have markup or that operates in the background, the APIs don’t work. The conversation component must also be rendered for the APIs to work.
This sample code is an example of the .html file of an LWC bundle that uses Conversation Toolkit API.
This sample code is an example of the .xml metadata file of the LWC bundle.
This sample code is an example of the .js file of the LWC bundle. Here is where you use the LWC methods for Enhanced Messaging.
These are the LWC methods for Enhanced Messaging.
-
endConversation() for LWC for Lightning Experience
Ends the Messaging session. This method works only in Lightning console apps.
-
getConversationLog() for LWC for Lightning Experience
Retrieves the conversation log. This method works only in Lightning console apps.
-
getEnhancedConversationLog() for LWC for Lightning Experience
Retrieves a full conversation log for a Messaging session. This method works only in Lightning console apps where the conversation component is rendered.
-
inactivateConversation() for LWC for Lightning Experience
Suspends the conversation. This method works only in Lightning console apps.
-
sendTextMessage() for LWC for Lightning Experience
Sends a new text message from the agent to an end user. This method works only in Lightning console apps.
-
setAgentInput() for LWC for Lightning Experience
Sets the text in the agent’s text box. This method works only in Lightning console apps.
-
setMessagingComponent() for LWC for Lightning Experience
Inserts a specified messaging component into the service rep’s text box. You can also use this method to insert text into the service rep’s text box. This method works only in Lightning console apps.
-
sendMessagingComponent() for LWC for Lightning Experience
Sends a new message with a specified messaging component on behalf of the service rep. You can also use this method to send a text message. This method works only in Lightning console apps.
See Also