[go: up one dir, main page]

Skip to content

philnash/ruby-whatsapp-bots

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WhatsApp Bots built in Ruby

This is a repo of WhatsApp bots built in Ruby using the Twilio API for WhatsApp.

Available bots

There is one bot so far:

  • Keyword bot: a Sinatra application that can return facts and pictures about dogs and cats based on the keywords you send to it

How to build a bot

See the blog post Build a WhatsApp chatbot with Ruby, Sinatra and Twilio to see how to get started with building bots.

Running the bots

You will need the following to run the bots in this repo:

Configure the Twilio sandbox for WhatsApp

  • Head to the WhatsApp sandbox area of the Twilio console, or navigate from the console to Programmable SMS and then WhatsApp
  • The page will have the WhatsApp sandbox number on it. Open your WhatsApp application and start a new message to that number
  • The page also has the message you need to send, which is "join" plus two random words, like "join flagrant-pigeon". Send your message to the sandbox number

Running an application

Download or clone the app

Clone the application to your machine with the following command:

git clone https://github.com/philnash/ruby-whatsapp-bots.git
cd ruby-whatsapp-bots

Install dependencies

Install the dependencies with bundler:

bundle install

Configure the environment

Copy the config example file:

cp config/env.yml.example config/env.yml

Get your Twilio auth token from your Twilio console and add it to config/env.yml.

To use the location bot, sign up for a free Dark Sky API key and add that to config/env.yml.

Run the app

Change into the directory of the bot you want to run. Then run the application with:

bundle exec rackup

ngrok

Run ngrok to tunnel through to localhost:9292:

ngrok http 9292

Take your ngrok URL and the path to your bot, https://YOUR_NGROK_SUBDOMAIN.ngrok.io/bot and enter it in the WhatsApp sandbox admin in the input marked "When a message comes in" and save the configuration.

Now send your bot a message and wait for the response.

License

These bots are licensed under the MIT license.

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages