Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6979327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:52:20+00:00 2026-05-27T17:52:20+00:00

I am using Twilio in my rails 3.1.3 app and I have got everything

  • 0

I am using Twilio in my rails 3.1.3 app and I have got everything basically set up, i.e. a controller for sms and xml builders for the views depending on the response. The only thing I can’t figure out is how to keep track of the conversation. The Twilio docs are pretty bad for using anything other than PHP to do this. I have tried using the Rails session hash, session[:variable], but it doesn’t seem to be saving the session, as I tried redirecting and printing it out and got nothing. Below is the code of the controller.

  def receive
    # Check for session variable and redirect if necessary
    @sms_state = session[:sms_state]
    if @sms_state == 'confirmation'
      redirect_to 'confirm'
    end
    if condition
      @sms_state = 'confirmation'
      session[:sms_state] = @sms_state
      render :action => "view.xml.builder", :layout => false
    else
      @sms_state = 'new_state'
      session[:sms_state] = @sms_state
      render :action => "error.xml.builder", :layout => false
    end
  end
  # method that should be called after user deals with first part
  def confirm
    if condition
      @sms_state = session[:sms_state] = nil
      render :action => "confirm_view.xml.builder", :layout => false
    else
      @sms_state = 'confirmation'
      session[:sms_state] = @sms_state
      render :action => "error.xml.builder", :layout => false
    end
  end

I have now set up a database table to track the current conversation state depending on the phone number contacting my app. The only thing now that I need to do is set an expiration for this conversation, just like a session or cookie. I am not sure how to do this or if its even possible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:52:21+00:00Added an answer on May 27, 2026 at 5:52 pm

    This depends on how you define “conversation”, but in general, you are better off using some sort of persistance (would recommend database over a file), and build the structure in accordance with your definition of a conversation.

    Suppose the conversation is defined as text messages between two 10-digit phone numbers without a time limit, you can setup a db with a sender and recipient attributes, so if you need to output something in a user interface, you can look for sender and recipient phone numbers, and display all messages coming to them or going from them.

    SMS is different from a phone call, since you can set cookies for the session of a phone call. SMS is done when either delivered or sent. When you receive an SMS to a phone number or short code, Twilio will make a request to the URL you provided for SMS, and your app can then respond. If you receive another response, it’s a brand new request, so you have to construct the notion of “conversation”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rails application that I am implementing the Twilio SMS API on,
I'm trying to send out some sms messages via php, using twilio, that have
I'm spiking on a rails app to make calls using twilio. I'm using the
I am trying to integrate my Rails app with a 3rd party API (Twilio).
For a ruby on rails twilio app, I simply need to upload an mp3
I'm using the Twilio API to send broadcast SMS messages based on an approved
How would I send an SMS to a user using a Kynetx App and
I'm using Twilio in an iphone app. I'm interested in having a dialer in
How can I send an SMS message programatically from an iPhone app? I'm using
I'm using the Twilio API to send an SMS from my Twilio number to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.