---
schema_version: "1"
id: 524204ebb9d2c75e8da3709d25b969a70d1370227bb75a267d1b26da1c0c15c1
title: Invite Users to Chat in Enhanced Web Chat
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/service-cloud/messaging-web/guides/invitation-conditions.md
canonical_url: https://developer.salesforce.com/docs/service/messaging-web/guide/invitation-conditions.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: ea3097f90154eb0b8a220560dc4166a58284b44fff5adecd5924c28032c36965
products:
  - Enhanced Web Chat
  - Service Cloud Developer Content
---
# 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](https://help.salesforce.com/s/articleView?id=service.miaw_chat_invitations.htm).

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.

```javascript
embeddedservice_bootstrap.invitationAPI.setCustomVariables(
{"Cart_Total" : "300",
"Cart_Items" : "6"}
);
```

**note:** The values of the invitation variables are strings.

This example snippet removes the invitation condition variables.

```javascript
embeddedservice_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](https://developer.salesforce.com/docs/service/messaging-web/guide/event-listeners.md) for more information.
