Skip to content

vihugoos/whatsapp-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Liber WhatsApp Bot

A whatsapp bot for Liber company, developed with Node.js
Explore Node.js docs »

Report Bug  •  Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Bot Documentation
  4. Infrastructure Liber
  5. Grafana Dashboard
  6. Contributing
  7. Contact

About The Project

Untitled.mp4

A bot for whatsapp to perform an automatic pre-service to the customer, registration of new customers, opening and assigning solicitations to Liber employees. Integration with Discord through Webhooks, to notify in real time when there are new customer solicitation and mark the responsible person, in addition to notifying new non-customer contacts and identify when a solicitation was closed to send in the closed solicitations channel, along with the service protocol.

Built With

Icon-Nodejs   Icon-whatsapp-web.js   Icon-Axios   Icon-Prisma   Icon-PostgreSQL   Icon-Docker


Getting Started

To get started, you need to have Node.js 18+ installed on your machine, for more information visit Node.js Downloads. You will also need to have Docker installed, for more information visit Docker Engine Install.

Obs: This guide will only serve to run the project locally (development environment), initially based on linux systems.

Prerequisites

Other than Node.js and Docker installed, you also need to have Google Chrome installed, because the library for automating whatsapp uses puppeteer to launch and control the browser, for more information visit Google Chrome Download.

Installation

  1. Clone the repo
    git clone https://github.com/vihugoos/whatsapp-bot.git
  2. Inside the project root directory install all project dependencies
    npm install
  3. Create an .env file with environment variables
    cat > .env << EOF
    DATABASE_URL="postgresql://postgres:docker@localhost:5432/liber?schema=public"
    
    DISCORD_WEBHOOK_URL_OPEN_SOLICITATIONS=yourDiscordChannelWebhookURL
    
    DISCORD_WEBHOOK_URL_CLOSED_SOLICITATIONS=yourDiscordChannelWebhookURL
    
    DISCORD_WEBHOOK_URL_NON_CUSTOMERS=yourDiscordChannelWebhookURL
    EOF
  4. Create a postgres container docker
    docker run --name liber -e POSTGRES_DB=liber -e POSTGRES_PASSWORD=docker -p 5432:5432 -d postgres 
  5. Run the migrate
    npx prisma migrate dev

Usage

With the installation complete, we can start the project.

  • Starting the project
    npm run dev  

Bot Documentation

Standard Flows

  1. Selecting "Não sou cliente", the bot sends this case to our commercial representative, who will later be able to release the registration if the payment is approved.

  2. If the registration is released, the bot will request all the necessary data and will register automatically (also already validating if the data entered are correct).

  3. Customer sends any message, the bot identifies him by cell phone number and sends service options immediately.

  4. The customer has changed his number and selects the option "Já sou cliente", the CPF is requested for confirmation and the registration is automatically updated.

  5. Selecting "Já sou cliente", but the CPF was not found in the database, the case is sent for assistance and further analysis.


Flags

  • "atendimento finalizado": If any Liber attendant sends a message that has these two words included, the bot ends the service.

  • "prosseguimento no seu cadastro": If our sales representative sends a message that includes this phrase, the bot will take over from here and automatically proceed with the registration of the new customer.

  • "em que posso ajudar": If an attendant/commercial representative sends a message that has this phrase included, the bot puts the customer in a state of assistance immediately and stops responding to any message.


Satisfaction Surveys:

Satisfaction surveys are only sent to users who have actually placed an order with us (in fact, our customers).


Viewing Messages:

The robot only sees messages from customers who are not being attended to, if so, it stops viewing them.


About Database:

Customers: All customer data is stored, namely: name, CPF, ID, email and cell phone number.

Solicitations: The data of all solicitations are generated automatically and stored in the database, namely: Service protocol, customer ID, which service is requested, status (open or closed), solicitation opening date, date on which the service was completed and the answer to the customer satisfaction survey.

Attendants: The following data of our attendants are saved in the database: name, discord username, discord ID and status (whether they are currently in attendance or not).


Infrastructure Liber

Logo

URL of each app:

Note: All of the above services were done by me.

Website Liber: https://libermedicos.com/

Dashboard (Operational Monitoring): https://grafana.libermedicos.com/

Prisma platform (Data Manipulation): https://cloud.prisma.io/


Grafana Dashboard

Logo

A dashboard created in Grafana to view all information about requests. Total number of customers, total solicitations, open and closed solicitations, average service time, etc. There is a tab for customer information and another for non-customers. In fact, a complete dashboard in which it is possible to carry out all the company's operational follow-up.


Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Contact

Developer @vihugoos - victorhugoos@live.com

🠕 back to top

Releases

No releases published

Packages

No packages published