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.ymlfile insidedockerfolder 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_messagingpermissionWHATSAPP_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 -dinsidedockerfolder
-
-
- Install Dependencies
Navigate to
whatsapp-connectorandchatbotto install their dependecies.npm install
or
yarn add
-
Update Environment Variables
- Create
.envfile by copying.env.samplein 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_messagingpermissionWHATSAPP_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
mainbranch - Build Docker Images of both microservices
- Push Docker Images of both microservices to docker repository
- Update
docker-compose.ymlby replacing environment varibles from GitHub secrets - Copying
docker-compose.ymlandnginx.confto the server - Running
docker-composecommand to recreate containers - Deployment is done
If you have any feedback, please reach out to me at [email protected]
