2

I'm trying to record in-call audio tehn process it and say the results back to the caller solely using Twilio.

For the <Record> TwiML element I can provide a separate callback URL after recording complete (action parameter, thus the call handling will be transferred there) and one after recording stored.

There are two problems arising here.

First, the processing of the recorded audio can take arbitrary amount of time so I can easily run out of the 5s limit (fortunately not in my case)

Second, I need to interchange data between those two callbacks. Since these two callbacks are executed separately, the memory isn't shared between them. I found no API for storing any persistent data using Twilio, so it looks like that I need to rely some third-party database service.

Can I acchive this somehow without relying on any external service for handling those callbacks?


Note: I found this StackOverflow answer which says that data persistence is impossible on Twilio, but the question asked a different thing. I also hope that the technology has been evolved since then.

lezsakdomi
  • 115
  • 10

2 Answers2

1

I don't know that you can do what you want within runtime functions, but you can do it in Studio as long as you only need the persistence within a single call flow. Studio has "flow variables" that you can set and manipulate within the flow using liquid. I use it to split, concatenate, and transform various inputs. If you wanted data to persist beyond a single call, then you'd need to use something external.

mike
  • 86
  • 5
1

You can use Twilio Sync for persistence across Functions. You can find out more details here.

A simple Sync Document should to what you need.

The Sync REST API

That said, why don't you just use the Gather Input On Call Widget with Speech, as the SpeechResult (the Speech to Text) will be automatically available to you after that widget completes, via the "user said something" flow.

Alan
  • 10,465
  • 2
  • 8
  • 9