In this article, we will tell you how to embed the Wazzup chat window into your CRM and set up the work of the "Deals" dropdown based on events.
We recommend working with the "Deals" dropdown using webhooks. And if webhooks can not be used — by events.
To get the link that will open the chat window, you need to call
https://api.wazzup24.com/v3/iframePOST https://api.wazzup24.com/v3/iframe
├── user *
│ ├── id *
│ └── name
├── scope *
├── filter[]
│ ├── chatType
│ ├── chatId
│ └── name
├── activeChat
│ ├── channelId
│ ├── chatType
│ └── chatId
└── options
├── clientType
├── useDealsEvents
└── useMessageEvents
| Parameter Required parameters are marked with * | Type | Description |
| user* | Object user | The object that contains information about the user |
| scope* | String | The context in which the window opens where:
|
| filter | Object (Array) filter | An array of objects with chats to show. Required when scope = card |
| activeChat | Object activeChat | Chat, active on opening iFrame |
| options | Object options | Settings for iFrame events. Required if you decide to create contacts and deals by events. |
| Parameter Required parameters are marked with an asterisk | Type | Description |
| id* | String | ID of the user who opens the chat window |
| name | String | If not specified, the CRM user name will be used. |
| Parameter Required parameters are marked with *an asterisk | Type | Description |
| chatType | String | Entity type in the messenger or social network:
|
| chatId | String |
Entity identifier in the messenger or social network:
|
| name | String | Optional parameter that contains the name of the contact |
| Parameter Required parameters are marked with * | Type | Description |
| channelId | String | Identifier of the channel in which you want to open an active chat when you open iFrame |
| chatType | String | Entity type in the messenger or social network:
|
| chatId | String |
Entity identifier in the messenger or social network:
|
| Parameter Required parameters are marked with * | Type | Description |
| clientType | String | CRM type. You don't have to specify anything |
| useDealsEvents | Boolean | Specify "true" if you want to be notified by iFrame to create or show a deal to the user. The event comes when the user clicks on the + in the "Deals" dropdown to create a deal from our iFrame, or on an entity in the "Deals" dropdown |
| useMessageEvents | Boolean | Specify "true" if you want to be notified by iFrame to create a new contact. The event comes when the user responds to an incoming message from our iFrame |
If a contact with the specified chatType and chatId is not in the Wazzup database, when you open it in the contact card of the CRM system, it will be created. The name will be used as the name, or the chatId if the former is missing.
curl --location --request POST 'https://api.wazzup24.com/v3/iframe' \
--header 'Authorization: Bearer c8cf90554027882f912520f454468d27' \
--header 'Content-Type: application/json' \
--data-raw '
{
"user": {
"id": "222555",
"name": "User Name"
},
"scope": "card",
"filter": [
{
"chatType": "whatsapp",
"chatId": "79998887766"
}
],
"activeChat": {
"chatType": "whatsapp",
"chatId": "79998887766"
}
}
'
The response will come with a json with a link to open the chat window.
If you open the link in the iFrame, add the allow="microphone *; clipboard-write *" attribute to the tag.
You need to specify "microphone" so that users can record voice messages from the chat window. If not, the user will see an error when clicking on the microphone icon to record.
Passing "clipboard-write" is necessary to make clipboard copying work properly in our iFrame. For example, the user could copy the error code from the notification on the button.
<iframe src="link" allow="microphone *; clipboard-write *"></iframe>
{
"url": "https://12345678.wazzup24.com/chat/0e812899-e25b-4a18-a3e4-d1f5890f9de7?token=${token}"
}
In case of an error, the response will receive a json containing the error property, or an http code 500.
{ "error": { "code": "NO_SUCH_ACCOUNT" }
This section describes how to set up the "Deals" dropdown operation in iFrame by events. A recommended way to set up it is with webhooks.
Events signal the need to:
What events can be reported by an iFrame
WZ_CREATE_ENTITY
├── type
└── data
├── chatType
├── chatId
├── channelId
├── userId
└── integrationId
| Field | Type | Description |
| type | String | Event name WZ_CREATE_ENTITY |
| data | Object data | The object that contains the event data |
| Field | Type | Description |
| chatType | String | Entity type in the messenger or social network: whatsapp, instagram, telegram, vk, avito |
| chatId | String |
Entity identifier in the messenger or social network |
| channelId | String | Channel ID |
| userId | Number | CRM user ID |
| integrationId | String | Integration ID |
{
type: 'WZ_CREATE_ENTITY',
data: {
chatType: whatsapp,
chatId: 79998887766,
channelId: c16tc1c-9f20-4rda-46jd-q92ty4j6s36888,
userId: test_id,
integrationId: 608df5ye-45hj-j6k7-l77k-qe5t88j4h1222
}
}
WZ_OPEN_ENTITY
├── type
└── data
├── chatType
├── chatId
├── channelId
├── userId
├── integrationId
└── entity
├── closed
├── id
├── link
├── name
└── responsibleUserName
| Field | Type | Description |
| type | String | Event name WZ_CREATE_ENTITY |
| data | Object data | The object that contains the event data |
| Field | Type | Description |
| chatType | String | Entity type in the messenger or social network: whatsapp, instagram, telegram, vk, avito |
| chatId | String | Entity identifier in the messenger or social network |
| channelId | String | Channel ID |
| userId | Number | CRM user ID |
| integrationId | String | Integration ID |
| entity | Object entity | The object that contains the entity data |
| Field | Type | Description |
| closed | Boolean | Flag. Indicates whether a deal is closed or opened |
| id | Number | Identifier of the entity which is opened by the user |
| link | String | Link to the entity. There can be nothing |
| name | String | Entity name |
| responsibleUserName | String | Name of the user responsible for the entity |
{
type: 'WZ_OPEN_ENTITY',
data: {
chatType: whatsapp,
chatId: 79998887766,
channelId: c16tc1c-9f20-4rda-46jd-q92ty4j6s36888,
userId: test_id,
integrationId: 608df5ye-45hj-j6k7-l77k-qe5t88j4h1222,
entity: {
closed: false,
id: clientId3,
link: #,
name: TestDeal,
responsibleUserName: TestUser
}
}
}
WZ_OUTPUT_MESSAGE
├── type
└── data
├── chatType
├── chatId
├── channelId
├── userId
├── integrationId
├── messageId
├── name
├── username
└── telephone
| Field | Type | Description |
| type | String | Event name WZ_CREATE_ENTITY |
| data | Object data | The object that contains the event data |
| Field | Type | Description |
| chatType | String | Entity type in the messenger or social network: whatsapp, instagram, telegram, vk, avito |
| chatId | String | Entity identifier in the messenger or social network |
| channelId | String | Channel ID |
| userId | Number | CRM user ID |
| integrationId | String | Integration ID |
| messageId | String | Sent Message ID |
| name | String | Name of a contact in messenger, social networks |
| username | String | Contact's @username in Telegram |
| telephone | String | Contact's phone number in Telegram |
{
type: 'WZ_OUTPUT_MESSAGE',
data: {
chatType: whatsapp,
chatId: 79998887766,
channelId: c16tc1c-9f20-4rda-46jd-q92ty4j6s36888,
userId: test_id,
integrationId: 608df5ye-45hj-j6k7-l77k-qe5t88j4h1222,
messageId: 7886о490-49df-8hj3-3jkj-wes4xc54fwd
}
}
1. Generate a link to the iFrame using the API method.
2. Insert that link into the input field of the HTML page.
3. The chat interface will be displayed. You will be able to tap on the necessary buttons to trigger an event — the data that came in this event will appear above the iFrame.