VIDEOCHAT  ::   FAQ  ::   Поиск  ::   Регистрация  ::   Вход

Автообзон с записью оценки в БД

Проблемы Asterisk без вэб-оболочек и их решения

Модераторы: april22, Zavr2008

Ответить
djan
Сообщения: 3
Зарегистрирован: 23 май 2019, 22:19

Автообзон с записью оценки в БД

Сообщение djan »

Приветствую коллеги. Надо помощь по реализации обзвона с тремя вопросами и возможностью записи в БД нажатой абонентом оценки. Сейчас у меня работает вот такой контекст:

Код: Выделить всё

[ivr-autodialer-custom]
exten => s,1,NoOp(Start IVR)
exten => s,n,Background(/var/lib/asterisk/sounds/custom/op_opinion)
exten => s,n,Background(silence/10,m)

exten => 1,1,MYSQL(Connect connid localhost asteriskuser PASSWORD asteriskcdrdb)
exten => 1,n,MYSQL(Query resultid ${connid} INSERT INTO op_opinion VALUES (NULL, ${UNIQUEID}, ${CALLERID(num)}, ${CONNECTEDLINE(number)}, SEC_TO_TIME(${CDR(DURATION)}), '', SYSDATE(), '${CONNECTEDLINE(name)}', 1, '${CDR(disposition)}'))
exten => 1,n,MYSQL(Disconnect ${connid})
exten => 1,n,Playback(/var/lib/asterisk/sounds/custom/thanks_opinion)
exten => 1,n,Macro(hangupcall,)

exten => 2,1,MYSQL(Connect connid localhost asteriskuser PASSWORD asteriskcdrdb)
exten => 2,n,MYSQL(Query resultid ${connid} INSERT INTO op_opinion VALUES (NULL, ${UNIQUEID}, ${CALLERID(num)}, ${CONNECTEDLINE(number)}, SEC_TO_TIME(${CDR(DURATION)}), '', SYSDATE(), '${CONNECTEDLINE(name)}', 2, '${CDR(disposition)}'))
exten => 2,n,MYSQL(Disconnect ${connid})
exten => 2,n,Playback(/var/lib/asterisk/sounds/custom/thanks_opinion)
exten => 2,n,Macro(hangupcall,)

exten => 3,1,MYSQL(Connect connid localhost asteriskuser PASSWORD asteriskcdrdb)
exten => 3,n,MYSQL(Query resultid ${connid} INSERT INTO op_opinion VALUES (NULL, ${UNIQUEID}, ${CALLERID(num)}, ${CONNECTEDLINE(number)}, SEC_TO_TIME(${CDR(DURATION)}), '', SYSDATE(), '${CONNECTEDLINE(name)}', 3, '${CDR(disposition)}'))
exten => 3,n,MYSQL(Disconnect ${connid})
exten => 3,n,Playback(/var/lib/asterisk/sounds/custom/thanks_opinion)
exten => 3,n,Macro(hangupcall,)

exten => 4,1,MYSQL(Connect connid localhost asteriskuser PASSWORD asteriskcdrdb)
exten => 4,n,MYSQL(Query resultid ${connid} INSERT INTO op_opinion VALUES (NULL, ${UNIQUEID}, ${CALLERID(num)}, ${CONNECTEDLINE(number)}, SEC_TO_TIME(${CDR(DURATION)}), '', SYSDATE(), '${CONNECTEDLINE(name)}', 4, '${CDR(disposition)}'))
exten => 4,n,MYSQL(Disconnect ${connid})
exten => 4,n,Playback(/var/lib/asterisk/sounds/custom/thanks_opinion)
exten => 4,n,Macro(hangupcall,)

exten => 5,1,MYSQL(Connect connid localhost asteriskuser PASSWORD asteriskcdrdb)
exten => 5,n,MYSQL(Query resultid ${connid} INSERT INTO op_opinion VALUES (NULL, ${UNIQUEID}, ${CALLERID(num)}, ${CONNECTEDLINE(number)}, SEC_TO_TIME(${CDR(DURATION)}), '', SYSDATE(), '${CONNECTEDLINE(name)}', 5, '${CDR(disposition)}'))
exten => 5,n,MYSQL(Disconnect ${connid})
exten => 5,n,Playback(/var/lib/asterisk/sounds/custom/thanks_opinion)
exten => 5,n,Macro(hangupcall,)

Он полностью работоспособен но тут у меня играет одна запись потом абонент ставит оценку от 1 до 5 - я ее и ложу в БД. Сейчас стала задача сделать три вопроса с теми же оценками от 1 до 5 и нужную ложить в БД. Помогите пожалуйста описать контекст.

---
от модератора:
используйте теги
BorisTheBlade
Сообщения: 167
Зарегистрирован: 14 фев 2011, 14:24

Re: Автообзон с записью оценки в БД

Сообщение BorisTheBlade »

Например так:
exten => s,1,NoOp(Start IVR)
exten => s,n,Set(vopros=2)
exten => s,n,Background(/var/lib/asterisk/sounds/custom/op_opinion)
exten => s,n,Background(silence/10,m)

exten => 1,1,MYSQL(Connect connid localhost asteriskuser PASSWORD asteriskcdrdb)
exten => 1,n,MYSQL(Query resultid ${connid} INSERT INTO op_opinion VALUES (NULL, ${UNIQUEID}, ${CALLERID(num)}, ${CONNECTEDLINE(number)}, SEC_TO_TIME(${CDR(DURATION)}), '', SYSDATE(), '${CONNECTEDLINE(name)}', 1, '${CDR(disposition)}'))
exten => 1,n,MYSQL(Disconnect ${connid})
exten => 1,n,Playback(/var/lib/asterisk/sounds/custom/thanks_opinion)
exten => 1,n,Goto(vopros-${vopros},1)
...
exten => vopros-2,1,NoOp(Start IVR)
exten => vopros-2,n,Set(vopros=3)
exten => vopros-2,n,Background(/var/lib/asterisk/sounds/custom/op_opinion)
exten => vopros-2,n,Background(silence/10,m)
...
Repz
Сообщения: 169
Зарегистрирован: 04 мар 2015, 11:35

Re: Автообзон с записью оценки в БД

Сообщение Repz »

http://asterisk.ru/store/files/Asterisk ... _DRAFT.pdf
стр 167
стих первый -"Наш первый диалплан "
стих второй - "Создание интерактивного диалплана"
аминь
djan
Сообщения: 3
Зарегистрирован: 23 май 2019, 22:19

Re: Автообзон с записью оценки в БД

Сообщение djan »

BorisTheBlade писал(а):Например так:
exten => s,1,NoOp(Start IVR)
exten => s,n,Set(vopros=2)
exten => s,n,Background(/var/lib/asterisk/sounds/custom/op_opinion)
exten => s,n,Background(silence/10,m)

exten => 1,1,MYSQL(Connect connid localhost asteriskuser PASSWORD asteriskcdrdb)
exten => 1,n,MYSQL(Query resultid ${connid} INSERT INTO op_opinion VALUES (NULL, ${UNIQUEID}, ${CALLERID(num)}, ${CONNECTEDLINE(number)}, SEC_TO_TIME(${CDR(DURATION)}), '', SYSDATE(), '${CONNECTEDLINE(name)}', 1, '${CDR(disposition)}'))
exten => 1,n,MYSQL(Disconnect ${connid})
exten => 1,n,Playback(/var/lib/asterisk/sounds/custom/thanks_opinion)
exten => 1,n,Goto(vopros-${vopros},1)
...
exten => vopros-2,1,NoOp(Start IVR)
exten => vopros-2,n,Set(vopros=3)
exten => vopros-2,n,Background(/var/lib/asterisk/sounds/custom/op_opinion)
exten => vopros-2,n,Background(silence/10,m)
...
Добрый день, спасибо Вам большое за подсказку.
Сделал вот такой контекст:

Код: Выделить всё

[ivr-autodialer-custom-op]
exten => s,1,NoOp(Start IVR)
exten => s,n,Set(question=2)
exten => s,n,Background(/var/lib/asterisk/sounds/custom/op_opinion_gsm)
exten => s,n,Background(silence/10,m)
 
exten => 1,1,MYSQL(Connect connid localhost asteriskuser PASSWORD asteriskcdrdb)
exten => 1,n,MYSQL(Query resultid ${connid} INSERT INTO test_ivr VALUES (NULL, ${UNIQUEID}, ${CALLERID(num)}, ${CONNECTEDLINE(number)}, SEC_TO_TIME(${CDR(DURATION)}), '', SYSDATE(), '${CONNECTEDLINE(name)}', 1, 0, 0, 0, '${CDR(disposition)}'))
exten => 1,n,MYSQL(Disconnect ${connid})
exten => 1,n,Playback(/var/lib/asterisk/sounds/custom/thanks_opinion_gsm)
exten => 1,n,Goto(question_${question},1)

exten => question_2,1,NoOp(Start IVR)
exten => question_2,n,Background(/var/lib/asterisk/sounds/custom/tt_opinion_gsm)
exten => question_2,n,Background(silence/10,m)

exten => 1,1,MYSQL(Connect connid localhost asteriskuser LTR0utl00k! asteriskcdrdb)
exten => 1,n,MYSQL(Query resultid ${connid} UPDATE test_ivr SET opinion1 = 1 WHERE uniqueid = ${UNIQUEID})
exten => 1,n,MYSQL(Disconnect ${connid})
exten => 1,n,Playback(/var/lib/asterisk/sounds/custom/thanks_opinion_gsm)
exten => 1,n,Macro(hangupcall,)
Лог звонка:

Код: Выделить всё

Executing [s@prozvon-informer-op:1] Answer("Local/380XXXXXX@prozvon-op-000037ff;1", "") in new stack
    -- Executing [s@prozvon-informer-op:2] Wait("Local/380XXXXXXX@prozvon-op-000037ff;1", "2") in new stack
    -- Channel SIP/goip_old_vodafone-00000155 joined 'simple_bridge' basic-bridge <9cf7e414-9d9e-42d5-9428-680668685b40>
    -- Channel Local/380XXXXXXX@prozvon-op-000037ff;2 joined 'simple_bridge' basic-bridge <9cf7e414-9d9e-42d5-9428-680668685b40>
    -- Executing [s@prozvon-informer-op:3] Goto("Local/380XXXXXXXXXX@prozvon-op-000037ff;1", "ivr-autodialer-custom-op,s,1") in new stack
    -- Goto (ivr-autodialer-custom-op,s,1)
    -- Executing [s@ivr-autodialer-custom-op:1] NoOp("Local/38XXXXXXXXXX@prozvon-op-000037ff;1", "Start IVR") in new stack
    -- Executing [s@ivr-autodialer-custom-op:2] Set("Local/38XXXXXXXXXXX@prozvon-op-000037ff;1", "question=2") in new stack
    -- Executing [s@ivr-autodialer-custom-op:3] BackGround("Local/380xxxxxxxxx@prozvon-op-000037ff;1", "/var/lib/asterisk/sounds/custom/op_opinion_gsm") in new stack
    -- <Local/3800000000000@prozvon-op-000037ff;1> Playing '/var/lib/asterisk/sounds/custom/op_opinion_gsm.gsm' (language 'en')
    -- Attempting call on Local/s@tc-maint for application NoCDR() (Retry 1)
    -- Called s@tc-maint
    -- Executing [s@tc-maint:1] NoCDR("Local/s@tc-maint-00003800;2", "") in new stack
    -- Executing [s@tc-maint:2] Set("Local/s@tc-maint-00003800;2", "TCMAINT=RETURN") in new stack
    -- Executing [s@tc-maint:3] GosubIf("Local/s@tc-maint-00003800;2", "0?timeconditions,1,1()") in new stack
    -- Executing [s@tc-maint:4] GosubIf("Local/s@tc-maint-00003800;2", "0?timeconditions,9,1()") in new stack
    -- Executing [s@tc-maint:5] GosubIf("Local/s@tc-maint-00003800;2", "0?timeconditions,8,1()") in new stack
    -- Executing [s@tc-maint:6] GosubIf("Local/s@tc-maint-00003800;2", "0?timeconditions,7,1()") in new stack
    -- Executing [s@tc-maint:7] GosubIf("Local/s@tc-maint-00003800;2", "0?timeconditions,6,1()") in new stack
    -- Executing [s@tc-maint:8] GosubIf("Local/s@tc-maint-00003800;2", "0?timeconditions,5,1()") in new stack
    -- Executing [s@tc-maint:9] GosubIf("Local/s@tc-maint-00003800;2", "0?timeconditions,4,1()") in new stack
    -- Executing [s@tc-maint:10] GosubIf("Local/s@tc-maint-00003800;2", "0?timeconditions,3,1()") in new stack
    -- Executing [s@tc-maint:11] GosubIf("Local/s@tc-maint-00003800;2", "0?timeconditions,2,1()") in new stack
    -- Executing [s@tc-maint:12] GosubIf("Local/s@tc-maint-00003800;2", "0?timeconditions,10,1()") in new stack
    -- Executing [s@tc-maint:13] System("Local/s@tc-maint-00003800;2", "/var/lib/asterisk/bin/schedtc.php 60 /var/spool/asterisk/outgoing 1") in new stack
  == Manager 'admin' logged on from 127.0.0.1
  == Manager 'admin' logged off from 127.0.0.1
    -- Executing [s@tc-maint:14] Answer("Local/s@tc-maint-00003800;2", "") in new stack
    -- Local/s@tc-maint-00003800;1 answered
       > Launching NoCDR() on Local/s@tc-maint-00003800;1
  == Spawn extension (tc-maint, s, 14) exited non-zero on 'Local/s@tc-maint-00003800;2'
[2019-05-24 16:59:00] NOTICE[17884]: pbx_spool.c:460 attempt_thread: Call completed to Local/s@tc-maint
    -- Executing [5@ivr-autodialer-custom-op:1] MYSQL("Local/38xxxxxxxxxxx@prozvon-op-000037ff;1", "Connect connid localhost asteriskuser PASSWORD asteriskcdrdb") in new stack
    -- Executing [5@ivr-autodialer-custom-op:2] MYSQL("Local/38xxxxxxxxxxx@prozvon-op-000037ff;1", "Query resultid 1 INSERT INTO test_ivr VALUES (NULL, 1558706316.160355, 380xxxxxxxxxxxx, 380xxxxxxxxx, SEC_TO_TIME(18), '', SYSDATE(), '', 5, 5, 5, 5, 'ANSWERED')") in new stack
    -- Executing [5@ivr-autodialer-custom-op:3] MYSQL("Local/38xxxxxxxxxxx@prozvon-op-000037ff;1", "Disconnect 1") in new stack
    -- Executing [5@ivr-autodialer-custom-op:4] Playback("Local/38xxxxxxxxxx@prozvon-op-000037ff;1", "/var/lib/asterisk/sounds/custom/thanks_opinion_gsm") in new stack
    -- <Local/380xxxxxxxxxxxx@prozvon-op-000037ff;1> Playing '/var/lib/asterisk/sounds/custom/thanks_opinion_gsm.gsm' (language 'en')
-- Executing [5@ivr-autodialer-custom-op:5] Goto("Local/380xxxxxxxxxxxx@prozvon-op-000037ff;1", "question_2,2") in new stack
    -- Goto (ivr-autodialer-custom-op,question_2,2)
    -- Executing [question_2@ivr-autodialer-custom-op:2] NoOp("Local/380xxxxxxxxxxx@prozvon-op-000037ff;1", "Start IVR") in new stack
    -- Executing [question_2@ivr-autodialer-custom-op:3] BackGround("Local/380xxxxxxxxxxx@prozvon-op-000037ff;1", "/var/lib/asterisk/sounds/custom/tt_opinion_gsm") in new stack
    -- <Local/380xxxxxxxxxxxxxx@prozvon-op-000037ff;1> Playing '/var/lib/asterisk/sounds/custom/tt_opinion_gsm.gsm' (language 'en')
    -- Executing [question_2@ivr-autodialer-custom-op:4] BackGround("Local/380xxxxxxxxxxxx@prozvon-op-000037ff;1", "silence/10,m") in new stack
    -- <Local/380xxxxxxxxxxxxxxx@prozvon-op-000037ff;1> Playing 'silence/10.gsm' (language 'en')
    -- Executing [1@ivr-autodialer-custom-op:1] MYSQL("Local/38xxxxxxxxxxxx@prozvon-op-000037ff;1", "Connect connid localhost asteriskuser PASSWORD asteriskcdrdb") in new stack
    -- Executing [1@ivr-autodialer-custom-op:2] MYSQL("Local/38xxxxxxxxxxxx@prozvon-op-000037ff;1", "Query resultid 1 INSERT INTO test_ivr VALUES (NULL, 1558706316.160355, 380xxxxxxxxx, 380xxxxxxxxx, SEC_TO_TIME(40), '', SYSDATE(), '', 1, 0, 0, 0, 'ANSWERED')") in new stack
    -- Executing [1@ivr-autodialer-custom-op:3] MYSQL("Local/38xxxxxxxxxxx@prozvon-op-000037ff;1", "Disconnect 1") in new stack
    -- Executing [1@ivr-autodialer-custom-op:4] Playback("Local/38xxxxxxxxx@prozvon-op-000037ff;1", "/var/lib/asterisk/sounds/custom/thanks_opinion_gsm") in new stack
Сейчас оно переходит на question_2, но когда на втором вопросе ставишь оценку выполняет действие в БД которое INSERT а не UPDATE, то есть как я понимаю выполняет действие по первому совпадению. Как при втором вопросе унифицировать нажатия клавиш от 1 до 5 я не могу понять, Прошу помочь
ded
Сообщения: 15625
Зарегистрирован: 26 авг 2010, 19:00

Re: Автообзон с записью оценки в БД

Сообщение ded »

Вместо
exten => 1,1,MYSQL(Connect connid localhost asteriskuser PASSWORD asteriskcdrdb)
exten => 1,n,MYSQL(Query resultid ${connid} INSERT INTO test_ivr VALUES (NULL, ${UNIQUEID},
напишите скриптик на PHP, с отладкой, положите его в /var/lib/asterisk/agi-bin и вызывайте
exten => 1,1,AGI(your-script.php)
Ответить
© 2008 — 2024 Asterisk.ru
Digium, Asterisk and AsteriskNOW are registered trademarks of Digium, Inc.
Design and development by PostMet-Netzwerk GmbH