Re: [asterisk-users] Pattern Extension not working in Dialplan

2014-09-08 Thread Hashmat Khan
READ application should do the job for you
[Syntax]Read(variable[,filename[filename2[...]][,maxdigits[,options[,attempts[,timeout])
i normally use first three arguments i.e. variable name, filename to play and 
max digits
you might consider using waitexten before read though
Rgds

From: anuragrana31...@gmail.com
Date: Mon, 8 Sep 2014 09:29:47 +0530
To: asterisk-users@lists.digium.com
Subject: Re: [asterisk-users] Pattern Extension not working in Dialplan

​Thank you all for your suggestions.
1. [macro-age] is a macro and not an extension badly named.
2. I am able to use Read to fulfill the purpose but we can't use Read() after 
Background(). To use read we need Playback() [ am I right?]. But Playback do 
not provide barge-in facility i.e. user have to listen whole message then only 
his inputs will be accepted and if he entered input during the time recording 
is played , the input will be lost. So if using Background() [which return the 
control immediately] I have to use _XX extension.
3. So basically I want to create a dial-plan where user is asked to input 
multi-digit value and he can enter it without listening complete message (if 
the user knows the message already)​

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users  
  -- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] Pattern Extension not working in Dialplan

2014-09-08 Thread A J Stiles
On Sunday 07 Sep 2014, Anurag Rana wrote:
 Hi,
 
 I created a dummy dialplan  where I ask the user to enter the age.
 
 [macro-age]
 exten = s,1,Background(my/age)  ;;Play recorded message to enter age
 exten = s,n,WaitExten(10)
 exten = _XX,1,Set(AGE=${EXTEN});; this line is not executing, instead
 dialplan is terminating with error given below.
 exten = s,n,NoOp(${AGE})
 exten = s,n,GotoIf($[${LEN(${AGE})}  0]?notEmpty)
 exten = s,n,Goto(s,1)
 exten = s(notEmpty),n,Background(my/thank-you)
 exten = s,n,Wait(1)
 
 
 When I receive call and tries to enter the digits (86 lets say), it only
 accept just first digit and terminates even before considering second
 digit. Error message :
  WARNING[5726][C-000a]: pbx.c:6696 __ast_pbx_run: Invalid extension
 '8', but no rule 'i' or 'e' in context 'testmacro'
 
 Please suggest what might be wrong.
 
 
 Anurag Rana
 http://newbie42.blogspot.in/

You would be better off jumping to a new context and building up your number, 
digit-by-digit as it is entered, in a channel variable.

In your s extension, set your variable to an empty string; do a Background() 
and then WaitExten() for a digit to be entered.  Have an extension _X to 
capture each digit and append it to the number so far.  Then use a GotoIf() to 
jump to the WaitExten() statement if insufficient digits have been entered so 
far.  You might also want a * extension to clear the number entered so far, if 
the user makes a mistake.


If you need a written example, I might be able to dig something out later.

-- 
AJS

Note:  Originating address only accepts e-mail from list!  If replying off-
list, change address to asterisk1list at earthshod dot co dot uk .

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] Pattern Extension not working in Dialplan

2014-09-08 Thread Anurag Rana
Thanks for the suggestion.

@Stiles - Look like this may work. Will try this. Thanks.

Anurag Rana
http://newbie42.blogspot.in/




On Mon, Sep 8, 2014 at 1:42 PM, A J Stiles asterisk_l...@earthshod.co.uk
wrote:

 On Sunday 07 Sep 2014, Anurag Rana wrote:
  Hi,
 
  I created a dummy dialplan  where I ask the user to enter the age.
 
  [macro-age]
  exten = s,1,Background(my/age)  ;;Play recorded message to enter age
  exten = s,n,WaitExten(10)
  exten = _XX,1,Set(AGE=${EXTEN});; this line is not executing,
 instead
  dialplan is terminating with error given below.
  exten = s,n,NoOp(${AGE})
  exten = s,n,GotoIf($[${LEN(${AGE})}  0]?notEmpty)
  exten = s,n,Goto(s,1)
  exten = s(notEmpty),n,Background(my/thank-you)
  exten = s,n,Wait(1)
 
 
  When I receive call and tries to enter the digits (86 lets say), it only
  accept just first digit and terminates even before considering second
  digit. Error message :
   WARNING[5726][C-000a]: pbx.c:6696 __ast_pbx_run: Invalid extension
  '8', but no rule 'i' or 'e' in context 'testmacro'
 
  Please suggest what might be wrong.
 
 
  Anurag Rana
  http://newbie42.blogspot.in/

 You would be better off jumping to a new context and building up your
 number,
 digit-by-digit as it is entered, in a channel variable.

 In your s extension, set your variable to an empty string; do a
 Background()
 and then WaitExten() for a digit to be entered.  Have an extension _X to
 capture each digit and append it to the number so far.  Then use a
 GotoIf() to
 jump to the WaitExten() statement if insufficient digits have been entered
 so
 far.  You might also want a * extension to clear the number entered so
 far, if
 the user makes a mistake.


 If you need a written example, I might be able to dig something out later.

 --
 AJS

 Note:  Originating address only accepts e-mail from list!  If replying off-
 list, change address to asterisk1list at earthshod dot co dot uk .

 --
 _
 -- Bandwidth and Colocation Provided by http://www.api-digital.com --
 New to Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello

 asterisk-users mailing list
 To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] Pattern Extension not working in Dialplan

2014-09-08 Thread Anurag Rana
@A J Stiles : If you could provide an example as you said, It would be very
nice.  Thanks.
-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] Pattern Extension not working in Dialplan

2014-09-08 Thread A J Stiles
On Monday 08 Sep 2014, Anurag Rana wrote:
 @A J Stiles : If you could provide an example as you said, It would be very
 nice.  Thanks.

This is excerpted from a dialplan application I wrote.  It's actually a PIN 
entry but should be usable for any general purpose application.  Sound files 
referred to will need to be created by you.

[get_pin]
exten = s,1,Set(pin=)
exten = s,n,Set(PINLENGTH=4)
exten = s,n(prompt),Background(ajs-enter_pin)
;  Build up the PIN digit by digit.  The WaitExten() will be cut short by any
;  keystroke, so we can use a quite longish timeout.
exten = s,n(nextdigit),WaitExten(30)
exten = s,n,Playback(ajs-sorry_didnt_get)
exten = s,n,GoToIf($[${LEN(${pin})}1]?prompt:saysofar)
exten = s,n(saysofar),Playback(ajs-digits_so_far)
exten = s,n,SayDigits(${pin})
exten = s,n,Goto(nextdigit)

;  We need a h extension  (for tidying up after ourselves)  in this context;
;  because the call may be placed from within this context.

exten = h,1,NoOp(Clearing up)

exten = *,1,Playback(ajs-start_again)
exten = *,2,GoTo(get_pin,s,1)

exten = #,1,Hangup()

exten = _X,1,Set(pin=${pin}${EXTEN:0:1})
exten = _X,n,NoOp(PIN so far is ${pin})
exten = _X,n,GoToIf($[${LEN(${pin})}=${PINLENGTH}]?got_all:need_more)
exten = _X,n(need_more),GoTo(get_pin,s,nextdigit)
;  We have all 4 digits .
exten = _X,n(got_all),NoOp(PIN is ${pin})


-- 
AJS

Note:  Originating address only accepts e-mail from list!  If replying off-
list, change address to asterisk1list at earthshod dot co dot uk .

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] Pattern Extension not working in Dialplan

2014-09-08 Thread Anurag Rana
​Thanks. I will try it. Meanwhile I was trying below code.

call goes to 'test' context and from there is passed to macro 'age'.
In 'age' macro when I am using any patter to accept even single digit, its
not working. So instead of using pattern I hardcoded the extension, but
still when I am pressing the key '2' it is throwing below error.
Please note that when diaplan execution is inside macro 'age', it searches
the extension inside its parent context 'test'...why? am I do something
wrong?

[test]
exten=s,1,Macro(age)

[macro-age]
exten=s,1,Background(my/age)
exten=s,2,WaitExten(15)
exten=s,3,NoOp(${AGE})
exten=s,n,GotoIf($[${LEN(${AGE})}  0]?notEmpty)
exten=s,n,Goto(s,1)
exten=s(notEmpty),n,Background(my/thank-you)
exten=s,n,Wait(1)

exten=2,1,(TEMP=${EXTEN})   ;; exten=_X,1,(TEMP=${EXTEN}) is also not
working
exten=2,n,Read(AGE,,1,10)
exten=2,n,Set(AGE=${${TEMP}*10+${AGE}})
exten=2,n,Goto(s,3)
​


-
​ OUTPUT -​


​ == Using SIP RTP CoS mark 5
-- Executing [s@test:1] Wait(SIP/101-0005, 1) in new stack
-- Executing [s@test:2] Macro(SIP/101-0005, age) in new stack
-- Executing [s@macro-age:1] BackGround(SIP/101-0005, my/age)
in new stack
-- SIP/101-0005 Playing 'my/age.slin' (language 'en')
[Sep  9 00:55:11] WARNING[9759][C-0005]: pbx.c:6696 __ast_pbx_run:*
Invalid extension '2', but no rule 'i' or 'e' in context 'test'*
-- Executing [h@test:1] NoOp(SIP/101-0005, ,) in new stack
[Sep  9 00:55:11] NOTICE[9759]: pbx_spool.c:402 attempt_thread: Call
completed to SIP/
​
-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] Pattern Extension not working in Dialplan

2014-09-07 Thread John Kiniston
The first issue I see is you are attempting to insert your pattern match in
the middle of your 's' extension, That's going to break your 's' extension.

The second issue is that you are matching on XX which will match two
digits, You need to match on _X instead if you are attempting to match on
the number 8.

I recommend you look into 'read' instead of trying to do a pattern match.

On Sun, Sep 7, 2014 at 1:41 PM, Anurag Rana anuragrana31...@gmail.com
wrote:

 Hi,

 I created a dummy dialplan  where I ask the user to enter the age.

 [macro-age]
 exten = s,1,Background(my/age)  ;;Play recorded message to enter age
 exten = s,n,WaitExten(10)
 exten = _XX,1,Set(AGE=${EXTEN});; this line is not executing, instead
 dialplan is terminating with error given below.
 exten = s,n,NoOp(${AGE})
 exten = s,n,GotoIf($[${LEN(${AGE})}  0]?notEmpty)
 exten = s,n,Goto(s,1)
 exten = s(notEmpty),n,Background(my/thank-you)
 exten = s,n,Wait(1)


 When I receive call and tries to enter the digits (86 lets say), it only
 accept just first digit and terminates even before considering second digit.
 Error message :
  WARNING[5726][C-000a]: pbx.c:6696 __ast_pbx_run: Invalid extension
 '8', but no rule 'i' or 'e' in context 'testmacro'

 Please suggest what might be wrong.


 Anurag Rana
 http://newbie42.blogspot.in/




 --
 _
 -- Bandwidth and Colocation Provided by http://www.api-digital.com --
 New to Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello

 asterisk-users mailing list
 To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users




-- 
A human being should be able to change a diaper, plan an invasion, butcher
a hog, conn a ship, design a building, write a sonnet, balance accounts,
build a wall, set a bone, comfort the dying, take orders, give orders,
cooperate, act alone, solve equations, analyze a new problem, pitch manure,
program a computer, cook a tasty meal, fight efficiently, die gallantly.
Specialization is for insects.
---Heinlein
-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] Pattern Extension not working in Dialplan

2014-09-07 Thread Steve Edwards

Please don't top-post.


On Sun, Sep 7, 2014 at 1:41 PM, Anurag Rana anuragrana31...@gmail.com wrote:



I created a dummy dialplan  where I ask the user to enter the age. 

[macro-age]
exten = s,1,Background(my/age)      ;;Play recorded message to enter age
exten = s,n,WaitExten(10)                 
exten = _XX,1,Set(AGE=${EXTEN})    ;; this line is not executing, instead 
dialplan is terminating with error given below.
exten = s,n,NoOp(${AGE})
exten = s,n,GotoIf($[${LEN(${AGE})}  0]?notEmpty)
exten = s,n,Goto(s,1)
exten = s(notEmpty),n,Background(my/thank-you)
exten = s,n,Wait(1)


On Sun, 7 Sep 2014, John Kiniston wrote:

The first issue I see is you are attempting to insert your pattern match 
in the middle of your 's' extension, That's going to break your 's' 
extension. The second issue is that you are matching on XX which will 
match two digits, You need to match on _X instead if you are attempting 
to match on the number 8.


I recommend you look into 'read' instead of trying to do a pattern 
match.


A pattern match is a reasonable method. I use pattern matching more often 
that the read() application. Try both and see which meets your needs 
better.


Are you really defining a 'macro' or is that just the (misleading) name 
you chose for your context. Personally, I use gosub() more, but again, 
try both :)


I suggest you try 'dialplan show macro-age' to see how Asterisk is 
interpreting your dialplan. I suspect it is not what you expect.


In specific, your ordering of '_xx' in the middle of 's' is odd. This 
would disrupt the value of the priority in older versions of Asterisk, but 
it appears that it does work in modern (I'm using 11) versions.


Also, a label ('notEmpty') belongs to a priority, not an extension.

--
Thanks in advance,
-
Steve Edwards   sedwa...@sedwards.com  Voice: +1-760-468-3867 PST
Newline  Fax: +1-760-731-3000-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] Pattern Extension not working in Dialplan

2014-09-07 Thread Steve Edwards

On Sun, 7 Sep 2014, Steve Edwards wrote:

In specific, your ordering of '_xx' in the middle of 's' is odd. This would 
disrupt the value of the priority in older versions of Asterisk, but it 
appears that it does work in modern (I'm using 11) versions.


Disregard that. I can't even follow my own advice ('dialplan show 
macro-age'). Don't 'intermingle' extensions.


--
Thanks in advance,
-
Steve Edwards   sedwa...@sedwards.com  Voice: +1-760-468-3867 PST
Newline  Fax: +1-760-731-3000

--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
  http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] Pattern Extension not working in Dialplan

2014-09-07 Thread Anurag Rana
​Thank you all for your suggestions.

1. [macro-age] is a macro and not an extension badly named.

2. I am able to use Read to fulfill the purpose but we can't use Read()
after Background(). To use read we need Playback() [ am I right?]. But
Playback do not provide barge-in facility i.e. user have to listen whole
message then only his inputs will be accepted and if he entered input
during the time recording is played , the input will be lost.
So if using Background() [which return the control immediately] I have to
use _XX extension.

3. So basically I want to create a dial-plan where user is asked to input
multi-digit value and he can enter it without listening complete message
(if the user knows the message already)​
-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users