twilio: voicemail and forwarding combined using twimlets - sms

I am new to twilio and am just trying a couple of things out. I had the case for voicemail as this:
http://twimlets.com/voicemail?Email=myemailaddress#yahoo.com&Message=please%20leave%20a%20message&Transcribe=true&
the case for forwarding was this
http://twimlets.com/forward?PhoneNumber=1115551212
How would I combine these two so that first it does the forwarding and then if there are no answers it does the voicemail? Or would I need a php code snippet to do this?
Appreciate any hints...

You can chain Twimlets to do what you want. One of the options for the forward Twimlet is a failURL which will be called if there is no answer before your specified timeout, so you just add your voicemail link there.
Using your examples and adding a 30 second timeout before it diverts to voicemail give you this:
http://twimlets.com/forward?PhoneNumber=1115551212&Timeout=30&FailUrl=http%3A%2F%2Ftwimlets.com%2Fvoicemail%3FEmail%3Dmyemailaddress%40yahoo.com%26Message%3Dplease%2520leave%2520a%2520message%26Transcribe%3Dtrue%26&

Related

Ruby Bunny exchange wait_for_confirm or die

What would be the best way to incorporate something similar to the RabbitMQ channel.waitForConfirmsOrDie() method, while utilizing the Bunny gem for a publish confirmation?
Right now I am using:
if !#channel.using_publisher_confirmations?
#channel.confirm_select
end
#channel.default_exchange.publish(args)
was_successful = #channel.wait_for_confirms()
But ideally, for the scenario I need, I would like to have a much shorter timeout on waiting for the confirmations. Right now, it seems as though there is a default timeout of roughly 15 seconds, but that is far too long to block the thread. If I don't receive confirmation within, say, three seconds, what I'd like to have happen is raise an exception/return false.
I saw there was a waitForConfirmsOrDie() in the RabbitMQ documentation, but Bunny does not have this as a method available.
Am I considering rewriting some methods for similar functionality. Has anyone come across something similar and found a good way to implement this?
Don't wait for confirms synchronously. You should use a technique similar to this to keep track of outstanding confirms and handle them.
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.

Phones won't stop ringing with Twilio Taskrouter

I've been trying to implement a call centre type system using Taskrouter using this guide as a base:
https://www.twilio.com/docs/tutorials/walkthrough/dynamic-call-center/ruby/rails
Project location is Australia, if that affects call details.
This system dials multiple numbers (workers), and I have run into an issue where phones will continue to ring even after the call has been accepted or cancelled.
ie. If Taskrouter calls Workers A and B, and A picks up first they are connected to the customer, but B will continue to ring. If B then picks up the phone they are greeted by a hangup tone. Ringing can continue for at least minutes until B picks up (I haven't checked if it ever times out).
Similar occurs if no one picks up and the call simply times out and is redirected to voicemail. As you can imagine, an endlessly ringing phone is pretty annoying, especially when there's no one on the other end.
I was able to replicate this issue using the above guide without modification (other than the minimum changes to set it up locally). Note that it doesn't dial workers simultaneously, rather it dials the first in line for a few seconds before moving to the next.
My interpretation of what is occurring is that Taskrouter is dialling workers, but not updating them when dialling should end, and simply moving on to the next stage of the workflow. It does update Worker status, so it knows if they've timed out for instance, but that doesn't update the actual call.
I have looked for any solutions to this and havent found much about it except the following:
How to make Twilio stop dialing numbers when hangup() is fired?
https://www.twilio.com/docs/api/rest/change-call-state
These don't specifically apply to Taskrouter, but suggest that a call that needs to be ended can be updated and completed.
I am not too sure if I can implement this however, as it seems to be using the same CallSid for all calls being dialled within a Workflow, makes it hard/impossible to seperate each call, and would end the active call as well.
It also just seems wrong that Taskrouter wouldn't be doing this automatically, so I wanted to ask about this before I tinker too much and break things.
Has anyone run into this issue before, or is able/unable to replicate it using the tutorial code?
When testing I've noticed the problem much more on landline numbers, which may only be because mobiles have their own timeout/redirects. VOIPs seem to immediately answer calls, so they behave a bit differently.
Any help/suggestions appreciated, thanks!
Current suggestion to work around this is to not issue the dequeue instruction immediately, but rather issue a Call instruction on the REST API when the Worker wishes to accept the Inbound Call.
This will create an Outbound Call to bridge the two calls together and thus won’t have many outbound calls for the same inbound caller at once.
Your implementation will depend on the behavior that you want to achieve:
Do you want to simul-dial both Workers?
Do you want to send
the task to both Workers and whoever clicks to Accept the Task first
will have the call routed to them?
If it's #2, this is a scenario where you're saying that the Worker should accept the Reservation (reservation.accepted) before issuing the Call.
If it's #1, you can either issue a Call Instruction or Dequeue Instruction. The key being that you provide a DequeueStatusCallbackUrl or CallStatusCallbackUrl to receive call progress events. Once one of the outbound calls is connected, you will need to complete the other associated call. So you will have to unfortunately track which outbound calls are tied to which Reservation, by using AssignmentCallbacks or EventCallbacks, to make that determination within your app.

How can I make my internet slower?

No really.
I have a lot of AJAX requests in my web app, and I want to include appropriate feedback mechanisms, spinners and the like for when the response is slow. But when developing all the calls are almost instant...
Using setTimeout inside your success handler can be one way. Suppose your callback for ajax completion is say function doneFn(..), then, change that callback to something like delayedDone(..) and from there call your original doneFn after a delay:
function delayedDone(){
setTimeout(function(){doneFn(responseParams);}, 3000);
}
And of course, another way would be to introduce some tiny milliseconds of sleep on the server side.
Here are two software solutions I have found - one for Mac and one for Windows:
http://wanem.sourceforge.net/
http://mschrag.github.com/
A rate limiting proxy might be what you're looking for. http://blog.nella.org/?p=833 shows an example, I'm not sure how complete it is. But the concept can easily be expanded on.

Ambiguous MVC Route Resolver UI

I'd like to create a UI for times when there is an ambiguous routing. For example suppose I have a domain called ping.com and I want to have the urls
http://ping.com/10.3.2.4
and
http://ping.com/hostname.com
I'd like to show an AJAX UI that shows that I'm seeing if it's an IP address, then if it's a hostname, etc. I'd also like to refresh resolution progress, get a report of what worked what didn't.
The purpose is to educate the
end user who is hacking my urls, to do
it right, and to slow down invalid
attempts.
Of course in this over simplified example I could transparently redirect to the right controller, but in a more complex resolution example, this may be helpful.
How would you approach this problem? What technologies would be involved?
I would probably punch everything through to a controller who's job it is to sort this stuff out and serve the correct view.
If I had to do it using routing, you could get pretty close with some route constraints limiting the "ping url" controller to pinging things that looked like IP addresses, etc. I guess one could get as far as going into custom route constraints and such, but if you are going that far, you might as well just make a controller . . .

AJAX Real Time and collaborative

I am trying to create real-time and collaborative application like - google wave for example.
When user1 writes something at the same time it shows on user2 screens.
I started a little research,and found some ways to this with Ajax -
1.every X seconds send request to the server and to check what is "happening"
2.timeout - long request ,Problem - I saw i can do this only with IE8
there are other options?what is the best way to this?
And with way number 2,this true I can do this only with IE8?
Yosy
The whole point of AJAX is that the server can wait for notifications from each clients, and notify all the other clients when something happens. There's no need for polling. Look up keywords like comet, and bayeux. Dojo has a good implementation.
I'm not sure what you are referring to in 2, but if I were going to implement something like this, I'd do what you explain in 1. Basically your server will be keeping track of the conversation, and the clients will constantly ask for updates.
Another possible option would be flash, but I don't know much about that other than it would be capable, so your on your own for researching that.
Some notes on keeping things running quickly in option 1:
Remember you only have 2 "ajax"
calls to work with on the client side (you can only have 2 calls
out at once). So keep track
of the calls that are out. Make use
of abort() if a call takes too long or its response is not going to be valid anymore.
Get the most out of your calls, if
you need to send text to the server,
use the response to get an update on
the current "conversation".

Resources