Custom Destination to Voicemail

Hi everyone,

So, I have a FreePBX with asterisk and I have the next flow:

  1. Caller call and get in on IVR;
  2. If he choose 1 or 2, get inside a Ring Group;
  3. If no one answer the call, he get in my Custom Destination that you can find in the fórum if you search by this title How to get Inputs from IVR freepbx (Sory but i can’t put links on the topic)

So, what I need is, in the Custom Destination as you can figure out on the link, if the caller insert the pin and confirm that is correct, i want that the call go direct to the voicemail.

How can I do it?

@dickson can you give me some help? The Custom Destination that I applied was given by you in another topic.

Maybe this post is helpful:

Thanks for the reply and help :slight_smile:

The custom destination that i have is the solution given by @dickson

Can you give me some help to do what I need? I’m a kind of noob on this. It’s the first time working with custom destinations, etc, by the CLI.

@lgaetz I studied that and I still cant get on it :confused:

I’ve been away from the forums for a bit, i’ll open up the code this weekend and get a response to you!

Many thanks @dickson

Ok, so as I understand your request:

After the caller “accept” the digits they entered in (and the system saves it) , you want the call to go directly to a voicemail box and have the mailbox play an UNAVAILABLE message?

If that is accurate, then follow the instructions below, otherwise let me know!

My original code example, at the very end of it looked like this:

exten => s,n(writevalue),system(echo "${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)},${CALLERID(all)},${UNIQUEID},${pinnumber}" >> /tmp/pincollected.txt)
exten => s,n,Return

Insert this between those two last lines:.

exten => s,n,Voicemail([email protected],u)

Change “900” in my example to the mailbox number you want to use on your system.
Should look something like this when you are done:

exten => s,n(writevalue),system(echo "${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)},${CALLERID(all)},${UNIQUEID},${pinnumber}" >> /tmp/pincollected.txt)
exten => s,n,Voicemail([email protected],u)
exten => s,n,Return

save your changes.
You’ll need to reload the config file
asterisk -rx 'core reload’

Give it a test!

1 Like

Hi @dickson

So I tested it and it’s working well and as I want. But before, when a call go to the end with no answer and get in on voicemail, after message recorded, he sent it as attachment to an email and now, isn’t work.

Another question. On the Playback messages, I want to playback some info from mp3 files, like we can change on IVRs. How can I do it there?


So, i put the sounds as I want after a little search like voicemail is already working as i want sending the emails. It was an error on voicemail config made by me.

One last ask, your Custom code are saving the PIN on a text file. Now I want to put it on the email that gonna be sent by voicemail. Explaining a little about the process:

I have a ticketing tool that are fetching an Inbox from a specified email. So, when the client call us and we don’t have no one to answer the call, the call get in this process. The client gonna put the Client ID, and record a message.

The message gonna be sent by asterisk to the email address that is fetched by the Ticketing Tool. I want the Client ID on the voicemail email for the tool can connect that call to the client profile on the Tool.

It is the last thing than need to be done, put the Client ID (In your code, the PIN) in the voicemail email.

Unfortunately, you can’t include a variable from asterisk into the voicemail body (last time i checked).
HOWEVER, how about tricking out the CallerID?

If you add this line " exten => s,n,set(CALLERID(num)=${CALLERID(num)}-${pinnumber})"
it should append the pinnnumber to the callers CallerID number that gets left in the voicemail.

Just insert it just before the “voicemail command” and that should do what you want! test and let me know.

exten => s,n(writevalue),system(echo "${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)},${CALLERID(all)},${UNIQUEID},${pinnumber}" >> /tmp/pincollected.txt)

exten => s,n,set(CALLERID(num)=${CALLERID(num)}-${pinnumber})

exten => s,n,Voicemail([email protected],u)
exten => s,n,Return

This will result in an email something like this. I entered in “344” as my number. You’ll see it with a -344 at the end of the caller’s number.

New voicemail in mailbox 900

From:	"John Smith" <5151234567-344>
Length:	0:35 seconds
Date:	Monday, January 28, 2019 at 09:31:22 PM

That is probably the best you’ll get in the current release. Maybe someone else reading has some thoughts?

Give to this guy a medal :blush:

Thanks a lot by your time and patience to help me like you help many others. You are the King.

The solution work so well and with this I could remove the number in totally cause he appears between comas before. My voicemail email are like: From: From: “931234567” <000111333>

Like this, with regex on the ticketing tool, I can filter and assign this emails to the new ticket with the phone to the person who is calling and to the company with the Client ID.

One more time, a big big big thanks from Portugal :wink:

Glad its working as you need!
And you are welcome! I’m just a small cog in a large collection of asterisk and FreePBX enthusiast! Glad to give back to the community that has helped me out for years and years.

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