This project aims to integrate a bot into WhatsApp using Twilio, Ngrok, and OpenAI API keys. Instead of accessing ChatGPT through a browser, we opted to make it available on WhatsApp for easier access and enhanced security.
- Write
app.py
:- Paste your OpenAI API keys in the code.
- Run the code:
- Obtain the server URL (e.g.,
https://127.0.0.1
).
- Obtain the server URL (e.g.,
- Configure Ngrok:
- Paste the server URL in the command:
ngrok http 127.0.0.1
. - Copy the forwarding URL provided by Ngrok.
- Paste the server URL in the command:
- Set up Twilio:
- Paste the Ngrok forwarding URL into Twilio's Sandbox configuration.
- Connect to WhatsApp:
- Your bot is now connected and can answer queries on WhatsApp.
- The user sends a query on WhatsApp.
- Twilio receives the query and forwards it to the Ngrok URL.
- Ngrok forwards the query to your server.
- Your server, using the OpenAI API, processes the query and fetches the relevant answer.
- The answer is sent back through Ngrok to Twilio, and then to WhatsApp.
API keys -> Code -> Ngrok -> Twilio -> WhatsApp
- Easy Access: Interact with ChatGPT directly from WhatsApp.
- Security: Ensures a secure connection and data handling.
- Time Efficient: Provides quick responses to user queries.