FPBX/Asterisk option to replace Avaya IPO “Campaigns”

Good morning, all.

We’re in the process of replacing an older Avaya IPO install with FPBX, and we’ve run across a little snag.

There are several modules built in the existing voicemail system that ask a series of questions, and record the answers from the caller, then email a single sound file (with all the answers appended to the one file). I see no way of doing this within the GUI at this time, nor do I see any FPBX Commercial Modules that offer such a thing.

Does anyone have any thoughts on how to achieve this?

Essentially the workflow is:
Answer and play greeting.wav
play refill1.wav
record for 8 seconds
play refill2.wav
record for 10 seconds
play refill3.wav
record for 5 seconds
play refill4.wav
record for 8 seconds
Then email to: < TARGET ADDRESS > with Subject: < SUBJECT VARIES >
BODY: < CALLER NAME > < CALLER NUMBER >
ATTACHMENT: < COMPILED RECORDING >
Delete file.

FreePBX does not provide such modules. anyway you can write a customized dial plan to achieve your goal. Locate a file called /etc/asterisk/extensions_custom.conf and do it in there. Use Asterisk’s commands Like MixMonitor() , Playback and any linux command who allows you to send the email from command Line.

Ooo, that is a bit outside of my skillset - I don’t know the Asterisk command structure anywhere near well enough to pull off such custom dialplan entries. :frowning:

Use the ‘a’ option to record to append to a file.

https://wiki.asterisk.org/wiki/display/AST/Application_Record

Something like

exten => 1,1,Answer()
same => n,Playback(greeting)
same => n,Playback(refill1)
same => n,Record(myfile.extension,8,ak)
same => n,Playback(refill2)
same => n,Record(myfile.extension,10,ak)
same => n,Playback(refill3)
same => n,Record(myfile.extension,5,ak)
same => n,Playback(refill4)
same => n,Record(myfile.extension,8,ak)
same => n,System(script to email file here)
same => n,Playback(goodbye)
same => n,Hangup()

Ok, this is beautiful. :slight_smile: . Since it’s recording to a specific file name, what happens when 2 people call in at once and run through it? Does the temp file need to have a random element to it’s name (if that’s even possible)?

You can use the ${UNIQUEID} variable to get a filename that is call specific.

So, based on this, here’s what I ended up creating:

[macro-campaign-refill]
exten => 1,1,Answer()
same => n,Playback(greeting)
same => n,Playback(refill1)
same => Record(${UNIQUEID},8,ak)
same => n,Playback(refill2)
same => Record(${UNIQUEID},10,ak)
same => n,Playback(refill3)
same => Record(${UNIQUEID},5,ak)
same => n,Playback(refill4)
same => Record(${UNIQUEID},8,ak)
same => n,System(script to email file here)
same => n,Playback(goodbye)
same => n,Hangup()

However, it drops the call with the following error:
Channel ‘SIP/1602-000007b1’ sent to invalid extension but no invalid handler: context,exten,priority=macro-campaign-refill,s,1

I’m using a CUSTOM DESTINATION with the following target:
macro-campaign-refill,s,1

(similar to a couple custom destinations I have that call scripts for rebooting the system (password-protected, of course).

You need the ‘n’ priority on your Record lines, I forgot them in my initial example.

Also you need to specify the file format so Record(${UNIQUEID}.wav,5,ak)

I’m not a FreePBX guy but I think you need to call this as Macro(campaign-refill), it looks like you may be trying to do a goto instead.

OK, tweaked to be this:
[macro-campaign-refill]
exten => 1,1,Answer()
same => n,Playback(greeting)
same => n,Playback(refill1)
same => n,Record(${UNIQUEID}.wav,8,ak)
same => n,Playback(refill2)
same => n,Record(${UNIQUEID}.wav,10,ak)
same => n,Playback(refill3)
same => n,Record(${UNIQUEID}.wav,5,ak)
same => n,Playback(refill4)
same => n,Record(${UNIQUEID}.wav,8,ak)
same => n,System(script to email file here)
same => n,Playback(goodbye)
same => n,Hangup()

Same error…

In FPBX, there’s a module for Custom Destinations, that lets you route a dialed number to a dialplan anchor (in this case [macro-campaign-refill]. I do something identical to this for another macro I have called [macro-reboot], and it’s laid out the same way, so I would expect this to function as well.

As a side-note, here’s what that reboot macro looks like:
[macro-reboot]
exten => s,1,Authenticate(1234)
exten => s,n,NoOp(Looks like we’re going to reboot!)
exten => s,n,Playback(vm-goodbye)
exten => s,n,System(/usr/bin/sudo /sbin/shutdown -r -t 1)
exten => s,n,hangup()

Macros must use the ‘s’ extension.

And Macros are very similar in function to the Gosub application which deprecates Macro. You should really use Gosub wherever you would have previously used Macro.

https://wiki.asterisk.org/wiki/display/AST/Macros

Oooo, not sure I’d know how to convert that to the new syntax - not very skilled on the back-end scripting.

Here’s the Dialplan entry FPBX generated to actually call the macro:

exten => 1609,1,Noop(Running miscapp 4: CAMPAIGN TEST)
exten => 1609,n,Macro(user-callerid,)
exten => 1609,n,Goto(macro-campaign-refill,s,1)

Yeah it’s doing a Goto not a Macro call.

I’d just rename your context to [campaign-refill]

and try it as the destination of campaign-refill,s,1

I thought those names were merely placeholders (that it starting with “macro” didn’t mean it was a macro, just that it was a name reference.

I made the requested changes everywhere (removed “macro-” from the name so it is now just “campaign-refill”), and it still failed.

BUT I did notice something I hadn’t before:
Channel ‘SIP/1602-00000819’ sent to invalid extension but no invalid handler: context,exten,priority=campaign-refill,s,1

“Priority=” the name of the target. Me think’s there’s something wrong with comma-separated commands somewhere, so the priority is essentially an invalid value.

And of course, I could be completely wrong. lol

from the asterisk console can you do a ‘dialplan show’ and paste the output block for [campaign-refill] ?

Macro’s are special contexts that do behave differently if you call them with the Macro command vs doing a Goto.

[ Context ‘campaign-refill’ created by ‘pbx_config’ ]
‘1’ => 1. Answer() [pbx_config]
2. Playback(greeting) [pbx_config]
3. Playback(refill1) [pbx_config]
4. Record(${UNIQUEID}.wav,8,ak) [pbx_config]
5. Playback(refill2) [pbx_config]
6. Record(${UNIQUEID}.wav,10,ak) [pbx_config]
7. Playback(refill3) [pbx_config]
8. Record(${UNIQUEID}.wav,5,ak) [pbx_config]
9. Playback(refill4) [pbx_config]
10. Record(${UNIQUEID}.wav,8,ak) [pbx_config]
11. System(script to email file here) [pbx_config]
12. Playback(goodbye) [pbx_config]
13. Hangup() [pbx_config]

Also:
[ Context ‘app-miscapps’ created by ‘pbx_config’ ]
‘0’ => 1. Noop(Running miscapp 1: ATTENDANT) [pbx_config]
2. Macro(user-callerid,) [pbx_config]
3. Goto(ext-queues,1600,1) [pbx_config]
‘1609’ => 1. Noop(Running miscapp 4: CAMPAIGN TEST) [pbx_config]
2. Macro(user-callerid,) [pbx_config]
3. Goto(campaign-refill,s,1) [pbx_config]

Also:
[ Context ‘customdests’ created by ‘pbx_config’ ]
‘dest-1’ => 1. Noop(Entering Custom Destination SYS–SHUTDOWN) [pbx_config]
2. Goto(macro-shutdown,s,1) [pbx_config]
‘dest-2’ => 1. Noop(Entering Custom Destination SYS–REBOOT) [pbx_config]
2. Goto(macro-reboot,s,1) [pbx_config]
‘dest-3’ => 1. Noop(Entering Custom Destination Campaign Test) [pbx_config]
2. Goto(campaign-refill,s,1) [pbx_config]

Another thought, that I’m sure probably has nothing to do with it. What are the double commas on each “record” line of the script?
same => n,Record(${UNIQUEID}.wav,10,ak)

…wav,10,ak…

I feel like something’s missing there that makes it mad.

OK so the problem is my example configuration was extension 1, you need to change your

[campaign-refill]
exten => 1,1,Answer()

to

[campaign-refill]
exten => s,1,Answer()

The double commas are there because I’m not specifying an option that goes between them

I won’t even pretend to know why the change from 1 to s worked, but it did. She answers now. Will it automatically delete the temp file after it’s done (haven’t tested/checked that yet)? Also, where does it place this file so I can even look to see if it’s removing it?

Thank you for finding that!!! :slight_smile:

It doesn’t delete the file, it’s placing it in your default sound directory which may be /var/lib/asterisk/sounds

Have you written the script to email the file yet? You can delete the file after you email it.