Twilio Flow change handle long HTTP requests

45 Views Asked by At

i'm using Twilio flow to make an HTTP request to my API GW on AWS. My endpoint can take more than 10 seconds to complete, and so I'm getting timeouts from the Twilio Flow Make HTTP Request widget. I couldn't find a way to extend this timeout, nor a way to create a "delay" in the flow (and then I would have change my API to be async, and make the flow poll for a response).

Any ideas how I can overcome this issue?

1

There are 1 best solutions below

1
jassent On

You could do something like this:

  1. HTTP Request widget requests the data from your Server.
  2. Your Server immediately responds with a Status Code 200 with a unique identifier in the body. Your Server begins to process the request asynchronously and returns the final result to a temporary table or blob (or wherever you can retrieve later).
  3. Twilio Studio plays an audio file for 10 seconds.
  4. Twilio Studio checks the temporary table or a blob for a result with the unique identifier. If there is no result, then go to step 3. If there is a result move to Step 5.
  5. Twilio Studio does something with the result.

You could use a variable to keep track of how many attempts have been made and give up after X number of tries.

You could also do this:

  1. HTTP Request widget requests the data from your Server.
  2. Your Server immediately responds with Twiml to tell Twilio to play a 5 minute audio file to the caller.
  3. Your Server continues to process the request and when it is done it issues a request to the Twilio REST API to return control of the call to Twilio Studio.

Good luck!