Invite Users to Chat in Enhanced Web Chat

You can add an invitation that appears above the floating action button before a chat session begins. Create invitation conditions associated with your embedded service deployment in Setup. For more information on creating invitations in Setup, see Set Up and Customize an Automated Invitation.

To invoke automated invitations based on custom variables, use the invitationAPI.setCustomVariables method.

Invoke Invitations with Custom Conditions 

The invitation conditions created in Setup are custom variables that determine when to show an invitation.

This example snippet populates the invitation condition variables.

Populate Variables
1embeddedservice_bootstrap.invitationAPI.setCustomVariables(
2{"Cart_Total" : "300",
3"Cart_Items" : "6"}
4);

The values of the invitation variables are strings.

Note

This example snippet removes the invitation condition variables.

Remove Variables
1embeddedservice_bootstrap.invitationAPI.removeCustomVariables(["Cart_Total","Cart_Items" ]);

Event Listeners 

Event listeners fire at various stages of the invitation process. There are three event listeners related to invitations.

  • onEmbeddedMessagingInvitationAccepted
  • onEmbeddedMessagingInvitationRejected
  • onEmbeddedMessagingInvitationShown

See Event Listeners for more information.