Coder Social home page Coder Social logo

sup3r-us3r / zap-bot Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 2.09 MB

This application was made in Node.js + TypeScript, it is a BOT for WhatsApp, which communicates with the official WhatsApp Business API, it simulates a barbershop scheduling flow using mocked data

License: MIT License

TypeScript 100.00%
bot nodejs typescript whatsapp whatsapp-business-api zap-bot whatsapp-bot chatbot

zap-bot's Introduction

Zap Bot

This application was made in Node.js + TypeScript, it is a Bot for WhatsApp, which communicates with the official WhatsApp Business API, it simulates a barbershop scheduling flow using mocked data.

Technologies

Project Architecture

project-architecture-overview

Preview

zap-bot.mp4
Facebook Developers Setup

Follow the steps below to configure your application on Facebook Developers.

Go to Facebook Developers here: link

Step 1

Access My Apps page

facebook-developers-step-1

Step 2

Create a new app

facebook-developers-step-2

Step 3

Select what the app does

facebook-developers-step-3

Step 4

Select app type

facebook-developers-step-4

Step 5

Add app info

facebook-developers-step-5

Step 6

Setup WhatsApp

facebook-developers-step-6 facebook-developers-step-7

Step 7

WhatsApp API Setup

facebook-developers-step-8

This step is important, you must copy the Temporary access token and paste it into the .env file in the GRAPH_API_TOKEN variable, the API Setup documentation will cover environment variables.

You need to select the test number that WhatsApp will generate for you, and you also need to enter your real cell phone number. After that, you must click on Send message to have a test message sent on your WhatsApp.

Step 8

WhatsApp configuration

facebook-developers-step-9

This step is also very important, in it we need to inform the Callback URL and the Verify token, this URL will be used for WhatsApp to verify our Webhook.

  • Callback URL: It is the https URL that will be generated by Ngrok, and /webhook is the API endpoint with GET method that will be used to verify the Webhook.
  • Verify token: It is the name of your app

You will only be able to complete this step after setting up the API, so access the documentation below to run the API and make all the necessary settings, and return to this step when finished.

facebook-developers-step-10

In this step we need to select the messages event, this means that when the user sends us a message, WhatsApp will notify us by calling the /webhook endpoint with the POST method.

Execute application

Setup API

Install dependencies

$ npm i

Create your .env

$ cp .env.example .env

Change these variables to their appropriate value and save the file:

WEBHOOK_VERIFY_TOKEN="App name"
GRAPH_API_TOKEN="Temporary access token"

Install Ngrok

As we are going to run the project in development mode, we need to use Ngrok to be able to generate an HTTPS link that will expose our local server to the internet, it would be as if our API were published in production, it's just a way to get around this problem, Therefore, the WhatsApp platform will be able to interact with our API locally without having to actually publish it.

It's very simple, you just need to create an account and install Ngrok, it's free.

Execute API Server

Start PostgreSQL

$ docker-compose up -d

Run migration

$ npx prisma migrate dev

Run API

$ npm run dev

Run Ngrok

$ ngrok http 8080

After running the above command, Ngrok will generate an HTTPS URL for you to use. This URL can access the API that is running locally externally.

facebook-developers-step-9-1

8080 is the server port, if you change this port number you will need to run ngrok with this changed port.

zap-bot's People

Contributors

sup3r-us3r avatar

Stargazers

Mayderson Mello avatar  avatar Gustavo Henrique avatar

Watchers

 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.