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

TwilioDevEd/employee-directory-node

Repository files navigation

Twilio

Employee Directory

Node.js CI

Use Twilio to accept SMS messages and turn them into queries against a database. This example functions as an Employee Directory where a mobile phone user can send a text message with a partial string of a person's name and it will return their picture and contact information (e-mail address and phone number).

Read the full tutorial here!

Local Development

This project is build using Express web framework and depends on MongoDB.

  1. First clone this repository and cd into it.

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

$ npm install
  1. Make sure the tests succeed.

    $ npm test
  2. Seed the database.

    $ npm run seed
  3. Start the server.

    $ npm start
  4. Check it out at http://localhost:3000.

Expose the Application to the Wider Internet

  1. 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

How To Demo

  1. Text your twilio number the name "Thor".

  2. Should get the following response:

    We found multiple people, reply with:
    1 for Thor
    2 for Frog Thor
    3 for Thor Girl
    Or start over
    
  3. Reply with 1.

  4. Should get the following response:

    Thor
    +14155559999
    thor@asgard.example.com
    [the image goes here]
    

## Meta

* No warranty expressed or implied. Software is as is. Diggity.
* [MIT License](http://www.opensource.org/licenses/mit-license.html)
* Lovingly crafted by Twilio Developer Education.