MMS Gateway - Twilio API for WhatsApp

The Twilio API for WhatsApp MMS Gateway currently delivers MMS messages to USA and Canadian phone numbers. You can use the following methods for attaching media files to your outgoing messages:

  • Public URL: simply enter the publicly accessible URL for each media file that you wish to send. You would typically upload the file (jpeg, png etc) to a server and determine the URL to that file and enter this into the URL field when sending an MMS message.
  • Get Media Record URL: using the supplied getMediaURL.php file (versions for both the FileMaker Data API and the FileMaker PHP API are included) you can generate a dynamic URL on the fly that Twilio can use to download a media file from the container field in the Media table record. This requires the fmMMS file to be hosted on FileMaker Server. N.B. the getMediaURL.php file currently doesn't work with FileMaker Cloud 2.x deployments due to the differences in how authentication is handled for FileMaker Cloud 2.x users with the Data API. We hope to have a version of the getMediaURL.php file that supports FileMaker Cloud 2.x soon.

There are some important differences that are unique to WhatsApp compared with the regular Twilio MMS API, including:

  1. a WhatsApp media message can only contain one media attachment. Any additional attachments will be ignored
  2. You can send media messages to any WhatsApp user who has sent you a message within the past 24 hours
  3. WhatsApp does not support including a text body in the same message as a video, audio file or document (e.g. pdf). If you pass the Body parameter on a message with one of these media types, the body will be ignored and not delivered to the device.

You can get further information on supported media files and limitations here:

https://support.twilio.com/hc/en-us/articles/360017961894-Sending-and-Receiving-Media-with-WhatsApp-Messaging-on-Twilio

Rules and Best Practices for WhatsApp Messaging on Twilio

https://www.twilio.com/docs/whatsapp/guidance-whatsapp-media-messages

https://www.twilio.com/docs/autopilot/channels/whatsapp

Message Scheduling

Twilio first introduced Message Scheduling on August 24, 2022. Support for Message Scheduling was added in v1.18 of fmMMS. You will first need to create a Messaging Service and copy the Twilio MessagingServiceSid into the Custom Text 3 field in the Accounts Screen. For more information on using Messaging Services visit:

You can get more information on the limitations and use of Message Scheduling here:

Incoming Messages/Replies

You can get incoming messages/replies to your Twilio number into the fmMMS file in a number ways:

  • Manually Download Incoming Messages
  • Use Webhooks to have Twilio push these automatically to fmMMS
  • Use Otto Webhooks

Using Webhooks is the preferred method as it saves you from having to poll/check for any new messages - with Webhooks new messages are forwarded to fmMMS automatically by Twilio as they are received.

Manual Download Incoming Messages

You can download incoming messages manually via the Account Details screen. Simply enter the date range you wish to download messages between and click the Get Incoming Messages button:

Any incoming messages to your Twilio number that have not been previously downloaded will then be downloaded, including any media attachments. You could also setup a FileMaker Server script schedule to have this run on a scheduled basis (e.g.every hour) to save you from having to manually download/check for new messages.

Twilio Webhooks Setup

To receive incoming MMS messages to your Twilio number from WhatsApp users, including replies to previously sent messages, you will need to use the supplied WebhooksIncomingMessages.php webhook file to act as the webhook receiver. See our Webhooks guide for what you need to do host the WebhooksIncomingMessages.php file on your chosen web server. Once you have the publicly accessible URL for this file you can enter this into your Twilio WhatsApp settings as follows:

  1. we recommend testing this out using the Twilio WhatsApp Sandbox first
  2. go to the Twilio Sandbox for WhatsApp configuration page here: https://www.twilio.com/console/sms/whatsapp/sandbox
  3. under Sandbox Configuration in the WHEN A MESSAGE COMES IN enter the URL in the adjacent field
  4. set the HTTP method to POST.
  5. click Save

It should look similar to this screenshot:

Twilio Otto Webhooks Setup

Please visit the Webhooks using Otto guide for instructions on setting up Otto Webhooks for your Twilio number.

Still need help? Contact Us Contact Us