Twilio Webhooks Using Claris Connect
You can use Claris Connect to create a flow to handle incoming messages from Twilio. This is a much simpler process than using the supplied PHP files for the FileMaker Data API as you don't need to worry about hosting the files and dealing with web servers and PHP configuration changes etc. You can setup a new Claris Connect Flow in a few minutes which can receive incoming SMS messages from Twilio and create a new record in the Replies table.
For information on the supported versions of FileMaker Server/FileMaker Cloud and other minimum requirements please see our Claris Connect Webhooks FAQ article.
To setup a new Claris Connect Flow to receive incoming SMS Messages from Twilio:
1. login to Claris Connect and create a new Project and give the Project a Name (e.g. Twilio Incoming SMS)
2. click the Create New Flow button
3. search for Twilio in the list of triggers and click on the Twilio app
4. select the New SMS Message option and click Continue
5. you will be prompted to sign into your Twilio account. These are the same credentials you have entered in your fmSMS > Accounts record for the Twilio Gateway:
6. after successfully signing in click Continue and you will then be able to select your Twilio Number from the list of phone numbers:
7. once you select your Twilio Number Claris Connect will generate the callback URL to use as the Webhook for receiving incoming SMS Messages. Click the Copy button next to the URL to copy this to your clipboard.
8. login to your Twilio account and click on Phone Numbers in the side navigation then click on the same Twilio Number you selected in Claris Connect. Under Messaging select the Configure with Webhooks/TwiML option then select A Message Comes in “Webhook” and enter the URL in the adjacent field and click Save.. It should look similar to this screenshot:
9. you now need to test the trigger by sending a message from your phone to your Twilio number to simulate an incoming SMS message. After the message has been received by Twilio and sent to your Claris Connect URL it should show the Success message like this screenshot:
Click Save Trigger once this has been successfully tested.
10. you now need to add another action to the Claris Connect Flow which will create a new record in the Replies table in the fmSMS file and populate the relevant fields with data from the incoming SMS. Click the + button and select Action to add a new Action:
In the list of apps search for 'FileMaker' and select the appropriate option for where your copy of fmSMS is hosted:
After selecting the appropriate Claris FileMaker option choose the Create Record option and click Continue:
11. you will then be prompted to authenticate with your Claris FileMaker server (the process is slightly different for each option):
You can use the same FileMaker account that the PHP files use here as they have the required access privileges for receiving incoming messages via the Data API. After you have successfully authenticate click the Continue button:
12. you then need to choose the FileMaker layout to use - select the WebReplies layout which is the same layout the PHP files use and has the necessary fields. To map the Twilio data from the incoming SMS to the matching FileMaker field the blue icon to the right of the following fields and select the option from the list (you should see the data from the test message your sent earlier to your Twilio number):
You only need to map the following fields:
Click the Save button - your Flow should now show the following 2 actions:
You can now toggle the Disabled option to Enabled - you will receive the following prompt:
Click Save to make your Flow active. You can now test this is working successfully by sending another message from your phone to your Twilio number and you should see a new record created shortly after in the Replies table in the fmSMS file.
You can remove the leading + character that is sent by Twilio for the SenderPhoneMobileIntFormat and DestinationPhoneMobileIntFormat fields by adding the following as an auto-enter calculation:
Substitute ( Self ; "+" ; "" )