Coder Social home page Coder Social logo

wabot-django's Introduction

Webhook for WhatsApp automation

A webhook in Python Django framework for WhatsApp automation. This project is developed using WhatsApp Cloud API.


Prerequisite

  • Python3
  • Django
  • JSON

Installation

Setup firebase

  1. Create new project in firebase
  2. Setup realtime database
  3. Navigate to Project Settings > Service Accounts > Firebase Admin SDK
  4. Select Python Language then generate new private key, This will download json file.
  5. Now copy the content of this JSON file and paste it in webhook/firebase.py (Line 10-21).
  6. Then copy the database URL from Realtime Database Firebase Console and paste it in webhook/firebase.py (Line 8).

Project Setup

  1. Clone this repository to your workspace
git clone https://github.com/parth-p-7span/wabot-django.git
  1. Navigate to wabot-django directory in your terminal
cd wabot-django
  1. Install required packages using below command
pip install -r requirements.txt
  1. Add your database in wabot/settings.py file
  2. Migrate database with following commands
python manage.py makemigrations
python manage.py migrate
  1. Run the project using below command
python manage.py runserver

Webhook Setup

  1. Deploy the project in any platform and obtain endpoint URL.
  2. Configure webhook in Meta developer portal. ( Please read this before proceeding ahead)
  3. Verify Token is given in the wabot/settings.py file with name WA_VERIFY_TOKEN

Important Files

  • webhook/actions.json : A JSON file that holds all the actions needed to perform by the bot.
  • webhook/firebase.py : A Python file for connecting app to firebase and performing actions.
  • webhook/func.py : A Python file for performing whatsapp actions like send message, mark as read message, and send input validation error message.
  • webhook/input_validator.py : This file contains all the functions for validating input messages.

actions.json structure

  • The primary key of object contains the order of message that has to be sent via BOT.
  • next key has the data of next message after performing one action.
  • type key has the data type of Bot's message
  • user_input key has boolean value. If it is true, the bot will wait for the user to send a message before sending the subsequent message; otherwise, the bot will keep sending subsequent messages.
  • expected key has the expected type of user's message. A validation error is sent if the user submits a message with the incorrect message type.
  • child key has the data of the message body as per Whatsapp Cloud API.

wabot-django's People

Contributors

parth-p-7span 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.