Skip to content

elizabethsiegle/superposition_bot_workshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Superposition AI/ML Chatbot Building Workshop

On 6/6/2020, we made a bot that tells you what programming language you are. This README has instructions on getting started with your bot and where to put the JSON and JS code in this repo, as well as some Resources at the bottom.

You'll need

Make an Autopilot bot and configure a phone number

Go to your Autopilot console and under Create a Bot select Start from Scratch. start from scratch

Give your bot a title like what-programming-language-are-you and click Create bot.

Select Channels from the left-hand menu and then click Programmable Messaging. prog messaging

Copy that Messaging URL and in a new tab configure your Twilio number in your phone number console. prog messaging url

You can also do the same for programmable voice so your bot is a phone call bot.

If you don't have a Twilio number yet, go to the Phone Numbers section of your Twilio Console and search for a phone number in your country and region, making sure the SMS checkbox is ticked. phone #s

In the Messaging section of your purchased number, in the A Message Comes In section, set the Webhook to be your Messaging URL and hit Save. messaging configuration

Make a bot to ask questions

Make a task called main_questions. Add the code from bot.json into it. It asks a series of questions in a Collect Action and takes in those questions. Each question has a name and a Validate instruction to limit what the user can answer with. We use the Validate attribute allowed_values to provide an array of possible answers. If this was a quiz where there is only one right answer, it might only have one allowed value.

After the last question, the bot redirects (with a Redirect Action) to a Twilio Function (a serverless environment for Node.js apps) to tally up all the answers and calculate the all-important answer to "What Twilio Product are you?"

Calculate the Results with JavaScript in a Twilio Function

Make a new Function by clicking the red plus button in your Functions Console. Select a Blank template and click Create. make a blank function

Append /superpos to the path of your Function, then copy the path and paste it in your Autopilot bot JSON bin's on_complete: redirect: uri. Then add the JavaScript code in bot.js to get the memory of each of the fifteen answered questions and create an empty response object that will soon be filled.

What's next for your bot

You can add more questions, more answer choices, more emojis, or a more complex system of tallying up the answers. With people sheltering at home, now is a great time to create entertaining quizzes for personal or professional use. Twilio Autopilot makes it easy for you to get creative with chatbots and quizzes to engage with customers, fans, friends, and family, or just have fun. Let me know online or in the comments what you're building.

Resources