3
votes

It is possible to initiate call from extension? My extension is look like the following:

[read_text]
    exten => s,1,Answer( )
    exten => s,n,Dial(SIP/1,G(99))
    exten => s,n,Dial(SIP/2,G(99))
    exten => s,n,Goto(1)
    exten => s,100,System(echo '${text}' | /usr/bin/espeak  --stdout |sox -t  wav - -r 8000  /tmp/voice.wav)
    exten => s,n,Playback(/tmp/voice)
    exten => s,n,System(rm /tmp/voice.wav)
    exten => s,n,Hangup( )

So if SIP/1 or SIP/2 answers, It plays text and hangup, if nobody answer it continues to Dial I tried to make call file, but it requires some channel to be setup, I tried to use Local, but unsuccess. I also found that there are queues, but can't find a way to initiate call to queue from call file. I'm very new to asterisk.

1

1 Answers

3
votes

What your trying to do can get pretty messy from the dialplan. Try something along these lines:

[call_read_text]
exten => s,1,Dial(SIP/1,gG(read_text,s,1))
exten => s,n,Dial(SIP/2,gG(read_text,s,1))
exten => s,n,Goto(1)

[read_text]
exten => s,1,System(echo '${text}' | /usr/bin/espeak  --stdout |sox -t  wav - -r 8000  /tmp/voice.wav)
exten => s,n,Playback(/tmp/voice)
exten => s,n,System(rm /tmp/voice.wav)
exten => s,n,Hangup()
  • Dont answer the call before you start!
  • g will continue in the dialplan if the call isn't answered, and call the next extension
  • G() will jump to read_text,s,1 if the call IS answered, and end the hunt
  • You can jumpstart all this with a call file, by connecting the first context with the second (will happen on answer).

Something along these lines:

Channel: Local/s@call_read_text
Context: read_text
Extension: s
Priority: 1

More on call files here: http://www.voip-info.org/wiki/view/Asterisk+auto-dial+out. Use Set: foo=bar in the call file to set ${text}