Bot Libre Forum Sign In : Sign Up

How to Connect your Bot to SMS Text Messaging

by mike2016 posted Jun 7 2016, 11:10

Through Bot Libre, you can now send and receive SMS messages with your own bot. You can use this to chat with your bot through SMS, but the possibilities are endless. You could also use it to perform surveys or marketing, send customer service escalations, or send notifications from social media or email. Any bot can be set up with SMS text messaging with an account on Twilio.com. This "How To" will give you a step by step process to connect your bot with Twilio to allow for SMS text messaging.

Step 1 - Create a Bot 

First you must create a bot that you want to connect to SMS Text Messaging, or you can use one of your existing bots. To create a bot, follow the instructions here: How to create your own chat bot in 10 clicks

Step 2 - Create a Twilio account

Click here to go the Twilio website. To create a trial account, click on the "+ Sign Up" link in the top right corner of the website.

Enter your information on the following form, then click the "Get Started" button.

You will then need to enter a phone number to receive a verification code.

Once you have received your verification code, enter it on the following screen and press "Submit" to complete your account creation.

Step 3 - Get a phone number from Twilio

From the menu on the left side of the Twilio website, select "Phone Numbers"

 

Click the "Get Started" button to begin. Next, click the "Get your first Twilio phone number".

A screen will pop up with a phone number that has been chosen for you. You can accept this phone number by clicking the "Choose this Number" button. If you want to try again for a different phone number, you can click the underlined "Search for a different number" link. Ensure the number you select has SMS capabilities.

Step 4 - Connect webhook

Navigate to your bot's page on the Bot Libre website. Go to its admin console by clicking on the gear icon.

Click the "SMS" link to view your bot's SMS settings. Copy the "Twilio Webhook URL" to your clipboard.

Now return to the Console on the Twilio website and select "Phone Numbers"

Next, select "Manage Numbers"

Select the phone number you created to edit its settings.

Scroll down to the "Messaging" section and select "Webhooks/TwiML" from the "Configure with" dropdown menu. Paste the Webhook URL from your bot's SMS admin page into the "A message comes in" Webhook field.

Your bot should now be able to reply to SMS messages sent to the phone number you set up on Twilio. Trial accounts on Trilio can only send messages to phone numbers you have verified in the phone numbers section of your account portal. To remove this restriction, you will need to upgrade your Twilio account.

Step 5 - Accessing SMS from a script

 To send SMS message's from a bot's script, you will need to enter your Twilio account's SID, Auth Token and phone number into your bot's SMS admin page. You can find your Twilio Account SID and Auth Token on your Account Dashboard on the Twilio site.

Return to your bot's SMS admin page and enter your Account SID into the Twilio SMS SID field, the Auth Token into the Twilio SMS Secret field and your Twilio phone number into the Twilio Phone Number field. Press "Save"

You will now be able to send SMS messages from your bot through scripts. The method for sending an SMS message from a Self script is Twilio.sms("+16131234567", message); The first parameter is the phone number the SMS message will be sent to. The second parameter is the message that will be sent to the number. For an example of how to do this, please look at the source for this script: https://www.botlibre.com/script?id=12864737

/** * This script lets users escalate their chat session by sending an SMS message to an operator cell phone number. * Ensure you reaplce the phone number with your own. * This requires your bot to be connected to SMS (from its Admin Console). */ state Escalate { pattern "escalate" template "Would you like to escalate this issue to a human operator?"; pattern "yes" that "Would you like to escalate this issue to a human operator?" template "Enter your email address?"; case input goto sentenceState for each #word of sentence; pattern "*" that "Enter your email address?" template "Invalid email address."; state sentenceState { case email that "Enter your email address?" answer sendSMS(); } var email { instantiation : #emailaddress; } function sendSMS() { message = speaker.name + " - " + conversation.input[-1] + " - " + conversation.input[-7]; // ** Make sure you change the phone number ** Twilio.sms("+16131234567", message); "I have escalated this issue, an operator should be in contact with you shortly."; } }

In summary, your bot should now be able to send and receive SMS messages. By creating a Self script, you will be able to create custom behaviour for sending SMS messages in response to chat messages sent to your bot. If you encountered any issues, or would like help setting up your bot please email us at support@botlibre.com or upgrade to our Platinum service and we can build your bot for you.


Id: 12896887
Tags: how to, mobile, scripting, sms
Posted: Jun 7 2016, 11:10
Updated: Nov 19 2019, 10:42
Replies: 0
Views: 21729, today: 1, week: 1, month: 5