I want to create the following:
- A line number, let's say 741-SUPPORT (just an example), where people can call.
- When somebody calls, I want them to listen some text (I use
<Say>
) and then, forward their call to my number. - When I receive the call, I want to listen to a text that announces me that this call comes from that line, and allows me to press 0 to accept de call, or any other number to reject it.
- In case that I accept, both calls get connected. Otherwise, the caller should be able to leave a message.
What I've done so far:
First TWIML used when the caller calls to 741-SUPPORT
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say voice="alice" language="en-US">
This call is being recorded.
Please hold on, your are being connected.
</Say>
<Dial action="CallEnded.php" timeout="15" timeLimit="600" callerId="+1741SUPPORT" record="record-from-answer">
<Number action="JoinCall.php">+PRIVATE NUMBER HERE</Number>
</Dial>
</Response>
JoinCall.php
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather timeout="10" numDigits="1" action="CallAccepted.php">
<Say voice="alice" language="en-US">
You have an incomming call from 741SUPPORT.
Press 0 to accept the call, press any other number to reject the call.
</Say>
</Gather>
</Response>
CallAccepted.php
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<?php if ($_POST['Digits'] == '0') { ?>
<Say voice="alice" language="en-US">
Call accepted.
This call is being recorded.
</Say>
<?php } else { ?>
<Say voice="alice" language="en-US">
Call will be rejected.
</Say>
<Hangup/>
<?php } ?>
</Response>
CallEnded.php
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say voice="alice" language="en-US">
<?php if ($_POST['DialCallStatus'] != 'completed') { ?>
We had issues connecting the call, please try again later.
<?php } else { ?>
Thanks for your call. Goodbye!
<?php } ?>
</Say>
</Response>
So I would like to know:
- How can I play hold music on the caller's side while all the logic is performed?
- How can I disconnect from the call and ask the caller to leave a message?