Twilio asyncAMD callback url invoked before initial Twiml prompt finishes

260 Views Asked by At

To set this up, here is the use case:

  • IVR system calls someone and reads a long-ish twiml prompt at them (about 251 characters)
  • at the end of the prompt gather user input
  • if a non-human answers the phone, I'm using asyncAMD callback to get the result of AMD and then leave a voice message

I am currently placing an outbound call using this code:

var call = CallResource.Create(
    machineDetection: "DetectMessageEnd",   
    asyncAmd: "true",
    asyncAmdStatusCallback: new Uri("[URI to callback]"),
    asyncAmdStatusCallbackMethod: HttpMethod.Post,      
    twiml: new Twilio.Types.Twiml("<Response><Say>[MyMessage]</Say></Response>"),       
    from: new Twilio.Types.PhoneNumber(configuration["fromPhoneNumber"]),
    to: new Twilio.Types.PhoneNumber(configuration["toPhoneNumber"])
);

where "MyMessage" is about 251 characters long.

The answering machine bit works wonderfully, and I'm able to leave a voice message in case a non-human answers (see my question and subsequent answer for How to leave a voicemail using Twilio AMD? for details).

However, I cannot for the life of me figure out how to prolong the asyncAMD callback long enough for the initial prompt to be finished in the case a human answers.

I've tried adding all of these optional API tuning parameters, and I still can't get it to work:

machineDetectionTimeout: 59,
machineDetectionSpeechThreshold: 6000,
machineDetectionSpeechEndThreshold: 5000,
machineDetectionSilenceTimeout: 10000,

What are my options here? Bail on asyncAMD and use blocking AMD? I need to be able to leave a voice message in case of a non-human answering, but I need to push the results of the asyncAMD invoking it's callback long enough for the initial response to be read in a human answers.

1

There are 1 best solutions below

0
Michael McCarthy On

I'm going to take this approach. In the recipient answers and says "hello" (which is likely they'll say it), answeredBy will return "human", but if they don't and just listen to the initial prompt, I get "unknown" back. At this point, I'm going to treat an answeredBy "unknown" as a person answering and listening to the initial Twiml prompt.