Survey after Hangup

Hello,
I’m new to FreePBX and I’m having trouble to manage an IVR for a survey after the hang up.
I have Asterisk 16.11.1 and FreePBX 15.0.16.75.
I managed to let it work when I set it as custom destination from FreePBX, but now I would like the following instructions should be executed when an operator hangs up:

[macro-survey]
exten => s,1,answer()
;this asks the first question (based on your recording) and stores them in variable
exten => s,n(question1),Read(answer1,enter-ext-of-person,1,1,2)
exten => s,n,GotoIf([ {answer1} < 4 ]?question2:question1)
;this asks the first question (based on your recording) and stores them in variable
exten => s,n(question2),Read(answer2,enter-ext-of-person,1,1,2)
exten => s,n,GotoIf([ {answer2} < 4 ]?finish:question1)
;this line puts the two answers together and separates them with a | symbol.
exten => s,n(finish),set(answer={answer1}|{answer2})
;this saves the answers into the CDR field of “userfield”
exten => s,n,Set(CDR(userfield)=${answer})
exten => s,n,hangup()

This context is saved into /etc/asterisk/extensions_override_freepbx.conf that should override the
/etc/asterisk/extensions_additional.conf behaviour.
I’ve tried to put the following into the [ext-local] dialplan:

exten => s,n,Set(CHANNEL(hangup_handler_push)=macro-survey,s,1);
or
exten => h,1,Goto(macro-survey,s,1)

But it doesn’t seem to work.
Can you help me? Thank you.

1 Like

No need to use the override context, extensions_custom should work

Do you have the queues pro module? If yes, then create a custom destination pointing to macro-survey,s,1 then make the post callee destination the custom destination.

https://wiki.freepbx.org/display/FPG/Custom+Destinations+Module

https://wiki.freepbx.org/display/FPG/VQ+Plus+Options+in+Queues#VQPlusOptionsinQueues-PostHangupDestinations

Another option is to use something in here to trigger the event.

Lastly, if you need something more simple, can you have the agent transfer the caller manually?

You can’t use a hangup handler to do a caller survery, the hangup handler only runs after the caller has hung up.

thanks! no, i don’t have the pro module for the moment… i’m trying to do this without it.

Thanks! yes, but i want the survey to start when the operator hungs up… what should i use?

Outside of having agents manually transfer the call, if you do not have the pro module, you will need to code a solution yourself. Including custom coding at least part of the queue component (if not all).

I would strongly recommend considering purchasing the module, as often it is far “cheaper” to use the existing prebuilt solution when you consider how long it will take you to code it, troubleshoot it and maintain it (changes).

If you really don’t want to purchase the commercial module and you are ready to get your hands dirty then you have two options.

1 Call the Queue with the c option

exten => s,n,Queue(QueueNum,c)

See more: https://wiki.asterisk.org/wiki/display/AST/Building+Queues
But this way you are loosing control of all changes you make in the GUI.

2 Call the queue with a local channel and add the dial option g which will continue the dialplan once the callee channel hangs up

[pre-queue]
exten => s,1,Noop()
exten => s,n,Dial(local/QueueNum@context,,g)
exten => s,n,Goto(your-survey,s,1)

See more: https://wiki.asterisk.org/wiki/display/AST/Asterisk+16+Application_Dial

Finally, create a custom destination which points to pre-queue,s,1 and then point your IVR or whatever is currently pointed to the queue, to this custom destination

Note: I haven’t tested both of these, but the second one makes more sense to me.

EDIT: I corrected the second method, and tested - it works.

3 Likes

Thank you very much Pitz! the second one seems to be the right way… but still when i get to the queue, and there is the hangup, the call is closed and i don’t get to the third instruction :frowning: i think freepbx still overrides the hangup routine somehow… do you have suggestions? otherwise i think i will buy the module… where should i found it? in application --> virtual queues?

Where did you place your custom dialplan? It needs to be in extensions_custom.conf, you can use the config edit module to write to that file.

Did you send the calls to the pre-queue context as instructed?

thank you for your replies. I found out the issue. I had to put the [pre-queue] and my survey istructions into extensions_freepbx_override.conf file as well as the [ext-queues] context (copied from extensions_additional.conf)… because otherwise once the queue is called and the operator hungs up Freepbx will apply its own hungup routines. now it’s working… do you think it’s a good workaround? thank you.

I suggest you to please pay attention to what we are suggesting you and follow along…

You’ve been told to put the custom context/dialplan in extensions_custom.conf otherwise FreePBX will override it.

Please do that, and copy the dialplan from above, if it does not work, please post a pastebin link that contains a call trace, see instructions: https://wiki.freepbx.org/display/SUP/Providing+Great+Debug#ProvidingGreatDebug-AsteriskLogs-PartII

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.