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
docker-compose
Update Environment Variables
docker-compose-local.yml
file inside docker
folder for below environment variables:
VERIFY_TOKEN
- Verify Token for WhatsApp WebhookOPENAI_API_KEY
- OpenAI API KeyWHATSAPP_TOKEN
- WhatsApp Business Permanent/Temporary Authentication Token with whatsapp_business_messaging
permissionWHATSAPP_SEND_MESSAGE_API
- WhatsApp Cloud API Send Message API End Point with Phone Number IDCHATBOT_URL
- Chatbot microservice api urlRun command docker-compose -f docker-compose.local.yml up -d
inside docker
folder
npm
Navigate to whatsapp-connector
and chatbot
to install their dependecies.
npm install
or
yarn add
Update Environment Variables
.env
file by copying .env.sample
in both microservicesVERIFY_TOKEN
- Verify Token for WhatsApp WebhookOPENAI_API_KEY
- OpenAI API KeyWHATSAPP_TOKEN
- WhatsApp Business Permanent/Temporary Authentication Token with whatsapp_business_messaging
permissionWHATSAPP_SEND_MESSAGE_API
- WhatsApp Cloud API Send Message API End Point with Phone Number IDCHATBOT_URL
- Chatbot microservice api urlRun 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
.
main
branchdocker-compose.yml
by replacing environment varibles from GitHub secretsdocker-compose.yml
and nginx.conf
to the serverdocker-compose
command to recreate containersIf you have any feedback, please reach out to me at [email protected]