Send Message as the End User in Messaging for Web

Send search queries, user actions, or any text to the Agentforce Service Agent or bot in the chat window by displaying it as if the end user had sent it.

This sample code illustrates how you can use this API.

Use the event handlers in the utilAPI.sendMessage() method to perform actions after the message is sent.

  • then - Use this handler to perform actions when the message is sent successfully.
  • catch - Use this handler to perform actions if the message fails to send.
  • finally - Use this handler to perform clean-up actions, regardless of whether the message was successfully sent or not.