Twiml - 自动按(数字)和挂断

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?

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.