How to verify pin code for IVR authentication in Yeastar P-Series PBX

Description

This article provides solution to verify pin code in IVR stage. We take Yeastar P-Series for demo and achieve such situation:

When caller is reaching IVR, he will hear IVR message first and asked to enter given pin code.

If pin code is correct, it will go to different queues according to the time defined in the script.

If pin code is incorrect, he will be asked to enter it again, if pin code incorrect for 3 times he will hear defined message and call will be hangup.

Applicable Devices

Model: P-Series PBX, S-Series PBX

Firmware: Not Required

Steps

1. Add an IVR in web interface and set up proper prompt to ask callers to input pin code, do not set any config in key press event.

2. Create 3 queues for destinations according to different time conditions, add more or less queues accordingly.

3. Access ssh of pbx and go to file by vi command.

support@IPPBX:~# vi /etc/asterisk/extensions.conf

4. Search context “[ivr_6200]” and copy all dialplan within context “[ivr_6200]”, replace 6200 accordingly.

5. Paste what you copied to the file in this path /ysdisk/support/customcfg/extensions_custom.conf and add two 2 paragraphs of script below to extensions_custom.conf.

Paragraph one below in italics and red:

Notice: change time condition and queue number accordingly, if don't need time condition in queue, replace GotoIfTime(08:00-18:00,mon&tue&wed&thu&fri,*,*?queues,6403,1) with Goto(queues,6403,1), if want to route calls to other destination like queue 6406 when pin code is wrong, replace GotoIf($[${COUNT}>=3]?wrongpin,1:ivr_6200,6200,check_count) with Goto(queues,6406,1).

 

exten = _X.,1,Set(pincode=${EXTEN})

exten = _X.,2,Set(result=${SHELL(awk '$1~/^${pincode}$/{print $1}' /ysdisk/etc/autoprovision/template/custom/ivr-pin/ivr-pin.xml)})

exten = _X.,3,Set(res=${result:0:-1})

exten = _X.,4,GotoIf($[${res}>=1}]?valid,1:invalid,1)

exten = valid,1,GotoIfTime(08:00-18:00,mon&tue&wed&thu&fri,*,*?queues,6403,1)

exten = valid,2,GotoIfTime(18:01-23:59,mon&tue&wed&thu&fri,*,*?queues,6404,1)

exten = valid,3,GotoIfTime(02:00-07:59,mon&tue&wed&thu&fri,*,*?queues,6405,1)

exten = invalid,1,GotoIf($[${COUNT}>=3]?wrongpin,1:ivr_6200,6200,check_count)

 

Paragraph two below in italics and red:

Notice: change audio message filename to play for callers after incorrect pin code for 3 times, in the demo filename is PinErrato_ENG_Ita.wav which has been uploaded to custom prompt in pbx, do not add file type to the script ).

exten = wrongpin,1,Background(record/PinErrato_ENG_Ita)

exten = wrongpin,2,Hangup()

 

After added to extensions_custom file, complete script should be similar to those in picture below.

6. Create any extension in web interface and delete it again, click on 'Apply' to make above change take effect.

7. In Auto Provisioning – Resource Repository – Custom Templates, add one and choose a phone model that might hardly use it in future in ‘Source Default Template’, and do set Template Name to ‘ivr-pin’ which is mandatory, in fact have to be the same as defined in script.

Scroll down mouse and remove all original contents in both fileds, add required pin code in first filed, one code one line, save it, later always modify or add new pin code here.

8. All done, test calls now.

Have more questions? Submit a request

1 Comments

  • 0
    Avatar

    Hi Tonnie, I followed your instructions but whatever PIN I enter, whether it's right or wrong, it always sends me to the wrongpin line. This is what the P550 tells me:

    --------------------------

    -- Executing [2222@ivr_6204:1] Set("PJSIP/1010-00000007", "pincode=2222") in new stack

    -- Executing [2222@ivr_6204:2] Set("PJSIP/1010-00000007", "result=") in new stack

        -- Executing [2222@ivr_6204:3] Set("PJSIP/1010-00000007", "res=") in new stack

    [2024-09-22 19:14:06] WARNING[5012][C-00000007]: ast_expr2.fl:470 ast_yyerror: ast_yyerror():  syntax error: syntax error, unexpected '>=', expecting $end; Input:
    >=1}
    ^

    [2024-09-22 19:14:06] WARNING[5012][C-00000007]: ast_expr2.fl:474 ast_yyerror: If you have questions, please refer to https://wiki.asterisk.org/wiki/display/AST/Channel+Variables
        -- Executing [2222@ivr_6204:4] GotoIf("PJSIP/1010-00000007", "?valid,1:invalid,1") in new stack

        -- Goto (ivr_6204,invalid,1)

        -- Executing [invalid@ivr_6204:1] GotoIf("PJSIP/1010-00000007", "0?wrongpin,1:ivr_6200,6200,check_count") in new stack

        -- Goto (ivr_6200,6200,9)

        -- Executing [6200@ivr_6200:9] Set("PJSIP/1010-00000007", "COUNT=2") in new stack

    ---------------------------------

    Tanks for your attention

Please sign in to leave a comment.