0
votes

I was wondering if anyone knows if the following is possible using an asterisk dialplan, and if so, where i'd find the info to program it.

1) Agent dials extension e.g. 1234

2) Agents DND Status is toggled on/off 3) MWI changed to reflect DND status, if DND MWI on

4) Update MySql DB to keep a record of what times status was changed

Thanks in advance

1

1 Answers

0
votes

I hope I did not misunderstand your intentions, and the following code will give you some inspiration.

[ext-local-custom]
exten => 1234,1,Answer()
; Ask agent to input action
; 1 - enable DND
; 0 - disable DND
exten => 1234,n(input),Read(digito,enter-toggled-on-off,1)
exten => 1234,n,GotoIf($["foo${digito}"="foo1"]?toggledOn)
exten => 1234,n,GotoIf($["foo${digito}"="foo0"]?toggledOff)
exten => 1234,n,Playback(invalid)
exten => 1234,n,Goto(input)
exten => 1234,n(toggledOn),NoOP(section toggled On)
; Set DND ON
exten => 1234,n,Set(DB(DND/${CALLERID(number)})=YES)
; MySQL record action
exten => 1234,n,MySql(connect connid localhost root  test)
exten => 1234,n,MySql(query resultidr ${connid} INSERT INTO `test`.`togglelog` (`exten`\,`toggle`\,`logtime`)VALUES (\'${CALLERID(number)}\'\,1\,\'${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)}\'))
exten => 1234,n,Goto(end)
exten => 1234,n(toggledOff),NoOP(section toggled Off)
; Set DND Off
exten => 1234,n,DBdel(DND/${CALLERID(number)})
; MySQL record action
exten => 1234,n,MySql(connect connid localhost root  test)
exten => 1234,n,MySql(query resultidr ${connid} INSERT INTO `test`.`togglelog` (`exten`\,`toggle`\,`logtime`)VALUES (\'${CALLERID(number)}\'\,0\,\'${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)}\'))
exten => 1234,n,Goto(end)
exten => 1234,n(end),Hangup()