Table of Contents

How to send the SMS with verification code using Pipedream

Alexander Gao Updated by Alexander Gao

Introduction

In some occasions we want to verify whether the user is operating by himself. Here we introduce an approach of sending verification code by SMS. Then ask the user to type in the code for verifying.

To do that, Pipedream can help you to accomplish the flow, we just need to send some necessary datas collected from Landbot, and within Pipedream we set the actions of Twilio with the datas.

To do this in the article we will show you how to:

  • 1. Set up in Pipedream the trigger to receive the datas from Landbot
  • 2. Create some blocks in Landbot to prepare the datas to be sent
  • 3. Prepare the Automation trigger in Landbot that will trigger Pipedream workflow with the information needed
  • 4. Set up the blocks to verify the user
  • 5. Set up the Twilio account and connect it with Pipedream
  • 5. Use the datas collected from Landbot and insert them to the action of Twilio

Below is an example of the flow:

  • a. Ask for the phone number
  • b. Set timestamp as a variable
  • c. Using slice to get the last 5 numbers of timestamp and save it as the verification code
  • d. Leave a message for the users to check the message
  • e. Ask the user to type in the code
  • f. Verify it the code is matched
  • g. Leave messages for the user depends on the code is matched or not (if not, it's recommendable to connect the message with the Question: Phone block or set buttons to ask if they want to reverify or quit)

Pipedream Trigger with Trigger automation block

Prepare Landbot
  1. Firstly, we have to set a Question: Phone block to ask the phone number:
When we are asking the phone number, remember to remind the user to type in the zone code, for example, the Spanish phone number should be like: 34XXXXXXXXX

The information that we collect, will be stored in variables, that we will send to Pipedream. As in the example below, we are storing the name input in the variable @name, that we will use later

  1. Then let's set variable block.

  1. Inside of the variable, for example, let's name the variable as @code, and the value should be ${timestamp}

  1. Create a Formulas block:

  1. Name the result as @verification_code, then type in Slice(ToString(@code),-5)
-5 means we slice the last 5 numbers of timestamp, which makes the code dynamic

  1. Create a Trigger automation block:

  1. Then create a message block to notify the user, so they can check the phone:

  1. Create a Question: Number, to ask for the code:
Remember to save the answer as variable, so we can use it in Conditions block

  1. Then create a Conditions block, with IF @user_verification_code equals to @verification_code:

  1. At the end of the flow, let's leave 2 different messages for the users. From the green output, which means the code is correct, we can say like Congratulations, you are successfully verified. From the red output, which means the code is incorrect, so we can say like Sorry, the code is not correct, please try again.
If the code is not right, it's optional set a button for them to choose if the want to do the verification again:

Create Pipedream workflow
  1. After set a Trigger automation block, let's open Pipedream, and log in:

  1. Then click on the button of New+ at upper right corner:

  1. It shows this page:

  1. Then below Select a trigger we select HTTP/Webhook:
  1. After that, choose New Requests:
  1. It displays this page:
  1. Then click on the button Create Source:
  1. It displays this page:

  1. Copy the URL below:

Prepare Landbot request to Pipedream
  1. During the time it waits for the datas, let's open Landbot, then paste the URL to Trigger automation block:

  1. Now we are going to set the variables we want to send to Pipedream, scroll down and go to Set data (variables) to be sent section, where you can see we are setting values to the Landbot variables:
  1. And click on Test webhook trigger button:
  1. If you scroll down, you will see the response from Pipedream:

  1. As long as the status code is 200, means our request is successfully sent.

Inside of Pipedream check request data
  1. Now we turn back to Pipedream:

Now we have seen behind bodyRaw there is a code with the information we sent. Means Pipedream has received our variables.

Yes, the @name, @email, and @age are the same as we sent to Pipedream: This is how the trigger works, we send variables to Pipedream, they receive, and when we try to test it as we did in step 22, it will be shown.

Set the action of Twilio

Create Twilio action
  1. Let's click on the plus button, and search for Twilio, select Send SMS:

  1. Click on Select an account, then click Connect Twilio:

Get a trial number, Sid, Secret and AccountSid for the connection
  1. In the dashboard of Twilio let's click on Get a trial number:

  1. Then go to Programmable Message, then find Messaging Servicies, to create a Message service. Then name it and select the use case:
  1. Then go to Sender Pool, add sender for the service, with our trial number:

  1. Then go to Dashboard, copy the AccountSid, paste it to Pipedream:

  1. For the Sid and Secret, go to Settings, API Keys. Create an API key. In the type we have to choose main, then name it. Soon we will find the Sid and secret:

  1. Copy the Sid and secret and paste them to Pipedream:

  1. Name the connection and save:

Set up the rest of action
  1. Below From, select our trial number:

  1. Below To, we put + first, then we search for the number we collect from Landbot, event > body > phone, click on select path:

  1. For the body we put a sentence with our verification code, to find the verification code, we have to go to event > body > verification_code:

  1. Click on SAVE then DEPLOY:
  1. Remember to turn on the API trigger:

Also please pay attention here, if you are in a free trial, you only can test the flow with the registered number(the one used to register the Twilio account), if not, in Pipedream will appear this error:

Test the flow in Landbot

  1. Let's go to Share > Share with a link > OPEN:

  1. Complete the flow:

As you can see, after we confirmed the phone number, we received a message from Twilio, with the verification code:

The number is exactly the same with the one we typed in Landbot chat, so the flow is successfully completed!

How did we do?

Pipedream trigger

Contact