Avatar of OAC Technology
OAC Technology
Flag for United States of America asked on

Barge voicemail calls on T1 PRI with Asterisk.

I am going to be setting up an Trixbox 2.8  (asterisk 1.6) PBX using a T1 PRI card and was wondering if there is any way to barge a voicemail call while someone is leaving a voicemail?  For example, if I'm on the phone and miss a call coming in that goes to my extension voicemail, is it possible for me to listen in on the person leaving the voicemail and take over the call if I want to talk to the person right away?

I have Aastra 57i and 9143i IP phones that I am using.
IP Telephony

Avatar of undefined
Last Comment
OAC Technology

8/22/2022 - Mon
Ron Malmstead

That's a good one.....

I'm not sure how you would modify the trixbox stock dialplan...but if this were open source asterisk, then I would say it could be done, with a bit less headache.

You can definitely chanspy(zap/1-2... but since the channel is already connected to vm app, you would need a method in which you can run a macro on that channel, to transfer that call back to the original extension.

The one issue I see...is that someone would probably leave a message faster than you can spy on the channel, and then decide to transfer them back to your second line.

....almost "anything" is possible with Asterisk, but this could get very tricky/technical....so the real question is....how badly do you want this ?
DrDamnit

No. This is unfortunately not available in asterisk because the Voicemail application (Comedian mail) does not support it.
DrDamnit

See....

nothing about barge or spy in the application information:
-= Info about application 'VoiceMail' =- 

[Synopsis]
Leave a Voicemail message

[Description]
  VoiceMail(mailbox[@context][&mailbox[@context]][...][|options]): This
application allows the calling party to leave a message for the specified
list of mailboxes. When multiple mailboxes are specified, the greeting will
be taken from the first mailbox specified. Dialplan execution will stop if the
specified mailbox does not exist.
  The Voicemail application will exit if any of the following DTMF digits are
received:
    0 - Jump to the 'o' extension in the current dialplan context.
    * - Jump to the 'a' extension in the current dialplan context.
  This application will set the following channel variable upon completion:
    VMSTATUS - This indicates the status of the execution of the VoiceMail
               application. The possible values are:
               SUCCESS | USEREXIT | FAILED

  Options:
    b    - Play the 'busy' greeting to the calling party.
    g(#) - Use the specified amount of gain when recording the voicemail
           message. The units are whole-number decibels (dB).
           Only works on supported technologies, which is Zap only.
    s    - Skip the playback of instructions for leaving a message to the
           calling party.
    u    - Play the 'unavailable' greeting.
    j    - Jump to priority n+101 if the mailbox is not found or some other
           error occurs.

Open in new window

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Ron Malmstead

...I'll try to write something to start you out.
You will have to test this yourself...I recommend doing it on a "test box"...not a production server.

Things we need to "possibly" make this work.
First... we need a feature...that will transfer a call back to you.  This feature will have to be able to know the channel that is connected to your vm box.

features.conf

[applicationmap]
sendback => *3,caller,macro,backsend
-----------------------------------------------------------

Now for the dialplan...

Extensions.conf
;We also need an extension we can call...that will monitor the zap/dhadi channel that is connected to vm.
exten => 9999,1,Answer()
exten => 9999,n,Set(__meext=${CDR(src)}); set my extension as a variable
exten => 9999,n,ReadFile(__chantovm=/var/monitorvm/${meext}.txt); Set the channel prefix as a variable by reading a file.  This file is created right before a call is sent to vm
exten => 9999,n,Set(DYNAMIC_FEATURES=sendback); add sendback as an allowed feature.
exten => 9999,n,ChanSpy(chantovm)
exten => 9999,n,Hangup()

;Add a macro to the dialplan...  This macro is the feature that will fire.
[macro-backsend]
exten => s,1,Playback(beep);beep indicates the macro is firing
exten => s,n,ChannelRedirect(${chantovm},default,${meext},1)


[internal-phones]
exten => _3XXX,1,Dial(SIP/${EXTEN},30)
exten => _3XXX,n,System(echo "${CDR(channel)}" > /var/monitorvm/${EXTEN}.txt)
exten => _3XXX,n,VoiceMail(${EXTEN}@internal-phones,u)




Ron Malmstead

Call extension 9999.... after the beep... the idea is that you will be spying on the zap channel... then if you want to send the call back to you... you dial *3...

...fingers crossed...
I wrote this on the fly.
OAC Technology

ASKER
Thank you very much, I'll give it a try once we get everything set up
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
DrDamnit

OOOooooo.... that actually looks promising....

Looking forward to seeing if it works!
OAC Technology

ASKER
I was also wondering, is this possible with SIP trunking as well, or only ZAP?
Ron Malmstead

It works on sip channels....as well as zap channels.

The only issue with sip channels, is that they have a unique identifier added onto them, which would need to be stripped off... using ":"
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Ron Malmstead

The idea would be to turn the channel output that appears as .....   SIP/3300-2ad92fe34...into SIP/3300
Then chanspy()
OAC Technology

ASKER
I'm new to asterisk coding, I just need to replace certain things in the above script with SIP/3300: to make it work with SIP?  Thanks again for all the help
Ron Malmstead

Just before an incoming call goes to voicemail... .this file is written...
exten => _3XXX,n,System(echo "${CDR(channel)}" > /var/monitorvm/${EXTEN}.txt)

If this is a SIP channel... the channel name will look like  .... SIP/3300-2e2a3ff34g
So, what we want... is to only take the first 8 characters when we execute chanspy().

For this... I would suggest the following...
First check if the variable "chantovm" is in fact a sip channel....then if it is... we strip off only use the first 8 chars, otherwise we use all chars.
...this line below, will Set() the chantovm variable, using the first 8 characters, only if the first 3 characters of the chantovm variable = "SIP".... otherwise it leaves it untouched.
exten => 9999,n,ExecIf("${chantovm:0:3}" = "SIP",Set,${chantovm}=${chantovm:0:8})
exten => 9999,n,ChanSpy(chantovm)

I'm a little iffy on whether a zap/1-1 channel will be written to the file as zap/1-1, ...or simply 1-1....You will have to test that.  I believe the proper way to execute chanspy is to use... SIP/3300 or ZAP/1-1 for example.... so in case the channel is written to the file as 1-1... you will have to append ZAP to it.....  (${chantovm}=ZAP/${chantovm}

...there are many ways to do this obviously....

While testing....make use of the NoOP() command.... so you can see what is happening with the variables in the CLI....    example......... exten => 9999,n,NoOp(Channel variable is currently - ${chantovm})

...this way you can see visually, if the var is correct....
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Ron Malmstead

...alternatively for zap channel if the channel is written 1-1, you can change it like so...

If not "SIP".....  append a "zap/" on the beginning...
exten => 9999,n,ExecIf("${chantovm:0:3}" <> "SIP",Set,${chantovm}=ZAP/${chantovm})
OAC Technology

ASKER
When I dial 9999, I get "Your call cannot be completed as dialed."  I've tried changing it to 1111 as well, so it will not try to use the outbound route and I still get the same message.  Any idea on what I'm doing wrong?

Thank you
ASKER CERTIFIED SOLUTION
Ron Malmstead

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
OAC Technology

ASKER
Still unable to get this to work. I will post my extensions.conf shortly.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
OAC Technology

ASKER
I've attached my extensions.conf.  When I dial 1111, I get a beep but nothing else.  My phone context is "from-internal."  Any ideas on what else I can do?

Thank you
DrDamnit

Not seeing where you attached extensions.conf
Ron Malmstead

Please post your extensions.conf file....
Also, please post some CLI output when you try the feature.

Probably either a syntax error on my part, or yours.
(still working under the assumption that this is even possible)   :)
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
OAC Technology

ASKER
Sorry about that, it looks like EE didn't accept the file earlier.  I've reattached.

CLI after dialing 1111 is below
 -- Executing [1111@from-internal:1] Answer("SIP/102-b7bbd698", "") in new stack
    -- Executing [1111@from-internal:2] Set("SIP/102-b7bbd698", "__meext=102") in new stack
    -- Executing [1111@from-internal:3] ReadFile("SIP/102-b7bbd698", "__chantovm=/var/monitorvm/102.txt") in new stack
    -- Executing [1111@from-internal:4] Set("SIP/102-b7bbd698", "DYNAMIC_FEATURES=sendback") in new stack
    -- Executing [1111@from-internal:5] ChanSpy("SIP/102-b7bbd698", "chantovm") in new stack
    -- <SIP/102-b7bbd698> Playing 'beep' (language 'en')

Open in new window

extensions.txt
Ron Malmstead

exten => 1111,n,ChanSpy(${chantovm}) ; syntax
Ron Malmstead

my fault....
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
OAC Technology

ASKER
Hmm, still nothing.  I did notice that there is never a .txt file created in /var/monitorvm.  
Ron Malmstead

exten => _3XXX,n,System(echo ${CDR(channel)} > /var/monitorvm/${EXTEN}.txt)

Can you change that...then post the output when you call an extension in the 3000's ??
OAC Technology

ASKER
IF all my extensions are in the 100's, do I just change this to exten => _1XX?

Thanks
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Ron Malmstead

"IF all my extensions are in the 100's, do I just change this to exten => _1XX?"...

Yes.. that would work.
OAC Technology

ASKER
I really appreciate all your help everyone, but this still isn't working for me. Are there any other suggestions or something I could post to help?
Ron Malmstead

After looking at the post here...from the start... I noticed that you are running Asterisk 1.6.x... in which case.....    the Set() program, should be MSet().  My fault on that....
Change that then tell me exactly which part isn't working..


First...
Is the file created ?
Getting the file to be created is the key first step.  You might try another directory, (does the directory exist)..., might also be permissions related.

Next...
Is the file read when you dial the spy exten ?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
OAC Technology

ASKER
I don't think the file is being created.  I've tried switching to the /var/spool/asterisk/monitor folder (since I know asterisk can read/write to that directory) and still no go
Ron Malmstead

Try this without the quotes....then the file should be created.

exten => _3XXX,n,System(echo ${CDR(channel)} > /var/monitorvm/${EXTEN}.txt)
Ron Malmstead

I think the quotes were messing it up, because this works for me.

exten => _3XXX,n,System(echo ${CDR(channel)} > /var/spool/asterisk/monitor/${EXTEN}.txt)
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
OAC Technology

ASKER
Hmm, I still do not get a txt file.  I will play around with it this week and see if I can find why it is not making the file.  Thanks again
Ron Malmstead

Some output from the CLI would be helpful.

Could you post something when you play around with this today ?
Ron Malmstead

..you might also try executing this line from a terminal window as well...

echo TEST > /var/spool/asterisk/monitor/test.txt

or,

sudo echo TEST > /var/spool/asterisk/monitor/test.txt

Your help has saved me hundreds of hours of internet surfing.
fblack61
OAC Technology

ASKER
Sorry I haven't been able to take a look at this lately.  I will take another look at it next week and see if we can get this sorted out.  Thanks for all your help on this
Ron Malmstead

Sounds good.
OAC Technology

ASKER
What's the best way to get all of the CLI information into a text file so I can post it here?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.