Skip to content
This repository has been archived by the owner on Jun 12, 2023. It is now read-only.

TwilioDevEd/employee-directory-rails

Repository files navigation

Twilio

Employee Directory with Ruby on Rails

Allow users to query an employee directory database via SMS messages. This tutorial shows how to handle fuzzy matching and user input via text message, and how to send customized SMS and MMS replies to users.

Build Status Coverage Status

Local development

This project is built using the Ruby on Rails web framework.

  1. First clone this repository and cd into it.

    $ git clone git@github.com:TwilioDevEd/employee-directory-rails.git
    $ cd employee-directory-rails
  2. Install the dependencies.

    $ bundle install
  3. Create the database and run migrations.

    Make sure you have installed PostgreSQL. If on a Mac, I recommend Postgres.app.

    $ bundle exec rake db:setup

    The data in our seed file was provided by Marvel. © 2016 MARVEL

  4. Make sure the tests succeed.

    $ bundle exec rspec
  5. Start the server.

    $ bundle exec rails s
  6. Expose your application to the wider internet using ngrok. You can click here for more details. This step is important because the application won't work as expected if you run it through localhost.

$ ngrok http 3000

Once ngrok is running, open up your browser and go to your ngrok URL. It will look something like this: http://9a159ccf.ngrok.io

  1. Configure Twilio to call your webhooks.

You will also need to configure Twilio to call your application when calls are received on your Twilio Number. The SMS & MMS Request URL should look something like this:

http://<sub-domain>.ngrok.io/directory/search

Configure SMS

Expose the Application to the Wider Internet

If you want your application to be accessible from the internet, you can either forward the necessary ports in your router, or use a tool like ngrok that will expose your local host to the internet.

You can read this blog post for more details on how to use ngrok. If you are using version 2.x, exposing a specific port should be easily done with the following command:

$ ngrok http 3000

How To Demo

  1. Text your twilio number the name "Iron"

  2. Should get the following response:

    We found multiple people, reply with:
    1 for Iron Man
    2 for Iron Clad
    Or start over
    
  3. Reply with 1

  4. Should get the following response:

    Iron Man
    +14155559368
    +1-202-555-0143
    IronMan@heroes.example.com
    [the image goes here]
    

Meta

  • No warranty expressed or implied. Software is as is. Diggity.
  • MIT License
  • Lovingly crafted by Twilio Developer Education.