Twilio SMS – Formidable Forms

Twilio Api Credentials
  • Description
  • FAQ
  • Screenshots
  • DEMO
  • Updates & Support

Use the Twilio add-on to send an SMS/text message when a form is submitted or when an entry is updated. You may also allow users to text in their votes for a poll or survey created by Formidable Forms. Each received text message will automatically create a new entry in your form. Please note, you must have a Twilio account in order to use the Twilio add-on.

Download and Install

  1. If you haven’t already done so, install and activate Formidable Forms Pro.
  2. In your WordPress admin, go to Formidable → Add-Ons and click the Install button for the Twilio SMS plugin for WordPress.

Set up the Twilio SMS forms

  1. Log in to your Twilio account and go to the Settings → General page.
  2. In the API Credentials section, copy your Twilio Account SID and Auth Token. If you are using a trial account, you must verify the number you are sending to.
  3. Go back to your Formidable → Global Settings → Twilio page and insert your Twilio Account SID and Auth Token.
    Twilio Global Settings

Phone Formatting

When setting up your Phone Number field format, Twilio recommends using E.164 number formatting for all To and From phone numbers to ensure deliverability. Learn more about Twilio Phone Number formatting.

The E.164 formatted phone numbers can be written as:

[+][country code][area code][subscriber number]

For example, this is the recommended format for a US phone number.

+14188884567

Send text message on form submission

You may send an SMS text message as an autoresponder when a Formidable form is submitted or when an entry is updated. Please follow the directions below to set this up.

  1. Create a form that will be used to send text messages. Include a Phone Number field in your form if you would like to send the message to the user filling out the form.
  2. Go to your form Settings → Actions & Notifications tab. Click on Twilio to add a Twilio action to your form.
    Twilio New Action
  3. Give your Twilio form action an Action Name for easy reference. This action name will only be seen on the back-end.
    Twilio Label
  4. Select one or more actions in the Trigger this action when dropdown.
    Twilio Trigger Action After
    Different triggers will be visible depending on which add-ons are active. The User Registration add-on adds an option to send a text after a user successfully registers. The PayPal and Stripe forms add-ons add an option to send a text when a payment is completed.
  5. Insert a phone number or your Phone Number field ID in the To box. You may insert multiple phone numbers, separated by a comma. A separate text will be sent to each phone number.
    Twilio To Box
  6. In the From box, you have the following options: Twilio From Number
    • All numbers in the linked Twilio account. Choose one of these for live sending. These numbers are cached in the dropdown for 15 minutes. If you need it cleared sooner, choose the number linked from the Twilio account.
    • The Twilio Test number. A test number can only send to another test number.
    • Use a different Twilio phone number. Don’t add a custom number unless you know what you’re doing. Be sure to include the international code.
  7. Use the [default-message] shortcode in the Message box when sending in an SMS message. This will send a message like: Sent from your Twilio account. Your responses were successfully submitted. Thank you! Twilio Default Message Box
    If you want to customize your own message, enter the message that you would like to send in the Message. Click on fields in the Customization panel to add field values from the entry into your message. Twilio Message Box
  8. If you would like to conditionally send a text message, you will need to add Conditional Logic. You may choose to send a text message only when a user agrees to receive text messages, for example. Please note that Conditional Logic is only available in the Pro version of Formidable Forms.
    Twilio Conditional Logic
  9. Click Update. Now when a user submits or updates an entry, a text message will be sent to the specified recipient.

Please note that you must configure the Global Twilio settings in order for this to work correctly.

Set up two separate countries

  1. Set up your form to send Twilio SMS.
  2. Add a Radio button or Dropdown field in your form with options for the user to select where they are located, with options like the United States and Australia.
    Twilio Sms Separate Countries
  3. Add a phone number field for the United States number format, then add conditional logic to show this field only if the United States is selected in the field.
    Twilio Sms United States
  4. Add another phone number field for the Australia number format, then add conditional logic to show this field only if Australia is selected in the field.
    Twilio Sms Australia
  5. Add a hidden field, and enable text calculations. Insert [x][y] in this field where x is the field ID of the United States phone number field and y is the phone number field ID of the Australia phone number field.
    Twilio Sms Hidden Field
  6. In your Twilio action, insert the hidden field ID in the To box.
    Twilio Sms Email To
  7. Follow steps 6-9 here to complete your setup.

Set up text voting

Use Twilio to allow users to text responses to a poll or survey. The responses will be stored in your form’s entries.

  1. Create a poll or survey with Formidable Forms. This form can have only one survey question. We recommend including a text field as well, to act as a catch-all for invalid votes.
  2. Log into your Twilio account and go the the Phone Numbers page.
  3. Find the phone number you’ll be using to accept text votes.
    • Click on that phone number so you can ‘Configure’ it.
      Twilio Edit Number
    • Change the Messaging URL to
      your-site-url/wp-admin/admin-ajax.php?action=frm_twilio_vote&form=5

      Replace your-site-url with your own site’s URL. Change 5 to the ID of your form.
      Twilio_Messaging_Url

  4. Now when the user texts their vote to your Twilio phone number, the text message content will be saved to your poll or survey form’s entries. Your users can either text the number position of the choice in your form, or the word itself. For example, if I have a poll for favorite colors and my choices are Red, Green, Pink, and Blue, and my favorite color is pink then I can text any of the following:

Send texts to a phone number list

If you would like to send texts to a list of phone numbers that have been entered in a Formidable form, follow the steps below.

  1. Create a view that is connected to the form where phone numbers are stored. We’ll call this the Numbers View. The View will need to be set up to display All Entries.
  2. In the Content box insert the following code;
    [x],

    Replace ‘x’ with the ID of your phone number field. Click Update.

  3. Create a new form, this is the form that will be used to send out messages, call this your Send SMS Form form. Add any fields you would like to use and click Update
  4. Follow the steps here to create your Twilio action.
  5. In the To box, insert the shortcode for the Numbers View.
    [display-frm-data id=x]

    Replace ‘x’ with the ID of the Numbers View.
    Twilio Group To Box

  6. In the Message box, insert the message you would like to send upon submission. Use the customization panel to insert field values. Click Update
  7. Publish your Send SMS Form on a page. It is recommend to change the Visibility to Private or Password Protected so only specific users can send texts to the Phone Number list.
    Twilio Private Publish
    Click Update.
  8. Now when you fill out the Send SMS Form form and hit submit, it will send out the message to all the phone numbers saved in the Numbers Form.

Filtering phone number list

If you would like to send text messages to a filtered phone number list, using a parameter is useful. For this example, you can send text messages to users that have more than a certain number of points in their account.

  1. Before proceeding, you will first need to create the Numbers View.
  2. Go to edit your View.
  3. Scroll down to the Advanced Settings. In the Sort & Filter section click the + Add button next to Filter Entries. Set up the filter so it says “Points is greater than [get param=points]”
    Twilio Filtered Numbers View
  4. Click Update to save your View.
  5. When inserting the View shortcode, add a param with the value from the field.
    [display-frm-data id=62 points="[100]"]

    The value in field 100 will be sent to the View and used in the filter. Swap out 62 for the ID or key of your View.

Undo phone formatting

When a phone number is prepared in this plugin, it is forced to be numeric. But if you are using a Twilio alphanumeric phone number, you will need to reverse this automatic formatting.

add_filter( 'frmtwlo_format_number', 'format_twilio_num', 10, 2 );
function format_twilio_num( $num, $args ) {
  return $args['original'];
}

Save phone number in a field

By default, the phone number is stored as the IP address for Twilio submissions. This example copies the value into another field.

add_filter( 'frm_validate_field_entry', 'copy_twilio_phone_number', 10, 3 );
function copy_twilio_phone_number( $errors, $posted_field, $posted_value ){
  if ( $posted_field->id == 25 && isset( $_POST['ip'] ) ) { //change 25 to the ID of the phone field
    $_POST['item_meta'][$posted_field->id] = $_POST['ip'];
  }
  return $errors;
}

Troubleshooting

No SMS message received

  1. Are you using a Twilio trial account? If so, did you verify the number you are sending to?
  2. Does the From number in your form settings match the number in your Twilio account? You must send from a Twilio number.
  3. If you are outside the USA, you must include an international code on the phone numbers. If these are missing, the USA code is used.
  4. SMS messages will not send if you are using test API credentials. The live credentials are required.

Twilio alphanumeric sender

At this time, sending from an alphanumeric id is not supported. Unfortunately, Twilio does not support this feature in the USA, so our developers are not able to test or support it.

Error messages

Sorry, there was an error saving your vote.
This message is shown in two cases.

  1. The form ID in your Twilio API URL isn’t a valid form id.
  2. Your form is set to only allow logged in users to submit.

Sorry, you can only vote once.
This message is returned when your form is limited to one response per user, and this phone number already has a submission in this form.

or
Shopping Cart
  • Your cart is empty.
Scroll to Top