Hi,
SMS messages are a great way to send notifications. When you need to make sure the message reaches its recipient fast and is read right away, SMS is the way to go. Using our Actions component you can easily implement this functionality both on premises and in the cloud, without complex configuration, integrating the text message functionality in your work processes.
UPDATE: There is now a specific subtype for the action described below to integrate Twilio in an even easier way. Give it a try!
In this example, we are going to be sending a text message to a user for whom we create a task in a Tasks list. Once a task is created and the user is specified in the Assigned To column, a text message with the task title will be automatically sent.
First, we need to sign up for an SMS service. There are many options available out there, we will be using Twilio, we've been using it for a while internally and found it to be reliable and affordable. The service exposes a REST API that allows us to send text messages programmatically. Once you're signed up, you will receive API Credentials (Account SID and Auth Token), basically your user name and password for use with the REST API.
Now we are switching to SharePoint to implement our business logic. Although not required, I will be using our User Property column to automatically fetch user's phone number form SharePoint Profile service or directly from Active Directory (on premises only). Of course, you can just type the number in when you create a task, but agree with me that it's a lot easier and cooler when it's done automatically. I'm using the O365 version of Ultimate Forms here, but your on-premises experience is similar. Needless to say, your Profile Service or Active Directory must contain phone numbers for your users.
Add a new User Property column to your Tasks list and call it Phone.
Note a couple of things here. First, I checked Allow editing, that causes the value of the field to not just simply fetch the data for the current user, but become more dynamic such as allow manual entry of the user to fetch, or, as in our case, take the user name from a parent column, such as Assigned To in our case. Locate Work phone in the box on the right and add it to formula.
Now when we create a task and specify a user, it will fetch the phone number automatically.
Next, we add the action that will actually send the text message. Click on Design button in the ribbon, scroll down to Configure Business Logic section and click on Actions. Select Call web service action type and configure the general settings:
The only important thing here is to make sure Run on events is set to New, that will ensure the action runs when an item is added to the list.
Switch to Action Settings tab, this is where we actually configure our connection to Twilio, our SMS service provider.
- Change Service type from SOAP to REST
- Under URL enter the service URL, for Twilio that would be https://api.twilio.com/2010-04-01/Accounts/<Your account SID>/Messages.json. The URL is generally available in the service provider's documentation.
- Switch Authentication to Credentials mode and enter Account SID and Auth Token as your user name and password
- Change Method to Post
- Add property mappings:
- To -> [Phone] - maps the recipient to the Phone column value
- From -> enter the outgoing phone number from Twilio
- Body -> [Task Name] - maps the body of the message to the Task name
Switch to Conditions tab, here we want to ensure that the action is only triggered when the task is actually assigned to a user, add a condition: Assigned To not equals and leave the field on the right empty.
Save the action, you are done! Try adding a new task and assigning it to yourself, check if a text message is delivered. That's it, it just took 2 minutes to implement SMS functionality!