callback + mysql

Get help with installing, upgrading and running Asterisk.

Moderators: muppetmaster, Moderator, Support

callback + mysql

Postby vitas » Sat Dec 26, 2015 2:50 pm

hello,

Please help me ... I want to set a callback with this configuration:

When an incoming call, the system determines my number and if he is in the list (based Msql) - throws in a voice menu ivr-pass which will be invited to dial PIN-code and access the following context. It all works (without callback). But the callback I can not set up, that is, do not get in the context of ivr-callback. The call goes to the asterisk and then prompts you to enter PIN-code in place that would run the script in /user/share/asterisk/agi-bin/callback.agi callback.agi

What can there be problem somebody tell me?

bash script:
Code: Select all
#!/bin/bash
echo Channel: Dongle/dongle0/$1 > /var/tmp/$2.call
echo MaxRetries: 2 >> /var/tmp/$2.call
echo RetryTime: 3 >> /var/tmp/$2.call
echo WaitTime: 20 >> /var/tmp/$2.call
echo Context: ivr-pass >> /var/tmp/$2.call
echo Extension: s >> /var/tmp/$2.call
echo Priority: 2 >> /var/tmp/$2.call
echo Archive: Yes >> /var/tmp/$2.call
chown asterisk:asterisk /var/tmp/$2.call
chmod 777 /var/tmp/$2.call
mv /var/tmp/$2.call /var/spool/asterisk/outgoing


mysql database:
Code: Select all
USE asterisk;
CREATE TABLE `callback` (
`phone` varchar(80) NOT NULL default '',
`pin` int(11) NOT NULL default '4321',
`callback` int(11) NOT NULL default '0',
`user` varchar(255) NOT NULL default ''
);
INSERT INTO callback(phone, pin, user) values('06XXXXXXXX', '3212', 'Vitas');


extensions.conf
Code: Select all
[fromgorod]
exten => s,1,NoOp(zvonyat s nomera ${CALLERID(all)})
exten => s,n,NoOp(${STRFTIME(${EPOCH},,%d.%m.%Y-%H:%M:%S)})
exten => s,n,MYSQL(Connect connid localhost asterisk passwordMsql asterisk)
exten => s,n,MYSQL(Query resultid ${connid} select pin, callback from callback where phone=${CALLERID(number)})
exten => s,n,MYSQL(Fetch fetchid ${resultid} pin callback)
exten => s,n,NoOp(pin -> ${pin} callback# -> ${callback})
exten => s,n,MYSQL(Clear ${resultid})
exten => s,n,MYSQL(Disconnect ${connid})
exten => s,n,GoToIf($["${pin}" != ""]?ivr-pass,s,1)
exten => s,n,Answer() ;otvechaem

[ivr-pass]
exten => s,1,GoToIf($["${callback}" != "0"]?ivr-callback,s,1)
exten => s,n,Background(/var/lib/asterisk/sounds/ru/dir-welcome) ;
exten => s,n,WaitExten(10)
exten => _XXXX,1,GoToIf($["${EXTEN}" = "${pin}"]?ivr,s,1)
exten => _XXXX,n,Hangup
exten => t,1,Hangup
exten => i,1,Hangup

[ivr-callback]
exten => s,1,AGI(/usr/share/asterisk/agi-bin/callback.agi,${callback},${UNIQUEID})
exten => s,n,hangup

[ivr]
exten => s,1,Set(inum=0)
exten => s,n,Set(tnum=0)
exten => s,n,Background(/var/lib/asterisk/sounds/ru/dir-welcome)
exten => s,n,WaitExten(10)
exten => 1,1,GoTo(ivr-out,s,1)
exten => 2,1,GoTo(ivr-ch-pin,s,1)
exten => i,1,Playback(pbx-invalid)
exten => i,n,Set(inum=$[${inum} + 1])
exten => i,n,GotoIf($["${inum}" < "3"]?s,1)
exten => i,n,Hangup()
exten => t,1,Set(tnum=$[${tnum} + 1])
exten => t,n,GotoIf($["${tnum}" < "3"]?s,1)
exten => t,n,Hangup()

[ivr-out]
exten => s,1,Set(inum=0)
exten => s,n,Set(tnum=0)
exten => s,n,Background(beep)
exten => s,n,WaitExten(10)
exten => _0[1-6]XXXXXXXX,1,Dial(Dongle/dongle0/${EXTEN})
exten => _0[1-6]XXXXXXXX,n,Hangup
;exten => 8[2-8]XXXXXXXXX,1,Dial(SIP/blabla3/${EXTEN}
;exten => 8[2-8]XXXXXXXXX ,n,Hangup
exten => i,1,Playback(pbx-invalid)
exten => i,n,Set(inum=$[${inum} + 1])
exten => i,n,GotoIf($["${inum}" < "3"]?s,1)
exten => i,n,Hangup()
exten => t,1,Set(tnum=$[${tnum} + 1])
exten => t,n,GotoIf($["${tnum}" < "3"]?s,1)
exten => t,n,Hangup()


CLI>
Code: Select all
CLI>
  == Using SIP RTP CoS mark 5
    -- Executing [s@fromgorod:1] NoOp("SIP/call-inband-outband-00000002", " "06XXXXXXXX" <06XXXXXXXX>") in new stack
    -- Executing [s@fromgorod:2] NoOp("SIP/call-inband-outband-00000002", "26.12.2015-19:24:07") in new stack
    -- Executing [s@fromgorod:3] MYSQL("SIP/call-inband-outband-00000002", "Connect connid localhost asterisk passwordMysql asterisk") in new stack
    -- Executing [s@fromgorod:4] MYSQL("SIP/call-inband-outband-00000002", "Query resultid 1 select pin, callback from callback where phone=06XXXXXXXX") in new stack
    -- Executing [s@fromgorod:5] MYSQL("SIP/call-inband-outband-00000002", "Fetch fetchid 2 pin callback") in new stack
    -- Executing [s@fromgorod:6] NoOp("SIP/call-inband-outband-00000002", "pin -> 3212 callback# -> 0") in new stack
    -- Executing [s@fromgorod:7] MYSQL("SIP/call-inband-outband-00000002", "Clear 2") in new stack
    -- Executing [s@fromgorod:8] MYSQL("SIP/call-inband-outband-00000002", "Disconnect 1") in new stack
    -- Executing [s@fromgorod:9] GotoIf("SIP/call-inband-outband-00000002", "1?ivr-pass,s,1") in new stack
    -- Goto (ivr-pass,s,1)
    -- Executing [s@ivr-pass:1] GotoIf("SIP/call-inband-outband-00000002", "0?ivr-callback,s,1") in new stack
    -- Executing [s@ivr-pass:2] BackGround("SIP/call-inband-outband-00000002", "/var/lib/asterisk/sounds/ru/dir-welcome") in new stack
    -- <SIP/call-inband-outband-00000002> Playing '/var/lib/asterisk/sounds/ru/dir-welcome.alaw' (language 'en')
    -- Executing [s@ivr-pass:3] WaitExten("SIP/call-inband-outband-00000002", "10") in new stack
  == CDR updated on SIP/call-inband-outband-00000002
    -- Executing [3212@ivr-pass:1] GotoIf("SIP/call-inband-outband-00000002", "1?ivr,s,1") in new stack
    -- Goto (ivr,s,1)
    -- Executing [s@ivr:1] Set("SIP/call-inband-outband-00000002", "inum=0") in new stack
    -- Executing [s@ivr:2] Set("SIP/call-inband-outband-00000002", "tnum=0") in new stack
    -- Executing [s@ivr:3] BackGround("SIP/call-inband-outband-00000002", "/var/lib/asterisk/sounds/ru/dir-welcome") in new stack
    -- <SIP/call-inband-outband-00000002> Playing '/var/lib/asterisk/sounds/ru/dir-welcome.alaw' (language 'en')
    -- Executing [s@ivr:4] WaitExten("SIP/call-inband-outband-00000002", "10") in new stack
  == CDR updated on SIP/call-inband-outband-00000002
    -- Executing [1@ivr:1] Goto("SIP/call-inband-outband-00000002", "ivr-out,s,1") in new stack
    -- Goto (ivr-out,s,1)
    -- Executing [s@ivr-out:1] Set("SIP/call-inband-outband-00000002", "inum=0") in new stack
    -- Executing [s@ivr-out:2] Set("SIP/call-inband-outband-00000002", "tnum=0") in new stack
    -- Executing [s@ivr-out:3] BackGround("SIP/call-inband-outband-00000002", "beep") in new stack
    -- <SIP/call-inband-outband-00000002> Playing 'beep.gsm' (language 'en')
    -- Executing [s@ivr-out:4] WaitExten("SIP/call-inband-outband-00000002", "10") in new stack
  == Spawn extension (ivr-out, s, 4) exited non-zero on 'SIP/call-inband-outband-00000002'

Last edited by vitas on Mon Jan 04, 2016 6:33 am, edited 1 time in total.
vitas
Newsterisk
 
Posts: 1
Joined: Sat Dec 26, 2015 2:31 pm

Re: callback + mysql

Postby abw1oim » Tue Dec 29, 2015 12:21 pm

There are several problems:

First of all: Your context "ivr-callback" is never execited, the callflow leads from

fromgorod -> ivr-pass -> ivr -> ivr-out

This would be callthrough but not callback.

Second:

In [ivr] You have an option 2 which sends the call to ivr-ch-pin which doesn't exist

Third:

Based on Your agi for the Callfile there's another (potential) problem: You would establish a channel of type Dongle via dongle0 to the given param $1 (which is - btw - undefined in Your example data, so why don't You use the CALLERID of the incoming call?). In the used context (which is ivr-pass at the moment) this leads somewhen to ivr-out, whereas - when a destination number is entered - a destination 0[1-6]X would be dialed via Dongle/dongle0. If dongle0 is not defined as a group but as a single device, this won't work, as every single device has only one channel.

As You can see, there are some different errors.
We can assist You if You want (I my govorim po russki). When interested, just drop a PM.
Olaf Winkler
Asterisk- & Database-Solutions
abw1oim
Oldsterisk
 
Posts: 358
Joined: Fri Aug 05, 2011 1:00 am
Location: Germany


Return to Asterisk Support

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 1 guest