Integrating Adhearsion app with Rails app

classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

Integrating Adhearsion app with Rails app

Rajat Saxena
I am capturing incoming caller id using Adhearsion and Asterisk in an Adhearsion app and then I need to send it to a Ruby on Rails app to run the application according to the fetched phone number.
I've tried the procedure on Adhearsion's website (http://www.adhearsion.com/docs/best-practices/rails). But it didn't work and it is now marked as 'stale'. I couldn't find much on the web either.

Any help would be much appreciated.

Thanks.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Integrating Adhearsion app with Rails app

Justin Aiken
Hi Rajat,

Check out these slides and the example app from my AhnConf2013 talk:


Gives a few different examples of ways to hook adhearsion into rails (DRB, HTTP, Redis)

Good luck!
Justin

On Oct 2, 2014, at 11:09 AM, Rajat Saxena <[hidden email]> wrote:

I am capturing incoming caller id using Adhearsion and Asterisk in an Adhearsion app and then I need to send it to a Ruby on Rails app to run the application according to the fetched phone number.
I've tried the procedure on Adhearsion's website (http://www.adhearsion.com/docs/best-practices/rails). But it didn't work and it is now marked as 'stale'. I couldn't find much on the web either.

Any help would be much appreciated.

Thanks.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Integrating Adhearsion app with Rails app

Nathan Samson
I want to do something different using adhearsion & rails (web frontend).

On the frontend users can login / register & depending on their authorization levels set some config settings. With each user also a phone number is asssociated.
My current idea is to implement this 100% in the same database with all models in the rails app.

Now there are incoming calls to my adhearsion controller, and depending on global config + user specific config the controller has to behave differentiently.
Logically reuse of the same models would be very beneficial, but from a deploy POV maybe not the best idea.

My idea was then to be able to expose an API in the rails service, which then gets called by the call controller to fetch config and/or upload recordings.
Although this has a similar problem that I want to be able to scale (& firewall) my API differently from my web server.

Has anyone a good setup to split of the API but reusing the same models?
One solution could be to create the common models & behaviour in a (private) gem extension, but that hinders development speed...

Nathan

On Thu, Oct 2, 2014 at 7:20 PM, Justin Aiken <[hidden email]> wrote:
Hi Rajat,

Check out these slides and the example app from my AhnConf2013 talk:


Gives a few different examples of ways to hook adhearsion into rails (DRB, HTTP, Redis)

Good luck!
Justin

On Oct 2, 2014, at 11:09 AM, Rajat Saxena <[hidden email]> wrote:

I am capturing incoming caller id using Adhearsion and Asterisk in an Adhearsion app and then I need to send it to a Ruby on Rails app to run the application according to the fetched phone number.
I've tried the procedure on Adhearsion's website (http://www.adhearsion.com/docs/best-practices/rails). But it didn't work and it is now marked as 'stale'. I couldn't find much on the web either.

Any help would be much appreciated.

Thanks.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Integrating Adhearsion app with Rails app

Ben Langfeld-2
You'll find far better answers to that side question, Nathan, in some Rails forum.

On 2 October 2014 15:29, Nathan Samson <[hidden email]> wrote:
I want to do something different using adhearsion & rails (web frontend).

On the frontend users can login / register & depending on their authorization levels set some config settings. With each user also a phone number is asssociated.
My current idea is to implement this 100% in the same database with all models in the rails app.

Now there are incoming calls to my adhearsion controller, and depending on global config + user specific config the controller has to behave differentiently.
Logically reuse of the same models would be very beneficial, but from a deploy POV maybe not the best idea.

My idea was then to be able to expose an API in the rails service, which then gets called by the call controller to fetch config and/or upload recordings.
Although this has a similar problem that I want to be able to scale (& firewall) my API differently from my web server.

Has anyone a good setup to split of the API but reusing the same models?
One solution could be to create the common models & behaviour in a (private) gem extension, but that hinders development speed...

Nathan

On Thu, Oct 2, 2014 at 7:20 PM, Justin Aiken <[hidden email]> wrote:
Hi Rajat,

Check out these slides and the example app from my AhnConf2013 talk:


Gives a few different examples of ways to hook adhearsion into rails (DRB, HTTP, Redis)

Good luck!
Justin

On Oct 2, 2014, at 11:09 AM, Rajat Saxena <[hidden email]> wrote:

I am capturing incoming caller id using Adhearsion and Asterisk in an Adhearsion app and then I need to send it to a Ruby on Rails app to run the application according to the fetched phone number.
I've tried the procedure on Adhearsion's website (http://www.adhearsion.com/docs/best-practices/rails). But it didn't work and it is now marked as 'stale'. I couldn't find much on the web either.

Any help would be much appreciated.

Thanks.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Integrating Adhearsion app with Rails app

Rajat Saxena
In reply to this post by Rajat Saxena
This is the code snippet in my Adhearsion app in SimonGame.rb


Adhearsion::Events.draw do
    ami name
: 'Newchannel' do |event|
    callvar
= event.headers['CallerIDNum']
    logger
.info "+++ WE HAVE A NEW CHANNEL +++"
    logger
.info callvar
    logger
.info "++++++++++++++++++++++++++++++++++"    
    caller_id_num
= callvar
    logger
.info caller_id_num
   
DRb.start_service 'druby://localhost:9000', SimonGame.new(caller_id_num)
    logger
.info "Server running at #{DRb.uri}"
   
end
end


 
def initialize(callerid)
   
@num = callerid
 
end

And in the Rails app, in my controller, I am putting this

counter = DRbObject.new nil, 'druby://localhost:9000'
    logger
.info "booooooooooooooooooooooooo"
      logger
.info counter
      logger
.info "value printed"

The result in my logs is

booooooooooooooooooooooooo
#<SimonGame:0x000000023fcbc0>
value printed


So I'm sensing I'm close. There's just a small mistake somewhere.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Re: [Adhearsion] Integrating Adhearsion app with Rails app

Ben Klang-2

signature.asc (858 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Integrating Adhearsion app with Rails app

Ben Klang-2
In reply to this post by Rajat Saxena
So a couple of things that may help:

* SimonGame is a CallController.  It is only meant to execute inside of an Adhearsion application, and will almost certainly fall apart when attempting to run it from a Rails app.  By starting your DRb server with SimonGame as the receiver, you’re asking for trouble.

* You can’t start a CallController from a “Newchannel” event as SimonGame won’t have the required call state nor control of the call via Asterisk or FreeSWITCH

* DRb is probably not the right tool for the job, if I understand what you want to do.

Let me suggest that you use the normal mechanism to send calls to Adhearsion for control, and that you use a vanilla HTTP API call to load the data from your backend. In this way the business logic contained in your models remains intact and you don’t have to duplicate it.

Try something like this in your config/routes.rb.  I make the assumption that you’ve defined a class called HttpApiClient that exposes a method “get_account_info” to fetch data from your Rails API

Adhearsion.router do
  route ‘default’ do
    account = HttpApiClient.get_account_info call.from

    if account
      # We have a valid customer account, let them play SimonGame and pass in the account information as metadata
      pass SimonGame, account: account
    else
      # No account information (API returned nil), so hang up
      play ‘sorry-you-are-not-a-customer.wav’, ‘goodbye’
      hangup
    end
end


/BAK/
-- 
Ben Klang
Principal/Technology Strategist, Mojo Lingo
+1.404.475.4841

Mojo Lingo -- Voice applications that work like magic
Twitter: @MojoLingo

Il giorno Oct 3, 2014, alle ore 7:40 AM, Rajat Saxena <[hidden email]> ha scritto:

This is the code snippet in my Adhearsion app in SimonGame.rb


Adhearsion::Events.draw do
    ami name: 'Newchannel' do |event|
    callvar = event.headers['CallerIDNum']
    logger.info "+++ WE HAVE A NEW CHANNEL +++"
    logger.info callvar
    logger.info "++++++++++++++++++++++++++++++++++"    
    caller_id_num = callvar
    logger.info caller_id_num
    DRb.start_service '<a href="druby://localhost:9000'">druby://localhost:9000', SimonGame.new(caller_id_num)
    logger.info "Server running at #{DRb.uri}"
    end
end


  def initialize(callerid)
    @num = callerid
  end

And in the Rails app, in my controller, I am putting this

counter = DRbObject.new nil, '<a href="druby://localhost:9000'">druby://localhost:9000'
    logger.info "booooooooooooooooooooooooo"
      logger.info counter
      logger.info "value printed"

The result in my logs is

booooooooooooooooooooooooo
#<SimonGame:0x000000023fcbc0>
value printed


So I'm sensing I'm close. There's just a small mistake somewhere.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.


signature.asc (858 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Integrating Adhearsion app with Rails app

Ben Klang-2
In reply to this post by Rajat Saxena
So a couple of things that may help:

* SimonGame is a CallController.  It is only meant to execute inside of an Adhearsion application, and will almost certainly fall apart when attempting to run it from a Rails app.  By starting your DRb server with SimonGame as the receiver, you’re asking for trouble.

* You can’t start a CallController from a “Newchannel” event as SimonGame won’t have the required call state nor control of the call via Asterisk or FreeSWITCH

* DRb is probably not the right tool for the job, if I understand what you want to do.

Let me suggest that you use the normal mechanism to send calls to Adhearsion for control, and that you use a vanilla HTTP API call to load the data from your backend. In this way the business logic contained in your models remains intact and you don’t have to duplicate it.

Try something like this in your config/routes.rb.  I make the assumption that you’ve defined a class called HttpApiClient that exposes a method “get_account_info” to fetch data from your Rails API

Adhearsion.router do
  route ‘default’ do
    account = HttpApiClient.get_account_info call.from

    if account
      # We have a valid customer account, let them play SimonGame and pass in the account information as metadata
      pass SimonGame, account: account
    else
      # No account information (API returned nil), so hang up
      play ‘sorry-you-are-not-a-customer.wav’, ‘goodbye’
      hangup
    end
end


/BAK/
-- 
Ben Klang
Principal/Technology Strategist, Mojo Lingo
+1.404.475.4841

Mojo Lingo -- Voice applications that work like magic
Twitter: @MojoLingo

Il giorno Oct 3, 2014, alle ore 7:40 AM, Rajat Saxena <[hidden email]> ha scritto:

This is the code snippet in my Adhearsion app in SimonGame.rb


Adhearsion::Events.draw do
    ami name: 'Newchannel' do |event|
    callvar = event.headers['CallerIDNum']
    logger.info "+++ WE HAVE A NEW CHANNEL +++"
    logger.info callvar
    logger.info "++++++++++++++++++++++++++++++++++"    
    caller_id_num = callvar
    logger.info caller_id_num
    DRb.start_service '<a href="druby://localhost:9000'">druby://localhost:9000', SimonGame.new(caller_id_num)
    logger.info "Server running at #{DRb.uri}"
    end
end


  def initialize(callerid)
    @num = callerid
  end

And in the Rails app, in my controller, I am putting this

counter = DRbObject.new nil, '<a href="druby://localhost:9000'">druby://localhost:9000'
    logger.info "booooooooooooooooooooooooo"
      logger.info counter
      logger.info "value printed"

The result in my logs is

booooooooooooooooooooooooo
#<SimonGame:0x000000023fcbc0>
value printed


So I'm sensing I'm close. There's just a small mistake somewhere.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.


signature.asc (858 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Integrating Adhearsion app with Rails app

Rajat Saxena
In reply to this post by Ben Klang-2

I make the assumption that you’ve defined a class called HttpApiClient that exposes a method “get_account_info” to fetch data from your Rails API

It is the other way round. I have to send the caller id of the incoming call to my Rails app which will then check whether the number exists in the database or not. I do not have any other task in Adhearsion except storing the caller id number and sending it to Rails.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Integrating Adhearsion app with Rails app

Rajat Saxena
Is it instead possible to somehow directly send parameters from an Asterisk event? An event is raised in the Asterisk console too for a new call. Can I send the caller id from there itself? (Whichever is easier I mean)

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Integrating Adhearsion app with Rails app

Ben Klang-2
In reply to this post by Rajat Saxena

Il giorno Oct 5, 2014, alle ore 3:26 AM, Rajat Saxena <[hidden email]> ha scritto:


I make the assumption that you’ve defined a class called HttpApiClient that exposes a method “get_account_info” to fetch data from your Rails API

It is the other way round. I have to send the caller id of the incoming call to my Rails app which will then check whether the number exists in the database or not. I do not have any other task in Adhearsion except storing the caller id number and sending it to Rails.

Nope, we’re saying the same thing.  When the call comes into Adhearsion, your HttpApiClient inside Adhearsion will send the caller ID via GET or POST to Rails, which will return data about whether the number is in the database or not.  You’ll need to expose such an API on the Rails side, and create client code to access it on the Adhearsion side.

/BAK/

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.


signature.asc (858 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Integrating Adhearsion app with Rails app

Ben Klang-2
In reply to this post by Rajat Saxena

Il giorno Oct 5, 2014, alle ore 3:33 AM, Rajat Saxena <[hidden email]> ha scritto:

Is it instead possible to somehow directly send parameters from an Asterisk event? An event is raised in the Asterisk console too for a new call. Can I send the caller id from there itself? (Whichever is easier I mean)


Yes, but you can’t control the call from here.  Since I understand that you want to interact with the call after you have determined whether the caller exists in your database, the appropriate place to do this is in a CallController, and not an Event.

/BAK/

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.


signature.asc (858 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Integrating Adhearsion app with Rails app

Rajat Saxena
Right. So is there any detailed guide on using HTTP requests? I went through Justin's slides but I'll need a little more support here.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Integrating Adhearsion app with Rails app

Ben Klang-2

Il giorno Oct 5, 2014, alle ore 3:24 PM, Rajat Saxena <[hidden email]> ha scritto:

Right. So is there any detailed guide on using HTTP requests? I went through Justin's slides but I'll need a little more support here.


It’s “just Ruby” so you can use the HTTP client of your choice.  If you’re looking for a recommendation, I usually use Faraday:


See their README for instructions on setting up and using that library.  If you put the file in the “lib/“ directory of your Adhearsion app, it will be available to be required in any CallController or routing definition you may use.

/BAK/

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.


signature.asc (858 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Integrating Adhearsion app with Rails app

Rajat Saxena
In reply to this post by Rajat Saxena
Hi,
I'm relatively new to Rails and unfortunately I still haven't been able to get this working. Is there any sample application or code that I could study?
I just need to send a parameter from Adhearsion app to Rails app.
Any help is really appreciated!
Thanks.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Integrating Adhearsion app with Rails app

Ben Klang-2
On Oct 17, 2014, at 1:15 PM, Rajat Saxena <[hidden email]> wrote:

Hi,
I'm relatively new to Rails and unfortunately I still haven't been able to get this working. Is there any sample application or code that I could study?
I just need to send a parameter from Adhearsion app to Rails app.
Any help is really appreciated!
Thanks.


Justin’s presentations are the best sample application code available:

Code:
If you want to share with us the code you’ve created, or have specific questions about something not working, we can comment on that.  Just share a link to the Github repository or a gist of the Adhearsion or Rails code.

/BAK/

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.


signature.asc (858 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Integrating Adhearsion app with Rails app

Rajat Saxena
In reply to this post by Rajat Saxena
This is the best I could come up with.

Adhearsion app:
SimonGame.rb

Adhearsion::Events.draw do
    ami name
: 'Newchannel' do |event|
    callvar
= event.headers['CallerIDNum']
    logger
.info "+++ WE HAVE A NEW CHANNEL +++"
    logger
.info callvar
    logger
.info "++++++++++++++++++++++++++++++++++"    
    caller_id_num
= callvar
    logger
.info caller_id_num

   
#Faraday stuff
      url
= 'http://localhost:3001/api/plans'
      conn
= Faraday.new(:url => url) do |faraday|
      conn
.post url, :some_param => caller_id_num
      logger
.info "Param posted"
     
end
   
end
end



Rails app:


      conn
= Faraday.new(:url => 'http://localhost:3000/test')
      response
= conn.get do |req|
       vellaparam
= req.params['some_param']
       logger
.info vellaparam
   
end


But as you probably guessed, it didn't work.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Integrating Adhearsion app with Rails app

Ben Langfeld-2
That's not how HTTP GET/POST work. You should create rails controllers/routes appropriately, not try to use Faraday (an HTTP client) as an HTTP server. If you need further help with basic Rails usage, I'd suggest reading the guides (http://guides.rubyonrails.org/) or seeking assistance via the Rails support channels.

On 17 October 2014 14:57, Rajat Saxena <[hidden email]> wrote:
This is the best I could come up with.

Adhearsion app:
SimonGame.rb

Adhearsion::Events.draw do
    ami name
: 'Newchannel' do |event|
    callvar
= event.headers['CallerIDNum']
    logger
.info "+++ WE HAVE A NEW CHANNEL +++"
    logger
.info callvar
    logger
.info "++++++++++++++++++++++++++++++++++"    
    caller_id_num
= callvar
    logger
.
info caller_id_num

   
#Faraday stuff
      url
= 'http://localhost:3001/api/plans'
      conn
= Faraday.new(:url => url) do |faraday|
      conn
.post url, :some_param => caller_id_num
      logger
.info "Param posted"
     
end
   
end
end



Rails app:


      conn
= Faraday.new(:url => 'http://localhost:3000/test')
      response
= conn.get do |req|
       vellaparam
= req.params['some_param']
       logger
.info vellaparam
   
end


But as you probably guessed, it didn't work.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Integrating Adhearsion app with Rails app

Rajat Saxena
In reply to this post by Rajat Saxena
I made the following changes.

SimonGame.rb:

Adhearsion::Events.draw do
    ami name
: 'Newchannel' do |event|
      callvar
= event.headers['CallerIDNum']
      logger
.info "+++ WE HAVE A NEW CHANNEL +++"
      logger
.info callvar
      logger
.info "++++++++++++++++++++++++++++++++++"    
      caller_id_num
= callvar
      logger
.info caller_id_num

   
#Faraday stuff
    url
= 'http://localhost:3000/flow2'
    conn
= Faraday.new
    logger
.info conn.inspect
    logger
.info "hiiiiiii"
    conn
.post url, :some_param => caller_id_num
    logger
.info "Param posted"
 
end



Flow2Controller.rb:

# Faraday stuff
       conn
= Faraday.new
       response
= conn.get 'http://localhost:3000/test'
       logger
.info response.inspect
       logger
.info "HOOOOOOOOOOOOOOOOOOOOOOOOOOO"
       logger
.info response
       logger
.info "HEEEEEEEEEEEEEEEEEEEEEEEEEEEE"

And then when I call, I get this in the log. The incoming phone number is passed as a parameter.

Ruby log/development.log

Processing Flow2Controller#index (for 127.0.0.1 at 2014-10-19 21:36:57) [POST]
 
Parameters: {"some_param"=>"9873374110"}

ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
 
<internal:prelude>:10:in `synchronize'
  /usr/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `
service'
  /usr/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'

 
/usr/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

Rendered rescues/_trace (15.3ms)
Rendered rescues/_request_and_response (1.9ms)
Rendering rescues/layout (unprocessable_entity)


Two questions:
1. There is this InvalidAuthenticityToken error.
2. How do I get the phone number to a variable from 'some_param'?

Thanks.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Integrating Adhearsion app with Rails app

Ben Langfeld-2
I'm afraid you're fundamentally misunderstanding HTTP, Rails and Adhearsion all at once here. I suggest perhaps you take some time to read a book about Rails and work on a very simple project before tackling this one, or hire someone to provide you with classes of some sort or to implement this project while you shadow for learning purposes.

Ben

On 19 October 2014 14:16, Rajat Saxena <[hidden email]> wrote:
I made the following changes.

SimonGame.rb:

Adhearsion::Events.draw do
    ami name
: 'Newchannel' do |event|
      callvar
= event.headers['CallerIDNum']
      logger
.info "+++ WE HAVE A NEW CHANNEL +++"
      logger
.info callvar
      logger
.info "++++++++++++++++++++++++++++++++++"    
      caller_id_num
= callvar
      logger
.info caller_id_num

   
#Faraday stuff

    url
= 'http://localhost:3000/flow2'
    conn
= Faraday.new
    logger
.info conn.inspect
    logger
.info "hiiiiiii"
    conn
.post url, :some_param => caller_id_num
    logger
.info "Param posted"
 
end



Flow2Controller.rb:

# Faraday stuff
       conn
= Faraday.new
       response
= conn.get 'http://localhost:3000/test'
       logger
.info response.inspect
       logger
.info "HOOOOOOOOOOOOOOOOOOOOOOOOOOO"
       logger
.info response
       logger
.info "HEEEEEEEEEEEEEEEEEEEEEEEEEEEE"

And then when I call, I get this in the log. The incoming phone number is passed as a parameter.

Ruby log/development.log

Processing Flow2Controller#index (for 127.0.0.1 at 2014-10-19 21:36:57) [POST]
 
Parameters: {"some_param"=>"<a href="tel:9873374110" value="+559873374110" target="_blank">9873374110"}

ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
 
<internal:prelude>:10:in `synchronize'
  /usr/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `
service'
  /usr/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'

 
/usr/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

Rendered rescues/_trace (15.3ms)
Rendered rescues/_request_and_response (1.9ms)
Rendering rescues/layout (unprocessable_entity)


Two questions:
1. There is this InvalidAuthenticityToken error.
2. How do I get the phone number to a variable from 'some_param'?

Thanks.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.