Code Monkey home page Code Monkey logo

live-traffic-whatsapp-chatbot's Introduction

Live Traffic Chatbot Using WhatsApp

Live Traffic Update

This is a simple chatbot that gives a live update about a user's location. Not only that, it provides a map's link to see where exactly the live update information applies.

Features

  • Appropriate feedback if the chatbot does not understand what the user says
  • Live update about traffic
  • Link to an interactive map

Tools

Deployed Application

Contributors

Testing This Application Locally

This is a mobile-based chatbot. You cannot find the chatbot on the deployed link. To test it out, you will need these:

  • A smartphone
  • An active phone number
  • WhatsApp mobile application installed in your smartphone
  • Twilio Account

Twilio provides a WhatsApp Sandbox that allows you to easily develop and test your application. To get started:

Try WhatsApp

You will see the Sandbox phonenumber assigned to you. There is also a code beginning with join- followed by two random words. You will need to send this code as a WhatsApp message to the number assigned to you to enable WhatsApp Sandbox.

  • Clone this project:
$ git clone git@github.com:GitauHarrison/live-traffic-whatsapp-chatbot.git
  • Move into the clone folder:
$ cd live-traffic-whatsapp-chatbot
  • Activate your virtual environment:
$ mkvirtualenv live_whatsapp_chatbot
  • Install all project requirements within your activate virtual environment:
(live_whatsapp_chatbot)$ pip3 install -r requirements.txt
  • Before you can run this application, you will need to create a .env file in the top-level directory following the example seen in the .env-template:
(live_whatsapp_chatbot)$ touch .env
  • Create a developer account with from TomTom API here. This will grant you 2500 free API calls per day.

  • You can create your API Key which you will later see in your dashboard

TomTom API Key

  • Add this key to your .env file:
TOMTOM_API_KEY='<your-TomTom_API-Key>'
  • Run the application:
(live_whatsapp_chatbot)$ flask run

You can access your localhost on http://127.0.0.1:5000/ as seen in the terminal. Additionally, if you look carefully in your terminal, you will see * Tunnel URL: NgrokTunnel: "https://4209c9af6d43.ngrok.io" -> "http://localhost:5000". This is the free public URL that ngrok has assigned you; giving access to your locally hosted application.

Alternatively, you can open another window in your terminal and run:

(live_whatsapp_chatbot)$ ngrok http 5000

Check out on the lines beginning with "Forwarding". You will use the https:// URL to allow for access to your locally hosted application.

Twilio Sandbox

  • In the box that says "WHEN A MESSAGE COMES IN", paste that ngrok URL. Remember to append /bot to your URL because this is the webhook that Twilio needs to know.

  • Click the Save button

Go back to your WhatsApp application on your phone. Ensure you have added your Sandbox number to your contact list. Then send a message to it as seen in the gif image at the top of this page.

Alternatively, if you do not want to use the free ngrok URL, which keep changing and is short-lived, you can deploy your application to Heroku. Paste your Heroku URL in the "WHEN A MESSAGE COMES IN" box. Test out the application in your WhatsApp.

Reference

  • If you are new to flask, I recommend that you begin from here
  • If you do not know what virtualenvwrapper is or you do not know how to use it, check this guide
  • It you would like to create your own live traffic chatbot, you can learn how to do it here

live-traffic-whatsapp-chatbot's People

Contributors

gitauharrison avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.