This project contains a whatsapp bot and a whatsapp message automation application which is controlled by a admin panel. Whatsapp Message Automation application automates sending WhatsApp messages to phone numbers extracted from a Google Sheet using a service account for Google Sheets API and wweb.js for WhatsApp messaging. Whatsapp bot is a bot that responds to messages using the Google Generative AI. The bot can reply to specific keywords and use generative AI to handle other queries.
googleapis
: Google API client library for Node.js to interact with Google Sheets API.wwebjs
: WhatsApp Web JavaScript library for sending messages via WhatsApp.fs.promises
: Provides a promise-based API for file operations.path
: Provides utilities for working with file and directory paths.- @google/generative-ai: Google’s generative AI library for handling natural language processing tasks.
- dotenv: A module to load environment variables from a
.env
file.
-
Create a Google Cloud Project:
- Go to the Google Cloud Console.
- Create a new project.
-
Enable the Google Sheets API:
- Navigate to APIs & Services > Library.
- Search for "Google Sheets API" and enable it.
-
Create Service Account Credentials:
- Go to IAM & Admin > Service Accounts.
- Create a new service account.
- Download the JSON key file.
-
Share the Google Sheet:
- Open the Google Sheet you want to use.
- Share it with the service account email (found in your JSON key file) with "Viewer" or "Editor" access.
-
Install WhatsApp Web JavaScript Library:
- Install the
wwebjs
library using npm.
- Install the
-
Prepare Credentials:
- Place your Google Sheets API credentials JSON file in the root directory of your project and name it
credentials.json
- Place your Google Sheets API credentials JSON file in the root directory of your project and name it
-
Node.js: Make sure you have Node.js installed. You can download it from nodejs.org.
-
Google Generative AI API Key: Obtain an API key from Google and set it up in a
.env
file.API_KEY=your_google_api_key_here
-
WhatsApp Web Account: You’ll need a WhatsApp account and a QR code to authenticate with WhatsApp Web.
- Clone the Repository:
git clone https://github.com/AksaRose/whatsappMsgAuto.git