- Twilio Account: Sign up for Twilio.
- Google Cloud Account: Sign up for Google Cloud.
- Log in to the Twilio Console: Go to Twilio Console.
- Navigate to the WhatsApp Sandbox:
- In the Console, go to "Messaging".
- Click on "Try it out" under "Send a WhatsApp message".
- Join the Sandbox:
- Follow the instructions to join the sandbox using the provided code and Twilio sandbox number.
- Set the Webhook URL:
- In the Twilio Console, under "Sandbox Configuration", set the "When a message comes in" webhook URL to your server endpoint (e.g.,
http://your-ngrok-url.ngrok.io/whatsapp).
- In the Twilio Console, under "Sandbox Configuration", set the "When a message comes in" webhook URL to your server endpoint (e.g.,
- Create a New Agent:
- Go to the Dialogflow Console.
- Create a new agent.
- Enable the API:
- Go to the Google Cloud Console.
- Select your project and enable the Dialogflow API.
- Create a Service Account:
- Go to "IAM & Admin" > "Service Accounts".
- Create a new service account with the roles
Dialogflow API ClientandDialogflow API Admin. - Generate a JSON key file and download it.
npm install express twilio body-parser dialogflow- Download service key fron google cloud and paste it in the root folder
- create API_KEYS.js file and add all the keys
- Download ngrok: ngrok Download Page.
- Run ngrok:
ngrok http 3000
- Copy the ngrok URL: Copy the forwarding URL provided by ngrok (e.g.,
http://abcdef1234.ngrok.io).
- Set the Webhook URL:
- In the Twilio Console, update the "When a message comes in" URL to the ngrok URL followed by
/whatsapp(e.g.,http://abcdef1234.ngrok.io/whatsapp).
- In the Twilio Console, update the "When a message comes in" URL to the ngrok URL followed by
-
Start Your Server:
node server.js
-
Send a WhatsApp Message:
- Send a message to the Twilio sandbox number from your WhatsApp.
-
Verify the Response:
- Ensure that your server processes the message, communicates with Dialogflow, and sends back an appropriate response.