Chat on WhatsApp with an AI
Server: Node.JS, Express
Database: Redis
API: WhatsApp Business Cloud API, OpenAI GPT-3
Deployment: Docker, Nginx, Linode
Misc: ElasticSearch, Kibana
whatsapp-connector: Whatsapp connector is a microservice which connects a bot to WhatsApp API, handles messaging and incoming requests from WhatsApp
chatbot: Chatbot is a microservice which will connect to OpenAI GPT-3 model to answer user queries based on prompt
Multiple prerequisites and configuration needs to be done on the Meta Developers, please follow my below guide for details: https://blog.amitwani.dev/create-a-chatbot-using-whatsapp-cloud-api
-
-
Update Environment Variables
- Fill necessary values in
docker-compose-local.yml
file insidedocker
folder for below environment variables:VERIFY_TOKEN
- Verify Token for WhatsApp WebhookOPENAI_API_KEY
- OpenAI API KeyWHATSAPP_TOKEN
- WhatsApp Business Permanent/Temporary Authentication Token withwhatsapp_business_messaging
permissionWHATSAPP_SEND_MESSAGE_API
- WhatsApp Cloud API Send Message API End Point with Phone Number IDCHATBOT_URL
- Chatbot microservice api url
- Fill necessary values in
-
Run command
docker-compose -f docker-compose.local.yml up -d
insidedocker
folder
-
-
- Install Dependencies
Navigate to
whatsapp-connector
andchatbot
to install their dependecies.npm install
or
yarn add
-
Update Environment Variables
- Create
.env
file by copying.env.sample
in both microservices - Fill necessary values for below environment variables:
VERIFY_TOKEN
- Verify Token for WhatsApp WebhookOPENAI_API_KEY
- OpenAI API KeyWHATSAPP_TOKEN
- WhatsApp Business Permanent/Temporary Authentication Token withwhatsapp_business_messaging
permissionWHATSAPP_SEND_MESSAGE_API
- WhatsApp Cloud API Send Message API End Point with Phone Number IDCHATBOT_URL
- Chatbot microservice api url
- Create
-
Run the Server
npm run start
Deploy with Docker easily using the Dockerfile
provided in the respective services folder or the docker-compose.yml
in the docker
folder
GitHub Actions is used to create a CI/CD workflow specified in the workflow.yml
.
- On every commit on
main
branch - Build Docker Images of both microservices
- Push Docker Images of both microservices to docker repository
- Update
docker-compose.yml
by replacing environment varibles from GitHub secrets - Copying
docker-compose.yml
andnginx.conf
to the server - Running
docker-compose
command to recreate containers - Deployment is done
If you have any feedback, please reach out to me at [email protected]