0
votes

We have currently developed a phone system for our call centre using Twilio (mainly c#, angular2 and typescript). Our company is currently in the UK but we have now started expanding out to the USA and because of laws in the US it looks like we'd need the ability to choose when we turn on the call recording. In the US people have to consent to recording the call before you can start recording them. I am trying to - when we make an outbound call via twilio to first play a message and get the user to input a key on their dialer to consent to recording the call before continuing with the call. I have attempted to use the gather and say verbs after we have dialled out but this doesn't seem to work. Code below:

`

public override void ApplyAction(TwilioResponse response)
        {
                 var attributes = this.GetAttributes<DialAttributes>("attribute-");
            attributes.callerId = this.PhoneNumber;
            response.Dial(new Number(this.ReceiverPhoneNumber), attributes);
            response.Gather(
              new
              {
                  timeout = 10,
                  finishOnKey = '*'
              });
            response.Say("We record all calls - please press the star key to consent to call recording");

        }`
1
I work at Twilio. That should be the way to do it. Can you share the code, or at least the current call flow, and what exactly isn't working? Thanksphilnash
we have a response builder class that will generate a TwilioResponse depending on direction of the call, phone etc - So for Outbound calls we have an outbound class with the method ApplyAction that will create the twilio response for outbound calls - called off to the Dial and then after that gather and say but it still just dials the call connects and then it doesn't perform the other two actions - i will add the code in the next commentDaniellesmith31
Can you edit your question with the code, it's much easier to read. Thanks!philnash
yes sorry im new to thisDaniellesmith31
In your code, does the <Say> get nested within the <Gather>?philnash

1 Answers

0
votes

Twilio developer evangelist here.

The problem is that you are performing the <Dial> before the <Gather> and <Say>. If you want the user to approve the call first you need to nest the <Say> in the <Gather> and provide an action URL for the <Gather>. When the user presses a button as part of the <Gather> Twilio will make an HTTP request to the action URL with the results in the Digits parameter. Then you should return the <Dial> as the response to that request, if the user signifies agreement. This way you ask them first and then connect the call.

Let me know if that helps.