Send notifications to WhatsApp
Create a WhatsApp messaging template and add WhatsApp to an outbound notification so requesters get record updates on WhatsApp.
Send outbound notifications through WhatsApp when requesters should get record updates on their phones. You end with a notification that sends an approved WhatsApp template, and replies that come back to the record.
Before you begin
- You need the
administratorrole in Servicely and access to the WhatsApp Business Account in Meta. - Complete Connect Sofi to WhatsApp up to Test Connection, so the WhatsApp messaging account holds the phone number ID and access token.
- Make sure each recipient’s user record has Mobile set to their number in international form without the plus sign.
- Know which outbound notification should also send to WhatsApp.
Steps
-
In the WhatsApp Business Account, create a message template and wait for Meta to approve it. Note its name, its language code and the order of its header, body and button variables.
-
In Servicely, go to Administration → Messaging → Messaging templates and select New. Enter a Name and set Provider Type to WhatsApp.
-
Set Subtype to Business Initiated Template. Enter the Meta template name in Template Provider Id.
-
In Mapping Script, set
answerto the language and the values for each template variable, in the order the template defines them. The example below follows the shipped template. Save. -
Go to Administration → Messaging → Outbound notifications and open the notification.
-
On the Providers tab, select New under Provider configurations. Set Provider type to WhatsApp and select the template. Save.
-
Check that the notification is Active and save it.
answer = {
language: language,
header: [title],
body: [recordNumber, description, sender, update],
button: [{url: relativeLink}]
}
The shipped template “Work - with Summary & Client Journal” has a WhatsApp variant. Its Mapping Script describes the matching Meta template: a header, a body with the record number, description, sender and update, and a website button. Replace its Template Provider Id with your approved template’s name before you use it.
Result
When the notification fires, Servicely sends the template to each recipient’s Mobile number from the WhatsApp messaging account. Each sent message is stored as a WhatsApp message linked to the record. When a recipient replies to the notification in WhatsApp, Servicely matches the reply to that record and processes it as an inbound message.
A message that does not reply to a notification goes to the Sofi assistant instead. The application property whatsapp_outbound_notification.autoreply.unlinked_message holds the ID of the messaging template used to answer messages that are not linked to a record.