Give your customers specialized product support. Learn how to use TaskRouter to create a workflow that will redirect users to an appropriate sales agent, based on the product they select.
This project is built using Ruby on Rails Framework for the backend and NodeJS to serve the frontend assets.
-
First clone this repository and
cd
into it.$ git clone [email protected]:TwilioDevEd/task-router-rails.git $ cd task-router-rails
-
Install the backend dependencies. Be sure to have SQLite installed on your system before running this command.
$ bundle install
-
Install the frontend dependencies.
$ npm install
-
Expose your application to the wider internet using ngrok.
This step is important because the application won't work as expected if you run it through localhost.
$ ngrok http 3000
Your ngrok URL should look something like this:
http://9a159ccf.ngrok.io
You can read this blog post for more details on how to use ngrok.
-
Configure Twilio to call your webhooks
You will also need to configure Twilio to call your application when calls or SMSs are received on your
TWILIO_NUMBER
. Your urls should look something like this:voice: http://9a159ccf.ngrok.io/call/incoming sms: http://9a159ccf.ngrok.io/message/incoming
Learn how to configure a Twilio phone number for Programmable Voice
Learn how to configure a Twilio phone number for Programmable SMS
-
Copy the sample configuration file and edit it to match your configuration.
$ cp .env.example .env
You can find your
TWILIO_ACCOUNT_SID
andTWILIO_AUTH_TOKEN
in your Twilio Account Settings. You will also need aTWILIO_NUMBER
, which you may find here. -
Create database and run migrations.
$ bundle exec rake db:setup
-
Make sure the tests succeed.
$ bundle exec rspec
-
Start the server.
$ bundle exec rails s
That's it!
-
First make sure you have correctly filled all the required environment variables from the
.env.example
file. Bob and Alice's number should be two different numbers where you can receive calls and SMSs. -
When you run the app, a new workspace will be configured. Once that is done, you are ready to call your Twilio Number where you'll be asked to select a product using your key pad.
-
Select and option and the phone assigned to the product you selected (Bob or Alice's) will start ringing. You can answer the call and have a conversation.
-
Alternatively, if you don't answer the call within 15 seconds, the call should be redirected to the next worker. If the call isn't answered by the second worker, you should be redirected to voice mail and leave a message. The transcription of that message should be sent to the email you specified in your environment variables.
-
Each time a worker misses a call, their activity is changed to offline. Right after they should receive a notification, via SMS, saying that they missed the call. In order to go back online they can reply with
On
. They can as well reply withOff
in order to go back to offline status. -
If both workers' activity changes to
Offline
and you call your Twilio Number again, you should be redirected to voice mail after a few seconds as the workflow timeouts when there are no available workers. Change your workers status with theOn
SMS command to be able to receive calls again. -
Navigate to
https://<ngrok_subdomain>.ngrok.io
to see a list of the missed calls.
- No warranty expressed or implied. Software is as is. Diggity.
- MIT License
- Lovingly crafted by Twilio Developer Education.