Unanswered counter

The unanswered counter shows that there are clients who are waiting for a response from the seller. We recommend placing the counter on the button, by which the manager goes to the window with all available chats.

To use the unanswered counter, you must connect to the web socket by URL. URL can be obtained by calling:

 GET https://integrations.wazzup24.com/counters/ws_host/api_v3/:apiKey

where apiKey is the API key of your integration.

In response you will receive a json, where the host field will contain the address to connect to.

Example
 ```

{
"host": "ws-counters2.wazzup24.com"
}

```
Use the socket.io library, version 4.1.3 to connect.
Connection example
  // The address obtained by accessing `https://integrations.wazzup24.com/counters/ws_host/api_v3/:apiKey`
const wsHost = 'ws-counters2.wazzup24.com';

// Connection options
const connectOptions = {
path: '/ws-counters/',
transports: ['websocket', 'polling']
};
// Connection
const client = io(`https://${wsHost}`, connectOptions);

Next, generate a counterConnecting event and send an object containing the type, apiKey, and userId fields to complete the connection:

{
"type": "api_v3", // Constant value
"apiKey": "32a817cbc1594bd5885574d8f0290cd3", // API integration key
"userId": "2e0df379" // User Id in CRM
}

Done. Now, when the number of unanswered will change, the data will come in the counterUpdate event in the form of the {counter: number} object.

If no role is selected for an employee in step 1 of the integration settings, the counter will come with 0 and the unanswered counter will show nothing.

If the employee in step 1 of integration settings has the “Sales rep” role selected, the counter will display unanswered only for those deals and contacts for which the manager was assigned responsible in the CRM. If an employee has the “Receives new clients” setting enabled, the counter will also show the number of unanswered messages from clients who are not yet responsible in the CRM.

For the counter to show unanswered for all deals, select the “Manager” role for the employee in step 1 of the integration settings.

Different colors of counters are provided for the roles “Manager” and “Quality Control”. Red for chats that the employee is responsible for, and gray for chats that they only control.

Full example of connecting to the notification service and getting the unanswered counter:

 

 <!-- index.html -->
<!-- Connecting library socket.io version 4.1.3 -->
<script src="https://cdn.socket.io/4.1.3/socket.io.min.js"></script>

<div id="counter"></div>

// apiKey of integration obtained from the Wazzup personal account
const apiKey = '420dadbdd4570844bf3b22629е71';

// id of the sales rep from your CRM
const userId = 'user1';

// Options for connecting to the notification service
const connectOptions = {
path: '/ws-counters/',
transports: ['websocket', 'polling']
};

// Getting the url to connect to the notification service
fetch(`https://integrations.wazzup24.com/counters/ws_host/api_v3/${apiKey}`)
.then((response) => response.json())
.then((data) => {
const { host } = data;

// Connecting with socket.io
const client = io(`https://${host}`, connectOptions);

// Listening to the event 'connect'
client.on('connect', () => {

// Completing the connection: broadcasting the event 'counterConnecting',
// in which we send the customer data
client.emit('counterConnecting', {
type: 'api_v3',
apiKey,
userId 
});
});

// Connection confirmation
client.on('counterConnected', () => console.log('Connected to Wazzup notifications!'));

// Updating the unanswered counter
client.on('counterUpdate', (data) => {
const { counter } = data;
document.getElementById('counter').innerHTML = counter;
});
})

.catch((error) => {
console.log('Connection error', error);
});
An alternative method to get the counter of unanswered

If the basic method doesn’t work, you can get the counter of unanswered requests:

GET https://api.wazzup24.com/v3/unanswered/{user_id}

where user_id is the user id

The response will be a json, where:

  • counterV2 — number of unanswered messages,
  • type — the type of unanswered messages by colour: red or grey. Red for chats that the employee is responsible for in the CRM, and grey for chats that he just controls,
  • lastMsgDateTime — time of the last incoming: year, month, day, exact time.

If no role is selected for the employee in step 1 of the integration settings, the counterV2 will come to 0 and the unanswered counter will not show anything.

If the employee in step 1 of the integration settings has the “Manager” role, the counter will display unanswered only for those transactions and contacts for which the manager has been assigned responsibility in the CRM. If an employee has the “Receives new clients” setting enabled, the counter will also show the number of unanswered messages from clients who are not yet responsible in the CRM.

For the counter to show the unanswered for all transactions, select the “Manager” role for the employee in step 1 of the integration settings.

Example response:

{ 
"counterV2": 7, 
"type": "red", 
"lastMsgDateTime": "2023-05-25T12:30:46.000Z" 
}