Homepage

Creating an SMS Notification

Last edit: Jul 14, 2023

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

Note

If you want to send the SMS via GraphQL, please check the sms_send GraphQL Mutation.

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 and a user property phone_number. 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 two-step process:

Step 1: Create SMS Notification

app/smses/welcome_user.liquid

---
to: '{{ form.properties.phone_number }}'
---
Hello {{ form.first_name }} via sms.

This assumes that you have already created a Sign-Up Form and configured the phone_number property.

Please note, that the phone number should include a country code. 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 the correct input. For production, you might find [to_mobile_number][/api-reference/liquid/platformos-filters#to_mobile_number] useful.

Step 2: Add SMS Notification to the Sign-Up Form

Add the SMS Notification you created to the Sign-Up Form configuration.

The SMS notification name is a path of the file relative to the smses directory, without extension.

In our example the path to the file is app/smses/welcome_user.liquid and the bolded part is the name - welcome_user. As the result of adding:

sms_notifications:
  - welcome_user

to the Sign-Up Form, the content of forms/developer_sign_up.liquid in the configuration section should look as follows:

---
name: developer_sign_up
resource: User
resource_owner: anyone
fields:
  email:
  password:
  first_name:
    validation: { presence: true }
  properties:
    phone_number:
      validation:
        phone_number: true
  ...
sms_notifications:
  - welcome_user
---

Important

If the SMS does not arrive to your phone after a minute, please check logs using pos-cli logs . If you configured Form and SMS correctly, you will find there information about the issue. For example, the phone number might be in an invalid format (missing country code, for example) or if you develop on staging you might need to ensure that in your Partner Portal Instance configuration the enable_sms_and_api_workflow_alerts_on_staging flag is set to true .

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.

contact us