Business Requirement
We often get requirements from businesses to send SMS from Dynamics CRM to customer on certain actions.
- Send SMS when New Lead created to Customer.
- Send SMS when Status of Case is changed.
- Send SMS to greet customer on his birthday
Proposed Solution
We can make use of Twilio which is a third-party vendor to send an SMS from CRM dynamics.
Steps to achieve this requirement,
- Create custom Activity with name SMS and add fields(Subject - Text data type, From - Text data type, To - Text data type, SID - Text) on to it. SID field is used to store the unique ID from Twilio in response which can be used to track the status of outbound SMS.
- Get a Twilio 14 days trial account here
- Get Twilio Trial Number by follow step by step tutorial here
- Add Twilio DLL Install-Package Twilio? and use ILMerge to merge this DLL with plugin DLL
- Register Post Create plugin on custom activity SMS and use below code to send SMS from CRM.
Notes
- Configure Account Sid and Token in configuration custom entity in CRM and use these configurations in plugin code.
- Configure from number in configuration custom entity in CRM and use these configurations in plugin code.
- Use steps mentioned here to update SMS status from Twilio to CRM dynamics.
- I have hardcoded the Account Sid, Token, body, to and from in my code sample. You will have to use plugin context to get subject and To number and use configurations entity record to get other details.
Conclusion
In today's blog, we learned how we can easily send SMS on various events from Dynamics CRM.
Hope this helps!