Search code examples
krl

Kynetx twilio:place_call


According to the docs I should be able to have Twilio initiate a call for me with

twilio:place_call( "3125551212", "7735551212", somewebhook);

I can't seem to get it working quite right. Does the webhook need to be there, and if so what should it respond with? I just want to initiate a phone call and have it connect me with my phone- I don't need any other Twilio intervention.

UPDATE:

Okay I think I got it worked out. The webhook (which I'm just putting into KRL) just needs this: twilio:dial("7735551212"); where that number is my number. So the person receiving the call from me will have a few seconds of dead air pause when they first pick up. To help with that, I'm also prepending it with this twilio:say("Hi, one moment please"); Here's the final rule:

rule twilconnect is active {
select when twilio twilconnect                     
{
    twilio:say("Hi, one moment please");        
    twilio:dial("7735551212");
}

}

And the rule that initializes everything looks like this:

rule makethecall is active {
  select when web make_the_call
  pre {
    tocall = event:param("tocall");
  }

  {         
    notify("Calling " + tocall,"...");
    twilio:place_call( tocall, "+17735551212", "http://webhooks.kynetxapps.net/t/{appid}/twilconnect");       
  }

}


Solution

  • You seemed to have answered your own question, but here seems to be the issue that confused you.

    The twilio module's place_call() action is used when you need to initiate a new outbound call when there isn't already a call.

    When you want to have an already in process call that you want to connect to an external number, you want the dial() action.