Creating an SMS Notification

Last edit: 

Contributors: 

This guide will help you create an SMS notification to send a text message to a newly signed up user using our Twilio integration.

Requirements

To follow the steps in this tutorial, you should understand the concept of notifications. You'll also use the sign up form you created in a previous tutorial. As you'll use our Twilio integration, you need to ensure that the to number is formatted according to Twilio's phone number format guideline.

Steps

Creating an SMS notification is a three-step process:

  1. Extend sign up form with mobile number
  2. Create SMS notification
  3. Add SMS notification to sign up form

Step 1: Extend sign up form with mobile number

As you haven't collected the mobile phone number in the sign up form yet, as a first step, extend the sign up form form_configurations/developer/sign_up.liquid:

---
fields:
  mobile_number:
    validation:
      presence: true
      phone_number: true
---

<label for="mobile_number">Mobile number</label>

<input name="{{ form_builder.fields.mobile_number.name }}"
  value="{{ form_builder.fields.mobile_number.value }}"
  id="mobile_number"
  type="text">

{% if form_builder.errors.mobile_number %}
  <p>{{ form_builder.errors.mobile_number }}</p>
{% endif %}

On the production site, you have to take into consideration that users might not know their country code, or what a country code is. For simplicity in this example though, assume that the user provides correct input.

Step 2: Create SMS notification

Create a notification file in notifications/sms_notifications/welcome_user.liquid:


---
name: welcome_user
to: '{{ form.mobile_number }}'
delay: 0
enabled: true
trigger_condition: true
---
Hello {{ form.first_name }} via sms.

Step 3: Add SMS notification to sign up form

Add the SMS notification you created to the sign up form:

---
sms_notifications:
  - welcome_user
---

Next steps

Congratulations! You have created an SMS notification. Now you can learn about creating an API call notification.

Questions?

We are always happy to help with any questions you may have. Check out our Help page, or contact us.