daguar / voicemail-for-that

Anthropomorphizing inanimate objects by giving them voicemail
MIT License
1 stars 1 forks source link

Have listen-to-other-voicemails mode play more than one voicemail #6

Open fureigh opened 10 years ago

fureigh commented 10 years ago

To replicate: Call the number, then press "2" to listen to other people's voicemails.

Current behavior: A random voicemail is played. Then it repeats indefinitely.

Desired behavior: A random voicemail is played. Then a different voicemail is played. Then a different one.

daguar commented 10 years ago

Thanks @fureigh -- this is definitely definitely next on the list for me.

One clarification: the current behavior is not that one voicemail repeats indefinitely. It is simply calling Voicemail.random every time.

Because Voicemail.random plays back a random message -- agnostic on whatever was just played -- it is likely to repeat often given a small number of voice messages.

That said, you're definitely spot-on that the desired behavior is that it not repeat during a given call at all.

There's two ways I see to do this:

1. Use Cookies

Twilio makes it stupid-easy to store stuff in session cookies, so we could simply do that.

When a voicemail is played back, its ID would be added to session, and then when a next one goes to be played, the query would only look for voicemails with an ID not in the array of voicemail IDs stored in the cookie.

2. Use HTTP (URL params + responses) for more RESTful behavior

This is a little bit better design -- a given URL is clearer on what will happen -- and is also an interesting way to play with RESTful design with a relatively small case.

Let's say a user has played back two voicemails, with IDs of 2 and 3. They would then hear "playing another message", and be redirected to /random?ignore=2,3. That URL, in turn, would yield a redirect to a random voicemail that is not 2 or 3.

(Side note: to actually make this RESTful, it'd be best to modify the "random voicemail" resource to have a URL of /voicemail/random, which I'll note here but for which I'll open a new ticket if this seems like a good idea.)

Any interest in pairing on this @fureigh?

fureigh commented 10 years ago

Sure, I'd be interested in pairing on this! Another approach would be to start with a random voicemail and then play the ones after it sequentially... probably more fun to use the second approach you mentioned, though.