WhatsApp Integration via Twilio
You can now integrate ServiceDesk Plus MSP with WhatsApp to trigger WhatsApp
notifications to ServiceDesk Plus MSP technicians/users on the latest events that happen in
the application. This can be done through Twilio and leveraging the already available
Webhooks functionality in ServiceDesk Plus MSP.
Twilio
Twilio provides a link between the internet and telecom networks and helps establish a
communication between the two entities. Twilio can be used to send SMS, WhatsApp
messages and so on.
Twilio Configurations
In order for this integration to work, you need a Twilio account.
To create an account in Twilio, go to
https://console.twilio.com and sign up using the
on-screen instructions. If you already have an account, log in.
Once you have logged in, copy the Account SID and the Auth Token and keep them in a
file. They will be required further to notify users.
After you have copied, locate Messaging - > Settings - > WhatsApp
Sandbox settings from the left pane
In WhatsApp sandbox settings, under Sandbox participants, add the WhatsApp number
that needs to be notified. To add the number, simply send a WhatsApp message to the
Twilio WhatsApp number provided in the instruction with the specified message.
As per the instruction in the image below, the message 'join now-will' has to be sent to
the WhatsApp number '+1 415 523 8886'. This will add the required number to the Twilio
Sandbox.
Twilio can now send WhatsApp messages to the number added. Make a note of the
Twilio sandbox number (+1 415 523 8886 in this case). The number will be required to
notify users.
(NOTE : Using sandbox for WhatsApp messaging is applicable only for Twilio trial
account users. Paid account users can buy their own numbers and use it instead of the
sandbox number.)
ServiceDesk Plus MSP Configurations
Once the configurations in Twilio are done, you can head to ServiceDesk Plus MSP to
configure Webhooks and trigger it through Custom trigger to faciliate Whatsapp
notifications to users based on preset criteria.
To do this,
- Go to Admin > Developer Space > Webhooks.
- Create a new Webhook and provide a name and description.
- Choose the HTTP method as Post.
- In the URL field, provide the URL in the format mentioned below:
Note: In the place of <TWILIO-ACCOUNT-SID>, use the account SID that was copied at the
beginning.
For example, if the account SID is 'xxxx-xxxx-xxxx-xxxx',
In the Authentication field, choose Basic Authentication. The username will be
the Account SID and the password will be the Auth Token of Twilio as mentioned
here.
In the request payload, provide the JSON below :
In the above payload, the 'From' number is the Twilio sandbox number that was copied
in the previous steps. Replace the number (14155238886) with your Sanbox number.
The 'Body' is the message that is to be sent to the user/technician. If a technician needs
to be notified upon a request creation, then the above message body can be used. The
message can be modified to your liking using the dollar variables and the criteria for the
notification.
The 'To' number is the number to which the WhatsApp message has to be sent. If the
mobile number of the technician assigned to the request is the same as the number
subscribed to the Twilio sandbox, then the number can be dynamically fetched using
'${{request.technician.mobile}}'. Else, the number can be hard-coded in the payload
itself. Make sure to include the country code too in the number.
- Choose the Content Type as 'application/x-www-form-urlencoded'. A sample
configuration of the web-hook is shown in the image below :
- Save the Webhook.
- Once the Webhook is saved, you can proceed to create a custom trigger.
Creating a Custom Trigger
- To create a custom trigger, go to Admin > Automation > Custom Triggers. Click a
new trigger and provide the name and description.
- Specify the fields 'Execute on actions', 'Execute during' and 'Cascade Execution'
and the 'Criteria' as per your requirements.
- In the 'Actions' set, select Webhook and choose the webhook that was just
created to notify on WhatsApp.
A sample configuration of the custom trigger is shown below :
Save the trigger. Now when a request is created with the criteria specified in the trigger,
the WhatsApp user will be notified with the message specified in the web-hook. Please
note that this is just an one-way notification integration. Replying to the messages will
initiate a 24-hour chat window and nothing else.
A sample of the message received in
WhatsApp is shown below :