Here I propose a solution to send SMS text messages from M3.
The desired solution is an exchange of SMS text messages between M3 and the user.
Scenario
For example, let’s suppose we have a scenario where approvers need to review new Customers before setting the Customer’s status to 20-Definite in CRS610. Also, let’s suppose that the approvals are done by SMS text messages. In such a scenario, M3 would send an SMS text message to the user’s mobile phone saying “Please review and approve this new customer XYZ”. The user would respond with an SMS text message saying “APPROVE”. M3 would acknowledge receipt of the approval and would call the API CRS610MI.ChgBasicData to set the Customer’s Status to 20-Definite.
Here is a screenshot of such an exchange between M3 and the approver:
Alternate solutions
The current solutions for such approval scenarios is to use the Smart Office Inbasket, the Mailbox Inbasket, and the Mobile Inbasket of ProcessFlow Integrator (PFI). But those solutions do not support SMS text messaging.
Why it matters
SMS text messaging is a market of 6 trillion SMS text messages sent in 2010 [1], generating $114.6 billion in 2010 [2].
We want M3 to also benefit from the potential of using SMS text messages.
Background
In a previous post, I had posted a solution to Send SMS from Smart Office with Skype. That was a solution for the client-side.
This time, I post a solution using Twilio. And this time the solution is for the server-side.
How it works
I propose a solution that uses PFI and the REST API of Twilio cloud communications.
Twilio is a service that allows developers to programmatically make and receive phone calls, and to send and receive text messages. Twilio’s REST API is XML or JSON over HTTP.
Technically speaking, we want PFI to send an HTTP request to Twilio. The HTTP Request must be over HTTPS, using a POST method, using Basic Authentication, and the Body of the request will contain as parameters the source phone number, the target phone number, and the desired message. We’ll use the WebRun activity node in PFI for that. And when Twilio will receive that HTTP Request it will send the SMS text message on our behalf using its PSTN gateway.
Pre-requisites
Make sure your Twilio account works:
- Open an account with Twilio
- Add funds
- Make sure to get a valid Twilio phone number
- Test it with the Twilio Sandbox
- Test it with the API Explorer
- Write down the Account SID and the Authorization Token, they will be needed for authentication later:
Sample HTTP Request
A sample HTTP Request to send an SMS text message looks like:
POST https://api.twilio.com/2010-04-01/Accounts/ACec246b17f76e0f336a6........../SMS/Messages.xml HTTP/1.1 Authorization: Basic QUNlYzI0NmIxN2Y3NmUwZjMzNmE2NTYzMjI2ZmNmMTUyYzo1ZjA2MDA4NDI0ZGQ1OGFmNWZkMThiYW.........== Content-Type: application/x-www-form-urlencoded Host: api.twilio.com Content-Length: 64 From=%2B14156250342&To=%2B18472874945&Body=Hi%2C+this+is+Thibaud!
Solution
Perform the following steps to implement the solution:
- Open PF Designer
- Create a new flow
- Add a WebRun activity node:
- Open the Properties of the WebRun activity node.
- Set the WebRun to Use external host
- Set the hostname to api.twilio.com
- Set the userid to your Twilio’s AccountSid as shown on your Twilio’s account Dashboard.
- Set the password to your Twilio’s AuthToken as shown on your Twilio’s account Dashboard.
- Check the box SSL enabled
- Set the Web program to:
/2010-04-01/Accounts/{AccountSid}/SMS/Messages.{format}
Where {AccountSid} is your AccountSid, and where {format} is either XML or JSON.
- Set the Post string with a From, To, and Body parameters.
- Set the source From phone number to your Twilio’s number, and URL-encode it. For example, the phone number +14156250342 becomes:
From=%2B14156250342
- Set the destination To phone number to any number you want, and URL-encode it. For example, the phone number +18472874945 becomes:
To=%2B18472874945
- Set the Body of the SMS text message to any text you want, and URL-encode it. For example, the message “Hi, this is PF Designer!” becomes:
Body=Hi%2C+this+is+PF+Designer!
- Separate the From, To, and Body parameters with ampersands &
- Set the Content-type to application/x-www-form-urlencoded.
But because PF Designer doesn’t have that specific content-type in the available list of options, you will have to add it manually in the XML file of the flow with a text editor like Notepad, and URL-encode it. The new value should be application%2Fx-www-form-urlencoded. The result should look like:<activity activityType="WEBRN" ...> <prop className="java.lang.String" name="contentType" propType="SIMPLE"> <anyData><![CDATA[application%2Fx-www-form-urlencoded]]></anyData> </prop> ... </activity>
- Save the flow
- The Properties of the WebRun should look like this:
- Run the flow:
- Now your mobile phone should receive the SMS text message and beep. Here is a screenshot from the SMS text message received on my iPhone:
- You can check the logs in Twilio:
Note: The WebRun activity node was meant for another purpose, to be used in conjunction with S3; we’re sort of deviating the WebRun activity node from its original purpose. So it will submit two more HTTP Requests to PFI – which are unnecessary to our solution – before submitting the HTTP Request to Twilio. It’s inefficient but that’s the only activity node of PFI that can natively submit HTTP Requests. UPDATE: I think I’m wrong here because I was testing from PFI Designer and that may have caused the two extra requests. When deployed the flow will probably not send them. To be verified.
Applications
Here are a few possible applications of sending and receiving SMS text messages from M3:
- Support for users that do not have smartphones
- Support for regions that are covered by GSM only and that lack coverage for 3G/4G/Wifi
- Approve/Reject Customers (CRS610) by text messages
- Approve/Reject Purchase Orders (PPS180) by text messages
- Send driving directions to truck drivers
- Send pick-up reminders
- Place a Customer Order via text messages
- Send notifications by text message when an order changes status.
- Monitoring and alert. To help with the scheduled jobs, such as CAS950, OIS180, PPS600, POs, Invoicing, Stock Transactions, etc. If there is an issue, if the jobs fail or do not complete within the expected time, M3 could alert a maintenance staff via SMS text message to its mobile phone.
Future work
- In addition to sending text messages, we can receive text messages via Twilio, so as to have two-way SMS text messaging with the user.
- As an alternative to PFI, we could use Twilio’s helper libraries in Java to send SMS text messages directly from M3 Business Engine with an MAK modification, i.e. without having to go thru PFI.
- In addition to PFI and M3, we could send SMS text messages from Lawson Smart Office scripts with the Twilio’s helper libraries for .NET.
Conclusion
That was an easy solution to send SMS text messages from PFI. By extension, since M3 Business Engine can trigger PFI flows, we can consider this a solution too for M3 BE to send SMS text messages.
UPDATE: I just learned that Landmark now includes an SMS activity node for Twilio:
Infor Landmark Technology Developer Guides > Infor Process Designer User Help > Notification activity nodes > The SMS activity node
https://docs.infor.com/help_lmrk_cloudsuite_11.0/topic/com.lawson.help.developer/com.lawson.help.lpdug-uw_11.0.x/L93301158231926.html?resultof=%22%74%61%73%6b%22%20
LikeLike