whatsapp_bot.mdx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. <Tabs>
  11. <Tab title="docker">
  12. ```bash
  13. docker run --name whatsapp-bot -e OPENAI_API_KEY=sk-xxx -p 8000:8000 embedchain/whatsapp-bot
  14. ```
  15. </Tab>
  16. <Tab title="python">
  17. ```bash
  18. python -m embedchain.bots.whatsapp --port 5000
  19. ```
  20. </Tab>
  21. </Tabs>
  22. 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.
  23. 3. Create a free account on [Twilio](https://www.twilio.com/try-twilio)
  24. - Set up a WhatsApp Sandbox in your Twilio dashboard. Access it via the left sidebar: `Messaging > Try it out > Send a WhatsApp Message`.
  25. - Follow on-screen instructions to link a phone number for chatting with your bot
  26. - 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.
  27. - 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.
  28. ### 💬 How to use
  29. - To connect a new number or reconnect an old one in the Sandbox, follow Twilio's instructions.
  30. - To include data sources, use this command:
  31. ```text
  32. add <url_or_text>
  33. ```
  34. - To ask the bot questions, just type your query:
  35. ```text
  36. <your-question-here>
  37. ```
  38. ### Example
  39. Here is an example of Elon Musk WhatsApp Bot that we created:
  40. <img src="/images/whatsapp.jpg"/>