OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Automatic Machine Detection workflow is different when used under <Dial><Number> vs when used in an outbound call using API

  • Thread starter Thread starter paul_glad
  • Start date Start date
P

paul_glad

Guest
I cannot control the flow of a call created using Dial keyword inside of amdStatusCallback webhook I provide in the Number tag. I'm using C# Twilio library and Voice JavaScript SDK. Apologies for the long one in advance.

Use case:

  1. Start a call from browser to a phone number:
  2. When the called party picks up I want AMD to work, then:

2.1. If the result is human or unknown, a message should be said, stating that continuing the call indicates the called party's consent to be recorded. Then it should connect the caller in browser and the callee.

2.2. machine-start: no point in asking for consent, so it should connect immediately for the caller to leave a message.

2.3. fax: just disconnect. I'll let the caller know it's a fax.

The perfect scenario would be if there was asyncAMD flag in Number keyword like it exists in CallResource.CreateAsync, and the call would go the 2.1 route by default and change after, but for some reason there's no such thing. I can live with that though, it's not the main issue.

Here's what happens:

  • Twilio.device is initiated correctly with a token that contains a reference to a TwiML App on my account;
  • A request is made to the webhook from the TwiML App;
  • Here's the response:

Code:
<Response>
    <Dial callerId="{myTwilioPhoneNumber}" record="record-from-answer" answerOnBridge="true" ringTone="us">
        <Number machineDetection="Enable" amdStatusCallbackMethod="GET" amdStatusCallback="{amdUrl}" machineDetectionTimeout="5">*phone-number*</Number>
    </Dial>
</Response>

Here's what I tried to do in amdUrl:

  • Respond with a Say TwiML instruction. But it is completely ignored.

Code:
<Response>
    <Say language="en-US">Very long message stating that continuing the call indicates your consent to be recorded</Say>
</Response>
  • Send the same TwiML instuction using CallResource.UpdateAsync. Both using twiMl parameter and as a response to another webhook I provided in the url parameter. It worked BUT the call gets disconnected from the twilio device in browser. I tried to add <Dial><Client>{voiceSdkDeviceId}</Client></Dial> or <Dial><Client><Identity>{voiceSdkDeviceId}</Identity></Client></Dial> after the Say to at least somehow connect them back but it also didn't work. I see the child call created in the logs but it ends with No Answer. I double-checked the device id multiple times, I call device.register() in my JS, I see the registered event fired.

When I created outbound calls using CallResourse.CreateAsync for another task, I enabled AMD there as well, and it worked just as described in this tutorial. It's a very unpleasant surprise that it doesn't work like this using Dial.

Before I enabled AMD I had a webhook that responded with the same Say instruction. I provided url to it in the Number tag and had the message said while hearing ringing in browser and then got connected. But if the call goes to voicemail, the consent message may easily be longer than the voicemail's greeting and still be playing after the beep. So the caller would have no idea it went to voicemail, and the callee would receive a message that starts in the middle of the consent message followed by confused silence of the caller. I'd really like to avoid it. Please help.

<p>I cannot control the flow of a call created using <code>Dial</code> keyword inside of <code>amdStatusCallback</code> webhook I provide in the <code>Number</code> tag. I'm using C# Twilio library and Voice JavaScript SDK. Apologies for the long one in advance.</p>
<p>Use case:</p>
<ol>
<li>Start a call from browser to a phone number:</li>
<li>When the called party picks up I want AMD to work, then:</li>
</ol>
<p>2.1. If the result is <code>human</code> or <code>unknown</code>, a message should be said, stating that continuing the call indicates the called party's consent to be recorded. Then it should connect the caller in browser and the callee.</p>
<p>2.2. <code>machine-start</code>: no point in asking for consent, so it should connect immediately for the caller to leave a message.</p>
<p>2.3. <code>fax</code>: just disconnect. I'll let the caller know it's a fax.</p>
<p>The perfect scenario would be if there was <code>asyncAMD</code> flag in <code>Number</code> keyword like it exists in <code>CallResource.CreateAsync</code>, and the call would go the 2.1 route by default and change after, but for some reason there's no such thing. I can live with that though, it's not the main issue.</p>
<p>Here's what happens:</p>
<ul>
<li>Twilio.device is initiated correctly with a token that contains a reference to a TwiML App on my account;</li>
<li>A request is made to the webhook from the TwiML App;</li>
<li>Here's the response:</li>
</ul>
<pre><code><Response>
<Dial callerId="{myTwilioPhoneNumber}" record="record-from-answer" answerOnBridge="true" ringTone="us">
<Number machineDetection="Enable" amdStatusCallbackMethod="GET" amdStatusCallback="{amdUrl}" machineDetectionTimeout="5">*phone-number*</Number>
</Dial>
</Response>
</code></pre>
<p>Here's what I tried to do in <code>amdUrl</code>:</p>
<ul>
<li>Respond with a <code>Say</code> TwiML instruction. But it is completely ignored.</li>
</ul>
<pre><code><Response>
<Say language="en-US">Very long message stating that continuing the call indicates your consent to be recorded</Say>
</Response>
</code></pre>
<ul>
<li>Send the same TwiML instuction using <code>CallResource.UpdateAsync</code>. Both using <code>twiMl</code> parameter and as a response to another webhook I provided in the <code>url</code> parameter. It worked BUT the call gets disconnected from the twilio device in browser.
I tried to add <code><Dial><Client>{voiceSdkDeviceId}</Client></Dial></code> or <code><Dial><Client><Identity>{voiceSdkDeviceId}</Identity></Client></Dial></code> after the <code>Say</code> to at least somehow connect them back but it also didn't work. I see the child call created in the logs but it ends with <code>No Answer</code>. I double-checked the device id multiple times, I call <code>device.register()</code> in my JS, I see the <code>registered</code> event fired.</li>
</ul>
<p>When I created outbound calls using <code>CallResourse.CreateAsync</code> for another task, I enabled AMD there as well, and it worked just as described in <a href="https://www.twilio.com/en-us/blog/async-answering-machine-detection-tutorial" rel="nofollow noreferrer">this tutorial</a>. It's a very unpleasant surprise that it doesn't work like this using <code>Dial</code>.</p>
<p>Before I enabled AMD I had a webhook that responded with the same <code>Say</code> instruction. I provided url to it in the <code>Number</code> tag and had the message said while hearing ringing in browser and then got connected. But if the call goes to voicemail, the consent message may easily be longer than the voicemail's greeting and still be playing after the beep. So the caller would have no idea it went to voicemail, and the callee would receive a message that starts in the middle of the consent message followed by confused silence of the caller. I'd really like to avoid it. Please help.</p>
 

Latest posts

Online statistics

Members online
1
Guests online
5
Total visitors
6
Top