How to get callerid using asterisk - asterisk

my scenario is below
analog phone (10 to 99)------> pbx------>(77)asterisk--------> jitsi(2000)
i have analog telephone interface numbered 77 attached with asterisk and
other sip user is 2000 on jitsi.
I can call from any number from 10 to 99(in intercom) on 77 and ivr
response will come then i can typed 2000# and call go to 2000 named user
in asterisk.
Now my problem is when i am calling from 10 to 99 (any number) this number
should display to sip 2000's user. But its not showing to user. Its shows
asterisk#my_asterisk_server_ip.
my config. as follow
extension.conf
exten => s,1,Goto(phrase-menu,s,1)
[phrase-menu]
exten => s,1,Answer()
exten => s,2,Wait(1)
exten => s,3,Read(PHRASEID,/var/lib/asterisk/sounds/custom/soip)
exten => s,4,Wait(2)
exten => s,5,Set(CALLERID(num,CID)=${CALLERID})
exten => s,6,Dial(SIP/${PHRASEID},40,tT)
exten => h,1,Hangup()
and in chan_dahdi.conf
; General options
[channels]
usecallerid=yes
hidecallerid=no
callwaiting=yes
threewaycalling=yes
transfer=yes
echocancel=yes
echocancelwhenbridged=yes
cidsignalling=dtmf
cidstart=polarity
callerid=asreceived
rxgain=0.0
txgain=0.0
;FXO Modules
group=1
echocancel=yes
signalling=fxs_ks
context=default
channel=1-20
#include dahdi-channels.conf
any help
thanks..
Thanks a lot...

First of all, exten => s,5,Set(CALLERID(num,CID)=${CALLERID}) is not valid, it should read: exten => s,5,Set(CALLERID(num)=${CALLERID}). Second, setting CALLERID to CALLERID is redundant. Third, are you actually setting the callerid in the first place (that would happen in your default context)?

Related

Asterisk AMD doesn't start on outbound call

Please can you tell me where I am wrong, I am new on Asterisk.
I am trying to detect voicemail on outgoing call (remote provider)
exten => _011225XXXXXXXX,1,Dial(SIP/${EXTEN}#dinstar)
exten => _011225XXXXXXXX,n,AMD()
exten => _011225XXXXXXXX,n,GotoIf($["${AMDSTATUS}" = "HUMAN"]? human:machine)
exten => _011225XXXXXXXX,n(machine),WaitForSilence(2000)
exten => _011225XXXXXXXX,n,Playback(asterisk-friend)
exten => _011225XXXXXXXX,n,Hangup()
exten => _011225XXXXXXXX,n(human),Verbose(3, We've got a human on the line!)
exten => _011225XXXXXXXX,n,Playback(transfer)
exten => _011225XXXXXXXX,n,Dial(SIP/${EXTEN}#dinstar)
exten => _011225XXXXXXXX,n,Playback(im-sorry)
exten => _011225XXXXXXXX,n,Hangup()
Cli print
CLI> == Using SIP RTP CoS mark 5
-- Executing [01122548484444#LocalSets:1] Dial("SIP/mor-00000002", "SIP/01122548484444#dinstar") in new stack
== Using SIP RTP CoS mark 5
-- Called SIP/01122548484444#dinstar
-- SIP/dinstar-00000003 is making progress passing it to SIP/mor-00000002
-- SIP/dinstar-00000003 answered SIP/mor-00000002
-- Remotely bridging SIP/mor-00000002 and SIP/dinstar-00000003
== Spawn extension (LocalSets, 01122548484444, 1) exited non-zero on 'SIP/mor-00000002'
Asterisk AMD in this example will start like you asked - after dial command compleated.
If you want use AMD for provisioning dial answer you should use it in on-answer macro(M param in dial command).
If you want use AMD to detect what happens and route calls, you should implement AMD on other end of call/add that to your dialling core. For examples see vicidial.org or other dialler.

Asterisk, blacklist a number by country code or area code

I have a problem lately, of getting crank calls at all hours of the day and night from overseas countries. I am trying to blacklist entire countries, by country code. After googling around I have come up with the following solution, but don't think it is working... as I have tried substituting my own area code and that doesn't work.
Does the coding look correct?
Also, I don't fully understand the [+]?1? part, and would appreciate a breakdown.
FYI, I do have a working blacklist by number set-up, so I know the [blacklisted] context part works.
extentions.conf:
;; same => n,Set(regx=^[+]?1?(215|609)[0-9]{7}$) ;; my test
same => n,Set(regx=^[+]?1?(252|96|27)[0-9]{9}$)
same => n,GotoIf($[${REGEX(“${regx}” ${CALLERID(num)})} = 1]?blacklisted,s,1)
[blacklisted]
exten => s,1,Answer
exten => s,n,Hangup
Examples of numbers I am trying to block:
+252616251444
+252616531860
+27612238445
+96893327281
The test number I am trying to block is 1-609-123-4567.
Here is my extension.conf:
[from-Provider]
exten => _X.,1,Set(CALLERID(num)=${CALLERID(num):1})
exten => 17025551234,1,Zapateller(nocallerid)
exten => _XX./_+252X.,n,Goto(blacklisted,s,1)
exten => _XX./_+1609X.,n,Goto(blacklisted,s,1)
same => n,GotoIf(${BLACKLIST()}?blacklisted,s,1)
same => n,Dial(SIP/home&IAX2/droid&SIP/office)
same => n,Hangup()
[blacklisted]
exten => s,1,Answer
exten => s,n,Hangup
This is the result of a call that should go through. It gets blocked and spits out this output until the caller hangs up.
CLI output:
== Using SIP RTP CoS mark 5
-- Executing [17025551234#from-Provider:1] Zapateller("SIP/Provider_did10-00000080", "nocallerid") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did10-00000080' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234#from-Provider:1] Zapateller("SIP/Provider_did9-00000081", "nocallerid") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did9-00000081' status is 'UNKNOWN'
...
-- Executing [17025551234#from-Provider:1] Zapateller("SIP/Provider_did9-00000088", "nocallerid") in new stack
== Spawn extension (from-Provider, 17025551234, 1) exited non-zero on 'SIP/Provider_did9-00000088'
EDIT (with noop added for callerid)
I replaced the dialplan with yours verbatim. The problem is no calls get through.
I think I see my problem. I need to include exten => 17025551234,1,Zapateller(nocallerid) because that is my DID. I don't know where to place that.
Here is the CLI output. It is the same whether it's a call that should go through or should be blocked...
== Using SIP RTP CoS mark 5
-- Executing [17025551234#from-Provider:1] Set("SIP/Provider_did10-000000ec", "CALLERID(num)=16175551234") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did10-000000ec' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234#from-Provider:1] Set("SIP/Provider_did9-000000ed", "CALLERID(num)=16175551234") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did9-000000ed' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234#from-Provider:1] Set("SIP/Provider_did9-000000ee", "CALLERID(num)=16175551234") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did9-000000ee' status is 'UNKNOWN'
EDIT (extensions.conf):
[globals]
[default]
exten => 1001,1,Progress()
exten => 1001,n,Answer()
exten => 1001,n,Playback(hello-world)
exten => 1001,n,Hangup()
[internal]
exten => 100,1,Dial(SIP/home)
same => n,Hangup()
exten => home,1,Dial(SIP/home)
same => n,Hangup()
exten => 103,1,Dial(SIP/office)
same => n,Hangup()
include => default
include => iax2
[iax2]
exten => 10,1,Dial(SIP/home)
same => n,Hangup()
exten => 11,1,Dial(IAX2/droid)
same => n,Hangup()
exten => 12,1,Dial(SIP/home&IAX2/droid)
same => n,Hangup()
exten => 20,1,Dial(IAX2/clive)
same => n,Hangup()
include => default
[from-Provider]
exten => _X.,1,Set(CALLERID(num)=${CALLERID(num):1})
exten => 17025551234,1,Zapateller(nocallerid)
same => n,Noop(CALLERID=${CALLERID(all)})
same => n,GotoIf(${BLACKLIST()}?blacklisted,s,1)
same => n,Dial(SIP/home&IAX2/droid&SIP/office)
same => n,Hangup()
exten => 442035551234,1,Zapateller(nocallerid)
same => n,Set(regx=^[+]?1?(252|96|27)[0-9]{9}$)
same => n,GotoIf($[${REGEX("${regx}" ${CALLERID(num)})} = 1]?blacklisted,s,1)
same => n,GotoIf(${BLACKLIST()}?blacklisted,s,1)
same => n,Dial(SIP/home&IAX2/droid&SIP/office)
same => n,Hangup()
[blacklisted]
exten => s,1,Answer
exten => s,n,Hangup
I have two DIDs. One in the USA 17025551234, and one in the UK 442035551234. I have no trunk lines.
EDIT (CLI output using ESYSCODER's context)
I have replaced the entire [from-Provider] context with your context exactly as you posted it. Then I dialed my DID number 17025551234from a number that should not be rejected 17025550000 (obviously I am changing the numbers for privacy concerns).
The CLI output is as follows:
com1*CLI>
-- Executing [17025551234#from-Provider:1] Set("SIP/Provider_did9-00000012", "CALLERID(num)=17025550000") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did9-00000012' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234#from-Provider:1] Set("SIP/Provider_did10-00000013", "CALLERID(num)=17025550000") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did10-00000013' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234#from-Provider:1] Set("SIP/Provider_did10-00000014", "CALLERID(num)=17025550000") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did10-00000014' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234#from-Provider:1] Set("SIP/Provider_did9-00000015", "CALLERID(num)=17025550000") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did9-00000015' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234#from-Provider:1] Set("SIP/Provider_did9-00000016", "CALLERID(num)=17025550000") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did9-00000016' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234#from-Provider:1] Set("SIP/Provider_did10-00000017", "CALLERID(num)=17025550000") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did10-00000017' status is 'UNKNOWN'
com1*CLI>
What confuses me is that I must have the exten => 17025551234,1,Zapateller(nocallerid) line in order for the the DID 17025551234 to pick up. Where should that fit into the dialplan/context that you are suggestiong. Or am I missing something. Is there another way to answer when my DID number is ringing me? Sorry if I'm being thick here... I may be missing one simple point.
EDIT (priority change)
With the following context the caller gets a message, "The number you have dialed is not in service"...
[from-didforsale]
exten => _XX./_1609123456X,1,Goto(blacklisted,s,1)
exten => _XX.,n,GotoIf(${BLACKLIST()}?blacklisted,s,1)
exten => _XX.,n,Noop(CALLERID=${CALLERID(all)})
exten => _XX.,n,Dial(SIP/home&IAX2/droid&SIP/office)
exten => _XX.,n,Hangup()
and this is the CLI output:
== Using SIP RTP CoS mark 5
[Nov 24 09:08:13] NOTICE[2957]: chan_sip.c:23613 handle_request_invite: Call from 'didforsale_did9' (209.216.15.70:5060) to extension '13022323111' rejected because extension not found in context 'from-didforsale'.
I get the exact same thing with the line commented out ;;exten => _XX./_1609123456X,1,Goto(blacklisted,s,1)
Isn't the dialplan sequence:
1. get caller ID
2. pick up incoming DID extension (I may have the wrong terminology)
3. check caller ID for blacklist
?
You can match caller id doing something like this:
exten => s/_+252X.,n,Goto(blacklisted,s,1)
exten => s/_+1609X.,n,Goto(blacklisted,s,1)
or
exten => _XX./_+252X.,n,Goto(blacklisted,s,1)
exten => _XX./_+1609X.,n,Goto(blacklisted,s,1)
More on pattern matching:
https://wiki.asterisk.org/wiki/display/AST/Pattern+Matching
EDIT
Example to block 1-609-123-456X, where X is any digit:
[from-Provider]
exten => _XX.,1,Set(CALLERID(num)=${CALLERID(num):1})
exten => _XX./_1609123456X,n,Goto(blacklisted,s,1)
exten => _XX.,n,GotoIf(${BLACKLIST()}?blacklisted,s,1)
exten => _XX.,n,Noop(CALLERID=${CALLERID(all)})
exten => _XX.,n,Dial(SIP/home&IAX2/droid&SIP/office)
exten => _XX.,n,Hangup()
[blacklisted]
exten => s,1,Answer
exten => s,n,Hangup
You can add also other patterns like:
_252X. (for numbers starting with 252
_96X. (for numbers starting with 96
If this will not work please add whole CLI log. Noop will show us what callerid is looking like in your PBX.
EDIT 2:
Both lines should have priority 1.
[from-didforsale]
exten => _XX./_1609123456X,1,Goto(blacklisted,s,1)
exten => _XX.,1,GotoIf(${BLACKLIST()}?blacklisted,s,1)
exten => _XX.,n,Noop(CALLERID=${CALLERID(all)})
exten => _XX.,n,Dial(SIP/home&IAX2/droid&SIP/office)
exten => _XX.,n,Hangup()

Asterisk & freePBX

I m beginner for asterisk, so I cannot transfer call from main line to asterisk line, can anyone help me??
I have Asterisk card which have 4 port, 2 for FXO and 2 for FXS and I attached 2 land-line on FXS port and plugged PSTN line in FXO port, I generated DAHDI extension for those two land-line one was 101 and second one is 102, I check both can call each-other successfully, using soft-phone also can call on 101 and 102 but problem is there when someone call on land-line they cannot ring and cannot attend the call, so please some give me dial plane.
I also configure
extension.conf
[incoming]
exten => s,1,Answer( )
exten => s,2,Background(enter-ext-of-person)
exten => 101,1,Dial(Dahdi/1,10)
exten => 101,2,Playback(vm-nobodyavail)
exten => 101,3,Hangup( )
exten => 101,102,Playback(tt-allbusy)
exten => 101,103,Hangup( )
exten => 102,1,Dial(SIP/Jane,10)
exten => 102,2,Playback(vm-nobodyavail)
exten => 102,3,Hangup( )
exten => 102,102,Playback(tt-allbusy)
exten => 102,103,Hangup( )
exten => t,1,Playback(vm-goodbye)
exten => t,2,Hangup( )
[internal]
exten => 101,1,Dial(Dahdi/1,,r)
exten => tejas,1,Dial(Dahdi/1,,r)
exten => 102,1,Dial(Dahdi/chirag,,r)
exten => chirag,1,Dial(Dahdi/chirag,,r)
but still unsuccess....
so please help me....
for your more information I will paste some other .conf file
/etc/dahdi/system.conf
fxsks=1,2
fxoks=3,4
loadzone=in
defaultzone=in
As show in above file system.conf in this fxsks channels are 1 & 2 and fxoks channels are 3 & 4 but I also used freePBX for gui mode in this When I searched Connectivity => Dahdi then I got fxsks channels are 3 & 4 and fxoks channels are 1 & 2, which one is right???
/etc/asterisk/chan_dahdi.conf
[general]
#include chan_dahdi_general.conf
#include chan_dahdi_general_custome.conf
[channels]
language=en
busydetect=yes
busycount=10
usecallerid=yes
callwaiting=yes
usecallingpres=yes
threewaycalling=yes
transfer=yes
cancallforward=yes
callreturn=yes
echocancel=yes
echocancelwhenbridged=no
echotraining=no
immediate=no
faxdetect=no
rxgain=0.0
txgain=0.0
#include chan_dahdi_channels_custem.conf
#include chan_dahdi_groups.conf
#include chan_dahdi_additional.conf
/etc/asterisk/dahdi-channels.conf
;line="1 WCTDM/4/0 FXSKS (in use) (EC:MG2-INACTIVE)"
signalling=fxs_ks
callerid=asreceived
group=0
context=from-pstn
channel=>1
callerid=
group=
context=default
;line="2 WCTDM/4/1 FXSKS (in use) (EC:MG2-INACTIVE)"
signalling=fxs_ks
callerid=asreceived
group=0
context=from-pstn
channel=>2
callerid=
group=
context=default
;line="3 WCTDM/4/2 FXOKS (in use) (EC:MG2-INACTIVE)"
signalling=fxo_ks
callerid="channel 3" <4003>
mailbox=4003
group=5
context=from-internal
channel=>3
callerid=
mailbox=
group=
context=default
;line="4 WCTDM/4/3 FXOKS (in use) (EC:MG2-INACTIVE)"
signalling=fxo_ks
callerid="channel 4" <4004>
mailbox=4004
group=5
context=from-internal
channel=>4
callerid=
mailbox=
group=
context=default
I got one more conf file which name is Zapata which I post bellow..
etc/asterisk/zapata.conf.template
[channels]
language=en
#include zapata_additional.conf
context=from-pstn
signalling=fxs_ks
faxdetect=incoming
usecallerid=yes
echocancel=yes
echocancelwhenbridged=no
echotraining=800
group=0
channel=1-2
and more thing I done change just in extension.conf which I mentioned in starting of discussion
I want share some more information, I install freePBX in server PC based on CentOS without gui interface, and I used freePBX in other pc using IP address of server.
And I made some extension based on SIP and Dahdi and its works successfully, If I call 101(Dahdi extension) from 105(SIP Extension) using soft-phone its work.
But when I try to call from my phone to landline then Dahdi extension line not get ring.
I also try to modify extension.conf file which I mentioned in above comment..
Tell one thing which way is better using freePBX or using modification in conf file??
Thanks....
Got it -- you don't have a context defined for from-pstn as specified in dahdi-channels.conf
Outside of freePBX the raw asterisk configuration would be, in your extensions.conf you'll need to add a section like this:
[from-pstn]
exten => _X.,1,Noop(Incoming call "from PSTN")
same => n,Answer()
same => n,Playback(demo-congrats)
same => n,Hangup()
In dahdi-channels.conf in the first two sections there's a definition of context=from-pstn which you'll need an accompanying context in your extensions.conf
The [bracketed] items are "contexts" in Asterisk, and specify a certain context in which the dialplan operates. More information can be found, especially, from the (free) book "Asterisk: The Future of Telephony"

Call not placed on Asterisk using OpenBTS

Could someone point me to a location where I can get the correct configuration for a test setup that can hold 1 or 2 mobile phones.
I have setup an OpenBTS 2.8 with Asterisk 1.8.4 on Ubuntu with an N210 and SBX daughterboard. I am able to dial 600 and establish a connection with the BTS and the echotest runs perfectly. I assigned the two terminals connected to the BTS with the following configurations and when I try to call each other I get the error posted below
The debug output says it placed a call and I dont get any ring on the other phone and I cant lift the call. It times out as expected.
This is my extensions.conf
[macro-dialGSM]
exten => s,1,Dial(SIP/${ARG1},20)
exten => s,2,Goto(s-${DIALSTATUS},1)
exten => s-CANCEL,1,Hangup
exten => s-NOANSWER,1,Hangup
exten => s-BUSY,1,Busy(30)
exten => s-CONGESTION,1,Congestion(30)
exten => s-CHANUNAVAIL,1,playback(ss-noservice)
exten => s-CANCEL,1,Hangup
[sip-external]
exten => 9000,1,Macro(dialGSM,IMSI240020702009669)
exten => 9001,1,Macro(dialGSM,IMSI240016010357097)
This is my sip.conf
[IMSI240020702009669]
callerid=9000
canreinvite=no
type=friend
allow=gsm
context=sip-external
host=dynamic
dtmfmode=info
[IMSI240016010357097]
callerid=9001
canreinvite=no
type=friend
allow=gsm
context=sip-external
host=dynamic
dtmfmode=info
This is the error output from asterisk
-- Executing [s#macro-dialGSM:1] Dial("SIP/IMSI240016010357097-0000001f","SIP/IMSI240020702009669,20") in new stack
== Using SIP RTP CoS mark 5
-- Called IMSI240020702009669
-- Nobody picked up in 20000 ms
-- Executing [s#macro-dialGSM:2] Goto("SIP/IMSI240016010357097-0000001f", "s-NOANSWER,1") in new stack
-- Goto (macro-dialGSM,s-NOANSWER,1)
-- Executing [s-NOANSWER#macro-dialGSM:1] Hangup("SIP/IMSI240016010357097-0000001f", "") in new stack
== Spawn extension (macro-dialGSM, s-NOANSWER, 1) exited non-zero on'SIP/IMSI240016010357097-0000001f' in macro 'dialGSM'
== Spawn extension (sip-external, 9000, 1) exited non-zero on'SIP/IMSI240016010357097-0000001f'
[Sep 18 18:01:31] WARNING[9737]: chan_sip.c:3551 retrans_pkt: Retransmission timeout reached on transmission 3c5b249c2220ff282dddf34d75e0848a#192.168.10.1:5060 for seqno 102(Critical Request) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
Packet timed out after 32000ms with no response
Where do you think I am making a mistake? I referred the wiki but it doesn't help or I cannot understand how to solve from the wiki the error message points.
I figured out the problem the macro had to be fed the ip to route the traffic on
Macro(dialGSM,IMSI240020702009669#127.0.0.1:5062)
hope this helps someone
Indeed, providing the ip address/port to the Dial function solved my problem.
It was very frustrating until I stumbled upon this solution.
Below is the running code
sip.conf :
[IMSI3102XXXXXXXXXX3]
callerid=2000003
canreinvite=no
type=friend
allow=gsm
context=sip-external
host=dynamic
dtmfmode=info
[IMSI3102XXXXXXXXXX4]
callerid=2000004
canreinvite=no
type=friend
allow=gsm
context=sip-external
host=dynamic
dtmfmode=info
extentions.conf :
[macro-dialGSM]
exten => s,1,Dial(SIP/${ARG1},20)
exten => s,2,Goto(s-${DIALSTATUS},1)
exten => s-CANCEL,1,Hangup
exten => s-NOANSWER,1,Hangup
exten => s-BUSY,1,Busy(30)
exten => s-CONGESTION,1,Congestion(30)
exten => s-CHANUNAVAIL,1,playback(ss-noservice)
exten => s-CANCEL,1,Hangup
[sip-external]
exten => 2000003,1,Macro(dialGSM,IMSI3102XXXXXXXXXX3#127.0.0.1:5062)
exten => 2000004,1,Macro(dialGSM,IMSI3102XXXXXXXXXX4#127.0.0.1:5062)

Initiate call from extension

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.
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}

Resources