- 13 Jun 2023
- 1 Minute to read
- Print
- DarkLight
Invitation
- Updated on 13 Jun 2023
- 1 Minute to read
- Print
- DarkLight
Invitation
Display
Event
Comm100 Live Chat API provides event when invitation shows:
Comm100API.on('livechat.invitation.display', function (invitation) { });
Here, invitation
is an object containing useful info about current invitation:
const invitation = {
id: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', // string, invitation id
campaignId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', // string, campaign id of this invitation
message: '', // string, invitation text
isManual: true, // boolean, whether current invitation is manual invitation
agent: { // agent will be provided if it is manual invitation
id: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', // string, agent id
name: '', // string, name of agent
avatar: '', // string, url of avatar image of this agent
title: '', // string, title of agent
bio: '', // string, bio of agent
},
};
Replace
Instead of using default invitation message, you could also use API to replace it with your own version:
Comm100API.render('livechat.invitation.message', function () {
const component = document.createElement('div');
component.innerText = 'How may I help you?';
return component;
});
To replace it with your own version, you need to return an HTMLElement. If falsy
value is returned, default invitation will be used and skip replacement process. This for auto invitation.
Show Invitation
Action
To display the specific invitation, you could use the following API:
Comm100API.do('livechat.invitation.show', invitationId);
The parameter invitationId
is the ID of the specific auto invitation. The conditions for this invitation will be ignored when you call this API. Invitation will show up if the visitor is not chatting or invited already.
Accept Invitation
Event
To receive events when visitor accept invitation, use:
Comm100API.on('livechat.invitation.accept', function (invitationId) { });
invitationId
as string will be provided as parameter, it is the id of current invitation.
Action
You could also simulate accept invitation action using the following API:
Comm100API.do('livechat.invitation.accept', invitationId);
You need to provide invitation id string of available invitation when accepting invitaiton, otherwise
API will ignore the call.
Refuse Invitation
Event
To receive events when visitor refuse invitation, use:
Comm100API.on('livechat.invitation.refuse', function (invitationId) { });
invitationId
as string will be provided as parameter, it is the id of current invitation.
Action
You could also simulate refuse invitation action using the following API:
Comm100API.do('livechat.invitation.refuse', invitationId);
You need to provide invitation id string of available invitation when refusing invitaiton, otherwise
API will ignore the call.