How to manage a distribution list to send WhatsApp notifications December 04, 2023 20:55 Updated Index: Survey of all your contacts Survey of all your contacts who have already interacted with your bot Survey of all your contacts on an external platform Create a distribution list Creating distribution list via Builder Creating distribution list via API Insert all numbers in the distribution list in the correct format Using the Plugin to create and manage distribution lists Survey of all your contacts First of all, as your users may be coming from different platforms and times, we will modularize this content for easy understanding. Above all, it is worth mentioning that all the content of surveying contacts on WhatsApp is related to the contact number of users. Survey of all your contacts who have already interacted with your bot Suppose you have a BLiP Chatbot and some users who have already interacted with your bot are not on your distribution list. To identify these users, the Get contacts with paging endpoint must be used. When it comes to the Whatsapp channel, the filter used in the query below, returns all users who communicated with your bot using the whatsapp channel. POST https://{{contractid}}.http.msging.net/commands HTTP/1.1Content-Type: application/jsonAuthorization: Key YOUR_TOKEN { "id": "a456-42665544000-0123e4567-e89b-12d3", "method": "get", "uri": "/contacts?$filter=(substringof('WhatsApp'%2Csource))"For each contact returned in the consultation, there will be an identity key, which represents the user's identifier on WhatsApp."items": [ { "name": "John Doe 1", "identity": "553199999999@wa.gw.msging.net", "extras": {}, "source": "WhatsApp" }, { "name": "John Doe 2", "identity": "553188888888@wa.gw.msging.net", "phoneNumber": "+553188888888", "extras": {}, "source": "WhatsApp" } ] Survey of all your contacts on an external platform In possession of the contact numbers, it is necessary to have access to the user's identifier in WhatsApp. Remember to perform this operation only once for each customer. The search for the identifier is done through an HTTP request, considering the customer's mobile phone number in international format "+DDI DDD PHONE_NUMBER". ATTENTION: Do not forget to add the "+" sign before sending. For more details about user verification, check contact, and the validity of the consulted number, access here. Here is an example of a number considering the country code as 55 (Brazil) and the area code as 31 (Minas Gerais). +5531999998888 POST https://{ORGANIZATION_ID}.http.msging.net/commands HTTP/1.1Content-Type: application/jsonAuthorization: Key {YOUR_TOKEN}{"id": "{{$guid}}","to": "postmaster@wa.gw.msging.net","method": "get","uri": "lime://wa.gw.msging.net/accounts/+5531999998888"} Note that one of the headers in this request requires a bot authorization token (YOUR_TOKEN). To find out where to find your bot's token, click here. Below is an example of a response to this request. Note that the resource property has a JSON object that contains the alternativeAccount property, this is the value that identifies the customer on the WhatsApp channel. 5531999998888@wa.gw.msging.net - identifier of the customer who has the mobile number 5531999998888 { "type": "application/vnd.lime.account+json", "resource": { "fullName": "John Doe", "alternativeAccount": "5531999998888@wa.gw.msging.net", "identity": "5531999998888@wa.gw.msging.net", "phoneNumber": "+5531999998888", "source": "WhatsApp" }, "method": "get", "status": "success", "id": "a456-42665544000-0123e4567-e89b-12d3", "from": "postmaster@wa.gw.msging.net", "to": "bot@msging.net", "metadata": { "#command.uri": "lime://wa.gw.msging.net/accounts/+5531999998888" }} Note: This operation must be performed only once for each customer. Create a distribution list There are currently two ways to create a distribution list, directly in the builder or using the API. Below are presented each of these forms with their respective specificities. Creating distribution list via Builder To perform the action of creating a distribution list in Builder, click on any block and select the Actions tab. In the functionality of adding input action, select the distribution list option. With the completion of all previous processes, enter the desired name in the list name field and the add new list button must be clicked to complete the process. The image below indicates in a compiled way the steps presented here. Creating distribution list via API To perform the action of creating a distribution list via API, we will use the endpoint of the documentation (replace {your_distributionList} with the desired name for your list). POST https://{{contractid}}.http.msging.net/commands HTTP/1.1 Content-Type: application/json Authorization: Key {YOUR_TOKEN} { "id": "1", "to": "postmaster@broadcast.msging.net", "method": "set", "type": "application/vnd.iris.distribution-list+json", "uri": "/lists", "resource": { "identity": "{your_distributionList}@broadcast.msging.net" }} Insert all numbers in the distribution list in the correct format Finishing all the previous steps, we will use the API to insert all the contacts raised in the created list. For this we will use the add a member to list endpoint. For each user to be inserted we must execute the request below, remember to replace your_distributionList with the name of your created list that can be obtained in the previous steps or in the get all endpoint lists. POST https://{{contractid}}.http.msging.net/commands HTTP/1.1 Content-Type: application/json Authorization: Key {YOUR_TOKEN} { "id": "3", "to": "postmaster@broadcast.msging.net", "method": "set", "uri": "/lists/{your_distributionList}@broadcast.msging.net/recipients", "type": "application/vnd.lime.identity", "resource": "5531999998888@wa.gw.msging.net"} Using the Plugin to create and manage distribution lists The Blip plugin is an independent way to connect unofficial resources to enhance the functionality of the portal. What are the features of this plugin/tool? View all distribution lists for your bot Add a new distribution list Delete distribution lists View all members of a distribution list Remove members from a distribution list View all bot contacts Add a contact as a member of a distribution list Add a contact as a member of a distribution list from a file [New] Filter bot contacts View all information for a contact How to use? Pre-requisite: Ative a extensão Broadcast List através da loja de plugins Instructions To create distribution lists: Go to the “Manage Lists” tab Click on the “New list” input field and enter the desired name for the list Click on the “Add” button remove distribution lists: Go to the “Manage Lists” tab Select one or more lists in the “List” table Click on the “Remove” button To view all members of a distribution list: Go to the “Manage Members” tab Select a distribution list in the “List” selection To remove members from a distribution list: Go to the “Manage Members” tab Select a distribution list in the “List” selection Select one or more members from the “Members” table Click on the “Remove” button To add a contact as a member of a distribution list: Go to the “Manage Contacts” tab Select a distribution list in the “List” selection Select one or more contacts in the “Contacts” table Click on the “Add” button To add a contact as a member of a distribution list: Go to the “Manage Contacts” tab Select a distribution list in the “List” selection Choose the correctly formatted .txt file Click on the “Import” button For more information, visit the discussion on the subject in our community or the videos on our channel. 😃 Related articles How to send WhatsApp notifications through Blip API Sending WhatsApp Active Messages on Blip Desk Broadcast List How to Send SMS via API Builder variables