Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to redirect browser in rails app following request from 3rd party API
    primarykey
    data
    text
    <p>I am trying to integrate my Rails app with a 3rd party API (Twilio). The user initiates a call by pressing a button on their browser, they follow the call logic on the telephone, and then when the call terminates, I want the browser to be redirected to a different page. However, I am having difficulty dealing with responses for the two different user agents (the browser and the Twilio API).</p> <p>The call is initiated using the following controller action (and as the request comes from the browser, the render action works without a problem):</p> <pre><code>def set_up @client = Twilio::REST::Client.new ACCOUNT_SID, AUTH_TOKEN data = { from: FROM, to: params[:number], url: candidate_begin_url(@candidate), method: 'get', timeout: 10 } @client.account.calls.create data render 'candidates/interview_in_progress' end </code></pre> <p>At the end of the call, once the user is ready to terminate, the Twilio API makes a GET request to the following controller. The intention is for two things to happen:</p> <ol> <li>The controller should respond to the Twilio API with XML instructions to hang up the call</li> <li><p>The controller should redirect the user's browser to a new url</p> <pre><code>def finalize_call response = Twilio::TwiML::Response.new do |r| r.Hangup end.text respond_to do |format| format.html { redirect_to candidate_complete_voice_interview_path(@candidate) } format.xml { render xml: response } end end </code></pre></li> </ol> <p>However it seems that because the request comes from the Twilio API user agent, I am unable to perform any actions with the browser. So while in the log I see the new page has been rendered with status 200 OK, there is no change in the browser.</p> <p>My question is, how can I instruct the browser to redirect following a request from a different user agent, in this case the API?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload