Please help me with some functional questions regarding managing callback requests

The main code is from here:

What I want to achieve:

  1. By a call to a specified extension a callback request is stored in a database.
  2. The operator of the extension should be able to manage the requests (scroll through, move, delete, priorize, block etc.) and to initiate the callback itself easyly.

As I don’t know how to implement all the needed features, any advise would be welcome.

The actual dialplan:

exten => 102,1,NOOP(Incoming Call from ${CALLERID(num)} to ${EXTEN})
same => n,Answer()
same => n,SET(DEST=${EXTEN})
same => n,Dial(SIP/${EXTEN},1)
same => n,GoTo(register-callback,s,1)
same => n,Hangup()

exten => 747,1,NOOP(PBX User ${CALLERID(num)} Reading Call-Back Data)
same => n,Answer()
same => n,GOTOIF(${DB_EXISTS(call-back/${CALLERID(num)})}?:hangup)
same => n,SET(CBQ=${DB(call-back/${CALLERID(num)})})
same => n,Playback(vm-youhave)
same => n,SayDigits(${FIELDQTY(CBQ,-)})
same => n,Playback(vm-messages)
same => n,SET(i=${FIELDQTY(CBQ,-)})
same => n,WHILE($["${i}" >= "1"])
same => n,Playback(vm-from-phonenumber)
same => n,SayDigits(${CUT(CBQ,,${i})})
same => n,Read(INPUT,vm-dialout,1)
same => n,GOTOIF($["${INPUT}" == "4"]?back)
same => n,GOTOIF($["${INPUT}" == "6"]?forw)
same => n,GOTOIF($["${INPUT}" == "2"]?first)
same => n,GOTOIF($["${INPUT}" == "3"]?last)
same => n,GOTOIF($["${INPUT}" == "7"]?del)
same => n,SET(DIALME=${CUT(CBQ,,${i})})
same => n,GOTOIF($["${INPUT}" == "1"]?yes)
same => n,EXECIF($["${SaveCBQ}" == ""]?SET(SaveCBQ=${CUT(CBQ,,${i})}):SET(SaveCBQ=${CUT(CBQ,,${i})}-${SaveCBQ}))
same => n,EndWhile()
same => n,hangup()
same => n(back),GOTOIF($[ "${FIELDQTY(CBQ,-)}" > "${i}" ]?go:nogo)
same => n(go),SET(i=$[${i} + 1])
same => n(go),ContinueWhile()
same => n(nogo),Hangup()
same => n(forw),SET(i=$[${i} - 1])
same => n(forw),ContinueWhile()
same => n(first),SET(i=$[${FIELDQTY(CBQ,-)}])
same => n(first),ContinueWhile()
same => n(last),SET(i=$[1])
same => n(last),ContinueWhile()
same => n(del),SET(ARRAY(CBQ,j)=${CUT(CBQ,,1-$[${i} - 1])}-${SaveCBQ},${i})
same => n(del),ContinueWhile()
same => n(yes),SET(ARRAY(CBQ,j)=${CUT(CBQ,,1-$[${i} - 1])}-${SaveCBQ},${i})
same => n,NOOP([CBQ:1]= ${CBQ:1} :: [CBQ:0:-1]=${CBQ:0:-1} :: [CBQ:-1]=${CBQ:-1})
same => n,EXECIF($["${CBQ:-1}" == "-"]?SET(CBQ=${CBQ:0:-1}))
same => n,EXECIF($["${CBQ:0:1}" == "-"]?SET(CBQ=${CBQ:1}))
same => n,SET(DB(call-back/${CALLERID(num)})=${CBQ})
same => n,Dial(SIP/${DIALME})
same => n(hangup),Hangup()

[register-callback]
exten => s,1,NOOP(Caller ${CALLERID(num)} Registering Call-Back for User ${DEST})
same => n,NOOP(do some call-back tricks here)
same => n,SET(CBQ=${DB(call-back/${DEST})})
same => n,GOTOIF($["${CBQ}" == ""]?first:sec)
same => n(first),Set(DB(call-back/${DEST})=${CALLERID(num)})
same => n,GOTO(jump)
same => n(sec),Macro(duplicate-check,${CALLERID(num)})
;same => n,System(echo "" > /var/spool/asterisk/voicemail/default/102/INBOX/msg0${CALLERID(num)}.txt)
same => n,GOTOIF($["${RESULT}" == "1"]?jump)
same => n,Set(DB(call-back/${DEST})=${CALLERID(num)}-${CBQ})
same => n(jump),NOOP(Playback(thanks-willb-called-shortly))
same => n,Hangup()

exten => i,1,GOTO(s,1)

[macro-duplicate-check]
exten => s,1,NOOP(${CBQ} Checked for Duplicate ${ARG1})
exten => s,n,SET(COUNT=${FIELDQTY(CBQ,-)})
exten => s,n,SET(ARRAY(i,RESULT)=1,0)
exten => s,n,WHILE($["${i}" <= "${COUNT}"])
exten => s,n,NOOP(${CUT(CBQ,,${i})} == ${ARG1})
exten => s,n,EXECIF($["${CUT(CBQ,,${i})}" == "${ARG1}"]?GOTO(found):SET(i=$[${i} + 1]))
exten => s,n,Endwhile()
exten => s,n,MacroExit()
exten => s,n(found),SET(RESULT=1)
exten => s,n,MacroExit()

My questions are as follows:

  1. " SET(ARRAY(CBQ,j)=${CUT(CBQ,1-$[${i} - 1])}-${SaveCBQ},${i}) " should delete the current callback number from the database key, but it’s working only with the first entry - when I try to scroll to one of the next entries and delete it, the whole key is being wiped.

  2. Do you have an idea for a simple solution on input to move the entries to another database key (like the “Old” folder in voicemail - something like an acknowledgement feature) instead of deleting them? Also I would like to store the timestamp of the entry creation and of the moving event, such as the timestamp of every retry, but I didn’t manage any easy way to modify this code to achieve this…

  3. Could you suggest how to display the selection of the callback entry dynamically on the phone screen (for ex. as a change of the callee number)? I have already tried " Set(REDIRECTING(to-num,i)=${CUT(CBQ,${i})}) " and " Set(CONNECTEDLINE(num,i)=${CUT(CBQ,${i})}) " - the regarding event appears in the CLI, but on the phone still “747” is being displayed, so it seems not to work during call…

  4. Could you advise me how to include priorities to this scenario? For ex. the extension 100 has a higher priority than extension 101 - so it should be stored above the 101 in the list. Extensions with the highest priority should ever appear at first, same priority - based on the timestamp of the call. Also I would like to have the possibility to make restrictions - like if an extension makes a retry after some amount of time, it should move up in the list, but if the time period between the retries is to short, it should move down and at least on a higher amount of retries it should be moved for a specified time period to a black list or something similar.

  5. Can you suggest how to combine callback list and if possible the black list from 4. with MWI - so that the phone would display that there are requests with the amount of the entries?

  6. Would it perhaps be possible to manage the entries directly from the phone screen without making a call - so scroll through, acknowledge (move to another database key - eg. move between white and black list) and initiate callback - like managing a voicemail box?

As test equipment I’m using several softphones and a UNIFY (Siemens) OpenStage 40 SIP.

Thank you very much in advance!

You can ask here specific questions, but nobody is probably willing here to do your homework. It’s still a good idea to start here: http://www.asteriskdocs.org/

Non-standard MWI with OpenStage SIP? Good luck with that.

These are partially specific questions - like the one regarding MWI or the first one…
If I were able to solve the problems by using standard documentation, I wouldn’t ask here - don’t you think?