when we make call using rest api then what twiml we use on that url parameter

让人想犯罪 __ 提交于 2019-12-02 09:02:52

Twilio evangelist here.

The value of the url parameter should be a publicly accessible URL that returns TwiML containing the instructions that you want Twilio to execute to the caller.

Your PHP to start the call would look like:

// Initiate a new outbound call
$call = $this->client->calls->create(
    "num2",
    "num1",
    array("url" => "http://example.com/answer.php", 'IfMachine'=>'Continue')
);

Then in answer.php, you can do two things:

  1. Check the AnsweredBy parameter to see if Twilio detected a machine or a human.
  2. Generate the Twiml you want to return based on that value

For example to say something different to a machine v a human, you could do something like this in your PHP:

<?php
    header("content-type: text/xml");
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<?php if ($_REQUEST['AnsweredBy']=='machine'): ?>
    <Response>
        <Say>Hello machine</Say>
    </Response>
<?php else: ?>
    <Response>
        <Dial>+15555555555</Dial>
    </Response>
<?php endif ?>

Hope that helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!