Prevent twilio from calling after hours - twilio

I have an application that is not allowed to call people after 8 PM (TCPA). I push calls in batch. Twilio makes 1 call per second roughly. I want to prevent twilio from accidentally pushing calls after 8 PM local time to the area code called.
What is the approach to do this?

Twilio developer evangelist here.
I'm afraid Twilio doesn't have anything "out of the box" that can help you there. Twilio will continue to make all the calls that you have pushed to it.
You could keep a record of all the calls that you have pushed, you receive the call SID in the response to creating a call, and then as it comes close to your cutoff time for those calls, send requests to cancel them.
Alternatively, rather than sending the calls to Twilio in large batches, why not use smaller batches that you can more easily estimate the time they will take to be sent and then stop sending calls for those areas at the right time. For example, if you sent calls in batches of 60, you can be reasonably sure they will take 60 seconds for all of them to be made. You can then stop sending calls at 7:59pm.

Related

Twillio Enqueue / Dequeue (or conference) Multiple callers

I am building an "overflow" queue of sorts for a call center. I'll spare you the logical reason and pitfalls of the current call center, but this is the task at hand.
I've taken the following steps:
(1) Create a flow in Twilio studio (to manage some inputs, etc, as well as enqueue the caller)
(2) Handle reservations by conferencing with the outbound (cell center) number.
There are two apparent issues:
(1) When a second call goes into the queue, it comes in without a reservation (because my one worker is on the "first" call??)
(2) I can essentially continually route folk in the queue to the call center until somebody picks up... however, with Taskrouter, it matches the one worker and the other calls are just stuck in the queue.
Ideally the final functionality would be that anybody in the queue hears the hold music until they are connected to the call center (which has a significant capacity for concurrent calls). I might be overthinking it, but (for example) if 50 calls were in queue, and only one worker - what happens to the 49 calls while the "worker" accepts the reservation? Would I need to create 50 workers? It seems like a bulky workaround, but there has to be a solution by all of you Twilio wiz's out there!
I am handling an assignment callback via Flask app, so that is able to handle the reservation and conference it... however, it can only do this with the first call (and worker) while other calls stack up without a reservation.
Any information is appreciated!
this was actually fairly easy once I was able to grasp the concept (for anybody that is interested).
For this specific application, task router and the 'conference' instruction (given to the assignment callback) handle connecting the inbound call to the outbound call center - if and only if the call center connects is the conference created. Otherwise, it will find the next available worker (ie call center) and attempt the same process.
Here is a simple conference instruction for your callback URL (in response to a new task):
ret = '{"instruction": "conference", "timeout": "300"}'
resp = Response(response=ret, status = 200, mimetype = 'application/json')
Then, you can either programmatically manage workers, tasks, attributes, etc. The conference instruction handles a lot of the heavy lifting as far as ensuring connections between the inbound and outbound calls, as well as corner cases.

Delaying or sorting REST API triggered outbound IVR calls outside of allowed TCPA time?

We will be sending requests for outbound calls via REST API to Twilio Studio via batch each morning. However, the order in which they are sent is arbitrary, and some called parties will be in time zones in which, calls should not be made at that time (e.g. calling PST time zones at 8:00AM EST). How can we deal with this? I could put in a split based on the State, which would be known. However then what? Could I include a loop based on a time check? If so, it is conceivable that the number of called parties waiting for their time zone to become eligible would exceed the number of concurrent outbound calls which are allowed. Would this then prevent normally eligible calls from being placed, or do flow executions not count towards this limit unless a call has already been placed?
I had thought about storing the queued requests in Sync, and executing them based on the State criteria in conjunction with a time check function. However, I'm not sure if this would even work.
Is there some means of sorting, or otherwise selecting queued API requests based on a criteria?
Any help would be appreciated. Thank you!
The decision on when to place the call would be determined outside of Twilio.
You would first identify which timezone the customers are in and group those based on Pacific, Mountain, Central, Eastern, say using the address within your CRM - which is safer then using their area code.
Then, once the time is appropriate for that timezone, you would make a call to the Twilio Studio Executions end-point to place each of the calls.
You can monitor queue_time to determine how many milliseconds a call remains in the queue before being placed, in case you need to increase you CPS (or slow down your calling) and to avoid abnormally large queues resulting in calls placed outside allowed business hours.
So, in short, the queueing logic is handled on your side rather then on Twilio's side.
Because of our specific use case, it is desirable to have the functionality self-contained. We prioritize inbound calls and the call volume varies, so the number of concurrent calls placed by the outbound IVR is very low. This means that a call can be queued for an extended period of time, and our allowed calling window may expire. Therefore, we must make this check immediately prior to making the attempt
I was able to resolve this with a function which checks the current time via a new Date().toISOString() and adds or subtracts the offset based on the time zone of the called party.

twilio gather significant delay in speech2text processing

I'm using TwilioML to collect user's input.
What I'm seeing is a significant delay 4-6 sec. from the time the user stop speaking to the time my service ( endpoint) is called. This happens even with very simple sentences (ex. my name is john).
Is this a known issue? From a user experience point of view it is not a great experience.
I tried to add a 'filler' via but it does not have any effect because the earlier I can get it started is when the endpoint is called.
Maybe there is a way to play a file in parallel while the the audio is converted to text.
From the documentation:
The 'timeout' attribute sets the limit in seconds that Twilio will
wait for the caller to press another digit or say another word before
moving on and making a request to the 'action' URL. For example, if
'timeout' is '3', Twilio will wait three seconds for the caller to
press another key or say another word before submitting the previously
entered digits or speech to the 'action' URL. Twilio waits until
completing the execution of all nested verbs before beginning the
timeout period.
The fact you are seeing a delay of between 4 and 6 seconds is probably explained by the fact the default timeout setting is 5 seconds.
Have you tried using a partialResultCallback URL? If set Twilio will submit results of speech recognition in real time to this URL. It's also worth adding hints if you are expecting callers to say certain words as this can speed up the recognition.

Can twiml set a rate limit on responses?

I have a number set up with a small twiml script (using twimlets). I want to have it stop responding for a bit if it's overused. For example if it's dialed 5 times in 1 minute it should wait 3 minutes before responding again. Is this possible with twiml/twimlets or would I need to move it to my own server and set up some code to detect this?
Twilio developer evangelist here.
Unfortunately I you't be able to set a rate limit just with TwiML. You could set a time limit for each call, but that wouldn't really accomplish exactly what you want.
My suggestion would be moving it to your own server where you will then be able to have full control of what your pages return, therefore showing different content according to the number of times it's been requested.
You can probably just spin up a free Heroku instance that will make things easier for you. This page shows you how to do that and much more.

How to grab a list of only active calls and active queues from Twilio

How do i grab only active queues while incoming call to my twilio number.Is there any way to filter only latest queues and update those queues order.
Twilio evangelist here.
I guess this depends on what you mean by "Active". If you mean, Queues that have calls waiting in them, there is not currently a way to have Twilio give you just that list.
You can ask Twilio to give you a list of Queues and then your application can filter that list using the CurrentSize parameter.
If you want to dequeue callers in a order other than the default FIFO behavior seen when you <Dial> a call into a <Queue>, you can use the REST API to dequeue a specific call:
https://www.twilio.com/docs/api/rest/member#instance-post-example-2
If that still does not give you enough control for your scenario you can always fall back to using a simple <Conference> instead of a <Queue>. In that case you would add calls to a conference in a muted state, and your application would be responsible for tracking what calls are in the conference, how long they have waited and what order they arrived.
Hope that helps. If I've misunderstood what you mean by Active, please let me know.

Resources