1
votes

After Michael Hartl's tutorial on rails, I'm trying to build a call tracking app, to learn more rails and Twilio.

So far I've managed to create --

  • Authentication
  • Integration With Stripe
  • Every User who registers automatically gets a Twilio Subaccount
  • Users Can Search for Phone Numbers, And Buy them

(This has been done with 20 Stackoverflow questions in the last 5 days!)

Now, What I would like to do is to actually create the functionality for recording call data via Twilio.

They have a php tutorial here : http://www.twilio.com/docs/howto/call-tracking

I'm having trouble conceptualizing how I'm going to make this work. I.e What Combination of Controllers/Actions will I need to route calls through a twilio number, and receive the information?

So far, I have 3 models

Plan Model

#  name              :string(255)
#  max_phone_numbers :integer
#  max_minutes       :integer
#  price             :integer
has_many :users

User Model

#  name                  :string(255)
#  email                 :string(255)
#  twilio_account_sid    :string(255)
#  twilio_auth_token     :string(255)
#  plan_id               :integer
#  stripe_customer_token :string(255)
belongs_to :plan
has_many :phones

Phone Model

#  campaign_       :string(255)
#  twilio_number   :integer
#  original_number :integer
#  user_id
belongs_to :user

Now, I'm thinking of having a new model, called Phone_data. The Phone Model than has_many Phone_datas. I could than use the association to show data on a particular phone.

Possible New Model: phone_data

#Data that twilio can save to each phone(duration of call, etc )
#phone_id
#belongs_to phones 

My question is, does the phone_data model make sense, and more importantly, how do you think the Controllers are going to look like, to achieve the functionality to

  1. Lead dials a Twilio number and Twilio POSTs information to your application

  2. Application saves Twilio call information to the proper phone_data association

  3. The application sends TwiML instructions to Dial the original_number

  4. Lead and agent have a conversation until one of them disconnects

  5. Twilio requests the Dial action URL and sends information about the second call leg

Here's the code that they use for PHP

1

1 Answers

2
votes

The guys at Twilio, especially Brian Levine, are amazing. Brian went ahead and explained this to me...by building a sample application! found here :

https://github.com/Beans0063/Twilio-Call-Tracking-Ruby