-1

I want a simple script that will allow me to:

  • Answer the incoming phone (from Intercom)
  • Automatically press "9"
  • Hangup the call

I have an intercom which calls to my number and I have to answer it then press 9 to door to be opened and hangup. I want to implement this with twilio but can't find any solutions.

Any suggestions?

1 Answers1

2

Twilio evangelist here.

Just to make sure I understand your question, you want your intercom to call your Twilio number and have Twilio "press 9" and then hang up. Assuming I have that right it should be pretty simple to do.

You're going to use the <Play> and <Hangup> TwiML verbs and return something like this Twilio in response to our Voice Request:

<Response>
    <Play digits="9" />
    <Hangup />
<Response>

if you need to add some time between when the call is answered and the tone is played, you can do something like this:

<Response>
    <Play digits="wwww9" />
    <Hangup />
<Response>

Each w character tells Twilio to pause for .5 seconds, so in this sample there is a 2 second delay before the tone is played.

Hope that helps.

Devin Rader
  • 10,260
  • 1
  • 20
  • 32
  • Thank you so much for the answer. Yes this is exactly what I need. One more thing. If I want to put filter by caller ID, like when "x" number calls "press 9" and when "y" number calls "press 6" How's that possible? – Hovig Zoubrigian Oct 04 '14 at 15:56
  • To do that you're going to need to write some code. As part of the HTTP request that Twilio makes to get the TwiML, we pass parameters including the phone number that the call is coming from. You can write a script using something like PHP (or whatever language you want) to grab that parameter, evaluate it and change the TwiML that gets returned. – Devin Rader Oct 04 '14 at 18:53