Tropo includes an “ask” method, which allows you to ask a question and wait for a response. On a voice call, the user is actually on the phone and typically responds quickly; with SMS, they might receive your text with the question but wait to respond until they have the free time. If your ask has a timeout of 30 seconds, and your user responds in a couple hours, how do you manage it? The absolute maximum timeout you can set is 2 hours – what if they respond the next day?
The best way to work around this limitation is by storing and reading the progress of an SMS conversation in a database, effectively eliminating any timeout concerns. This blog will discuss – and show – how to start, save and work with CouchDB to accomplish this. For the sake of simplity in this sample code, we’re getting back all the users. Realize that in a production system, you’ll probably want to tune this lookup so instead of getting back the couch documents for every user, you should search for the callerID and get only the documents for a particular user.