![]() Here is how it works:Ī) castVote(): It begins the voting process and also takes users vote. The first two functions are the actual voting while the last two are for showing results. The Fourth Section spans from Line 46–136 and consists of four functions which are in charge of actually accepting and validating users vote and showing the result to the user. The Third Section spans from Line 27–43 and only consists of one function, showCandidates, we simply use this to show our list of candidates once requested by the user. The Second Section spans from Line 7–25 is where we define our file variables and default values, like votes and candidates. ![]() Line 5, sees us introduce our utility module where we store our helper functions. Line 4 we imported our helper response module(this would help format our various responses). At Line 3, we installed the Twilio official NodeJs module which we would use to send back our response. The First Section spans from Line1–5 is where we install helpers files and methods into our application. To make the explanation easier I would be explaining section by section. I know this file looks quite a lot but with some explanation, you would see it's not that complex. We would then create a new file called index.js which would be used to set up our application server(with expressjs) If you didn't check the process you followed to make sure you didn't miss any step.įrom the installation, we have only a package.json file in our project. You should receive a response similar to the one below once you join. To begin using the Twilio WhatsApp Sandbox, we proceed to the WhatsApp section on the Twilio dashboard and send a message to the sandbox number provided usually, +14155238886 with the provided code, which is in the format join-: For this tutorial we would not involve ourselves in that process, we would rather leverage on a safe sandbox Twilio provides for development and testing purposes. ![]() However before we can start sending and receiving messages using the Twilio WhatsApp API in production, we must first get a WhatsApp Approved Twilio Number which will act as our WhatsApp number for sending and receiving messages. In other to give our chatbot access to the messages from WhatsApp, Twilio provides a very robust WhatsApp API that allows us to both send and receive WhatsApp messages right from within our application. Now that we have our environment set up, let's proceed to our Twilio sandbox to set things up. Twilio - The Twilio Library we would use to send messages Start by creating a directory, then cd into it and run this commandĮnter fullscreen mode Exit fullscreen mode To successfully follow through with this tutorial the following are required: Send free-form messages using the Twilio WhatsApp API Respond to WhatsApp messages sent to your Twilio WhatsApp numberĭevelop a Rest API based voting application In this tutorial, we would be embarking on a creativity journey by building a voting WhatsApp Chatbot with NodeJs using the Twilio Platform.Īfter successfully following this tutorial, you would have learned how to: Its use can only be limited by our creativity! It has been used in different contexts ranging from customer support, book tickets for movie/show, banking(UBA Leo) just to mention a few. In its mere definition, it is a software application used to conduct an online chat conversation via text or text-to-speech, in place of providing direct contact with a live human agent. Chatbots help us reduce our dependence on our manual ways of communication and also challenges our preconceived way of implementing solutions. With the rate of technological advancement taking place in this century, we are always finding new ways to automate our tasks and make our lives better. Build a WhatsApp Chatbot Voting Application Using NodeJs and Twilio
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |