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.
Related
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.
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.
I am trying to receive information from a telnet connection in Lua using LuaSocket. I have all of that up and running except when I receive, if I receive anything less than the maximum number of bytes it takes 5 seconds. If I receive anything more than the number of bytes on the screen it takes upwards of half an hour.
My current idea for a solution is to try receiving for instance 750 bytes, then if that doesn't work within 6-7 seconds do 700 bytes, then 650 and so on until I can receive it very quickly. I need to parse the information and find two specific phrases, so if it's possible to do that inside of my telnet connection and just return that instead of the entire screen that would work as well. I also don't need ALL of it, but I need as much of the received information as possible to raise the chances that my information is in that block of it, hence why I'm only decrementing by 50 in my example.
I can't find any functions that allow you to start reading something (doing a function) and then quit it after a certain time interval. If anybody knows how to do this, or has any other solutions to my problem, let me know please! :) Thanks!
here is what I need repeated:
info = conn:receive(x)
with x decrementing each time it takes longer than 6 seconds to complete.
The solution you are proposing looks a bit strange as there are more straightforward ways to deal with asynchronous communications. First of all, you can use settimeout to limit the amount of time that send and receive calls will wait for the results (be careful as receive may return partial results in this case). Second option is to use select which allows you to check if a socket has something to read/write before issuing a blocking command.
I am new to Twilio and was reading that the limit is 1 SMS per Second per Number.
If you have more phone numbers, then the overall sending rate increases.
My question is if we need to specify multiple numbers in the code in order to take advantage of the increased rate with having more numbers, or is this taken care of automatically by Twilio, even when I specify only one number in the code?
It is not clear if I manually have to Round Robin across all my numbers myself, or if Twilio does this for us.
I am using PHP to do this.
Twilio evangelist here.
You will have to write the code that round robins across all of the numbers in your account. This should be pretty straight-forward.
What I would do is put all of those numbers in an array (you can use the REST API to get the list of all of your Twilio phone numbers), and then in your message sending loop, just use a counter to keep track of your place in that array. Once that counter reaches the array size, just reset it to 0 to start over at the beginning of the array.
Hope that helps.
Over the years the answer to this question has changed. There is now a Twilio service called Copilot which enables all kinds of number intelligence. See the docs here for examples of how to use it. That docs page lists it as a "public beta" (though it also suggests sending API queries to the 2010 version of their API, so it seems a bit outdated).
Edit: Be sure to read the docs regarding the response, since the Copilot behavior is different than the standard message sending behavior:
There is a slight difference in API response when specifying the MessagingServiceSid parameter. When you only specify the From parameter, Twilio will validate the phone numbers synchronously and return either a queued status or an error. When specifying the MessagingServiceSid parameter, Twilio will first return an accepted status.
Would like to maintain a local record of the price of all the phone calls that my application makes.
Am not sure what a good pattern for this would be. It looks like the price is not available in the arguments provided during the status call back when the call is closed. I assume this means I'll need to query Twilio's servers to find the price of the call. Can I do this immediately or do I need to wait a certain amount of time for the price to populate?
Is there another pattern that would be simpler, require fewer steps, or be less error prone that I am not seeing here?
Thanks!
Twilio evangelist here.
I'd recommend checking out the Usage Records API. These handy API's give you an easy way to get rollup data for your account, like how much your account spent yesterday, or how many outbound calls it made.
You can also set up Usage Triggers to proactively notify you when threshholds are met.
Hope that helps.