A whatsapp bot for Liber company, developed with Node.js
Explore Node.js docs »
Report Bug •
Request Feature
Table of Contents
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.
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.
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.
- Clone the repo
git clone https://github.com/vihugoos/whatsapp-bot.git
- Inside the project root directory install all project dependencies
npm install
- Create an
.env
file with environment variablescat > .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
- Create a postgres container docker
docker run --name liber -e POSTGRES_DB=liber -e POSTGRES_PASSWORD=docker -p 5432:5432 -d postgres
- Run the migrate
npx prisma migrate dev
With the installation complete, we can start the project.
- Starting the project
npm run dev
-
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.
-
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).
-
Customer sends any message, the bot identifies him by cell phone number and sends service options immediately.
-
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.
-
Selecting "Já sou cliente", but the CPF was not found in the database, the case is sent for assistance and further analysis.
-
"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 are only sent to users who have actually placed an order with us (in fact, our customers).
The robot only sees messages from customers who are not being attended to, if so, it stops viewing them.
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).
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/
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.
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!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Developer @vihugoos - victorhugoos@live.com