whatsapp_bot.mdx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ---
  2. title: '💬 WhatsApp Bot'
  3. ---
  4. ### 🚀 Getting started
  5. 1. Install embedchain python package:
  6. ```bash
  7. pip install --upgrade embedchain
  8. ```
  9. 2. Launch your WhatsApp bot:
  10. ```bash
  11. python -m embedchain.bots.whatsapp --port 5000
  12. ```
  13. If your bot needs to be accessible online, use your machine's public IP or DNS. Otherwise, employ a proxy server like [ngrok](https://ngrok.com/) to make your local bot accessible.
  14. 3. Create a free account on [Twilio](https://www.twilio.com/try-twilio)
  15. - Set up a WhatsApp Sandbox in your Twilio dashboard. Access it via the left sidebar: `Messaging > Try it out > Send a WhatsApp Message`.
  16. - Follow on-screen instructions to link a phone number for chatting with your bot
  17. - Copy your bot's public URL, add /chat at the end, and paste it in Twilio's WhatsApp Sandbox settings under "When a message comes in". Save the settings.
  18. - Copy your bot's public url, append `/chat` at the end and paste it under `When a message comes in` under the `Sandbox settings` for Whatsapp in Twilio. Save your settings.
  19. ### 💬 How to use
  20. - To connect a new number or reconnect an old one in the Sandbox, follow Twilio's instructions.
  21. - To include data sources, use this command:
  22. ```text
  23. add <url_or_text>
  24. ```
  25. - To ask the bot questions, just type your query:
  26. ```text
  27. <your-question-here>
  28. ```
  29. ### Example
  30. Here is an example of Elon Musk WhatsApp Bot that we created:
  31. <img src="/images/whatsapp.jpg"/>