January 10, 2008

Switchvox new voicemail email -> SMS notification

Switchvox offers a wonderful email notification feature for new voicemail messages, but what if you are not at your computer? Naturally, the first thing that comes to mind is to forward those email notifications to your cell-phone via SMS.


Email notification sent by the PBX looks approximately like the one below:

From: SwitchvoxPBX
Sent: Thursday, January 10, 2008 2:42 PM
To: John Doe
Subject: New message 8 in mailbox 102

Dear John Doe:

Just wanted to let you know you just received a 0:02 long message (number 8) in mailbox 102 from "MARY JANE" <18001234567>, on Thursday, January 10, 2008 at 02:42:04 PM so you might want to check it when you get a chance.

You can check your message via the phone or use the links below to download your message:

Use the link below to just download the voicemail.
*Note* This does not mark it as read in the system.
https://SwitchvoxPBX/main?cmd=play_voicemail&msgnum=1

Use this link below to download the voicemail and mark it as read.
*Note* This will move this voicemail message to your Old folder and this link will no longer work.
https://SwitchvoxPBX/main?cmd=play_voicemail&msgnum=1&mark=read

Use this link below to download the voicemail and delete it.
*Note* This will completely remove the voicemail from the system and this link will no longer work.
https://SwitchvoxPBX/main?cmd=play_voicemail&msgnum=1&mark=delete

Thanks!

The quick and dirty way to forward this to your cell-phone is by using Outlook’s rules: this would simply forward the message to your cell-phone’s email address (most wireless providers offer this feature). However, all you will get is most likely part of the message that ends with words “… received message (number 8) in mailbox”, because SMS message has a limit on the number of characters (sender’s email, subject will also be included and will eat up characters. Isn’t it frustrating? You receive SMS notification about new voicemail, but you don’t know who called, when, and if they actually left a message, or hung up realizing you are not there, because the message got trimmed due to character limit.

If you look at the Outlook’s rule actions, you might notice “run a script” option, which is triggered when rule conditions are true, and this is exactly what I need: grab a message, take only the information I need and send it to my cell-phone.

So, launch your Outlook if it is not already running and hit Alt-F11 or go to Tools > Macro > Visual Basic Editor and paste the following script:

   1:  Public Sub ForwardSMS(Item As MailItem)
   2:      ' Do not run during business hours
   3:       If Time() < #8:00:00 AM# Or Time() > #5:00:00 PM# Then
   4:      ' Check to make sure it is an Outlook mail message, otherwise
   5:      ' subsequent code will probably fail depending on what type
   6:      ' of item it is.
   7:      If TypeName(Item) = "MailItem" Then
   8:          Dim msgBody As String : msgBody = Item.Body
   9:          Dim oRegExp, oMatches, oMatch, strDuration, strMsgNumber, strMsgInfo, strResult
  10:          strResult = ""
  11:          Set oRegExp = CreateObject("VBScript.RegExp")
  12:          oRegExp.Pattern = ".*\n\s*.*you just received a (.*) long message \(number ([\d:]*)\) in mailbox \d\d\d from (.*) so you might want to check it.*"
  13:          Set oMatches = oRegExp.Execute(msgBody)
  14:          For Each oMatch In oMatches
  15:          If oMatch.SubMatches.Count = 3 Then
  16:                  strDuration = oMatch.SubMatches(0)
  17:                  strMsgNumber = oMatch.SubMatches(1)
  18:                  strMsgInfo = oMatch.SubMatches(2)
  19:              strResult = strResult & "Message number " & strMsgNumber & " (" & strDuration & ") received from " & strMsgInfo & VbCrLf
  20:          Else
  21:              strResult = strResult & oMatch.Value & vbCrLf
  22:          End If
  23:          Next
  24:          Set oMatches = Nothing
  25:          Set oRegExp = Nothing
  26:          
  27:          Dim oEmail As Object
  28:          Set oEmail = Application.CreateItem(olMailItem)
  29:          oEmail.Body = strResult
  30:          oEmail.Recipients.Add "1234567@my_wireless_provider.com"
  31:          oEmail.Send
  32:          Set oEmail = Nothing
  33:        End If
  34:        End If
  35:  End Sub

Customize if necessary. Few notes:

  1. Line 3 checks for business hours (so that script runs only when you are away from the computer). In case you want the script to always do its job, then remove line 3 and the corresponding line 34.
  2. Line 12 has a regular expression to get only required information from notification email's body. Change the expression if your notification text is different from the one displayed at the beginning of this post.
  3. Line 30 specifies email address of your cell-phone. You can also create a contact in Outlook (with the needed email) and instead of specifying email address in the script, you can specify contact's name here.

Close the Visual Basic Editor. Then go to Tools > Rules and Alerts in your Outlook to create a rule, that would take notification messages from your Switchvox PBX and then select “run a script” for the rule’s action. When you click on the word ‘script’, a dialog box should pop up, showing the list of scripts. Select ForwardSMS (script’s name is specified in line 1 in the code above). Please note, that this is a client-side rule. This means that Outlook must be running for the rule and script to work!

Now, when you receive your next notification email, the rule you created should trigger the script. As a result, you will receive SMS message on your cell-phone which would look like this:

johndoe@domain.com Message number 8 (0:02) received from "MARY JANE" <18001234567>, on Thursday, January 10, 2008 at 02:42:04 PM

Now, when you get such SMS it is clear who called, when, and that the person didn't actually leave a message (very short duration time is a hint).

Hope someone will find this useful :-)

UPDATE: As it was pointed out in the first comment to this post, Switchvox SMB allows you to achieve the described behavior (custom notifications) via bult-in functionality. However, the one used in our office is a Switchvox SOHO, which apparently does not offer the Custom Voicemail Message Notification.

13 comments:

Anonymous said...

Another way to get VM notifications to your cell is to do it through the Switchvox interface.
You can either do this as an admin and change the email for everybody, or you can ask your admin to grant your extension the ability to edit your voicemail notification email.
If you have admin access, you can just navigate to System Setup --> Voicemail Settings and change it in section 4.
If you get your admin to let you edit the template for just your own extension, log in to your extension's interface in the Switchvox and go to Voicemail --> Voicemail Options and change it in section 4.
I have done this for my extension because I like to have the notifications go out to my cell phone. The message looks like this:
Received a %VM_DUR% long message from %VM_CALLERID%.
%DOWNLOAD_LINK%
Also, make sure you change the email address where notification emails get sent. You'll find this under Settings --> Modify Account. If you want them to go to more than one address, its a little more complicated because there are so many ways to do that, but suffice it to say, it can be done. :)
Maybe you already knew this and was looking for another way, but hopefully this is helpful to someone.
-T

haltenberg said...

Well, I guess I should have specified the version of Switchvox at the very beginning. Your tip about changing voicemail settings in section 4 of the System Setup is nice, but Switchvox SOHO has only two sections. Therefore, I do not see any other way to achieve the desired behavior (receive an email notification with attached wav message as well as get a nice cellphone notification).

Dave Michels said...

Great ideas. But how do you put in two email addresses for notification (1 for email and 1 for SMS)?

haltenberg said...

Dave,
The Recipients collection can have multiple email addresses. Just call oEmail.Recipients.Add method as many times as needed.

Anonymous said...

I am able to get it to fire when I receive the voicemail notification from my switchovx but the Sent email shows is in my SENT email folder is blank..so the SMS is blank..

Anonymous said...

I just posted the last post. When the *Client-side) rule fires, I get a popup window that a program is trying to access email-addresses you have stored in Outlook, do you wna to allow this?

I select YES and the SENT email is created and I see it in my Sent folder, but it is blank no text. Here is the VBscriptI copied. I changed the email address to my cell and the (If time) line as well.

Public Sub ForwardSMS(Item As MailItem)

' Do not run during business hours

If Time() < #8:00:00 AM# Or Time() > #10:00:00 AM# Then

' Check to make sure it is an Outlook mail message, otherwise

' subsequent code will probably fail depending on what type

' of item it is.

If TypeName(Item) = "MailItem" Then

Dim msgBody As String: msgBody = Item.Body

Dim oRegExp, oMatches, oMatch, strDuration, strMsgNumber, strMsgInfo, strResult

strResult = ""

Set oRegExp = CreateObject("VBScript.RegExp")

oRegExp.Pattern = ".*\n\s*.*you just received a (.*) long message \(number ([\d:]*)\) in mailbox \d\d\d from (.*) so you might want to check it.*"

Set oMatches = oRegExp.Execute(msgBody)

For Each oMatch In oMatches

If oMatch.SubMatches.Count = 3 Then

strDuration = oMatch.SubMatches(0)

strMsgNumber = oMatch.SubMatches(1)

strMsgInfo = oMatch.SubMatches(2)

strResult = strResult & "Message number" & strMsgNumber & " (" & strDuration & ") received from " & strMsgInfo & vbCrLf

Else

strResult = strResult & oMatch.Value & vbCrLf

End If

Next

Set oMatches = Nothing

Set oRegExp = Nothing

Dim oEmail As Object

Set oEmail = Application.CreateItem(olMailItem)

oEmail.Body = strResult

oEmail.Recipients.Add "678491xxxx@vtext.com"

oEmail.Send

Set oEmail = Nothing

End If

End If

End Sub

haltenberg said...

Yes, you have to allow the script to be run. In order to work-around the pop-up dialog every time you might want to adjust the security settings in Outlook. Otherwise, if the script is "installed" properly, the pop-up will appear only once: when Outlook is launched.

If your sent email is blank, please do a test: change line 29 in my post's code from oEmail.Body = strResult to oEmail.Body = "This is a test" or something like that. If your sent mail now has this phrase (i.e. if this works), then there must be a problem with the regular expression. The message sent by your Switchvox might be different from mine, and therefore the regular expression in line 12 might need tweaking.

Anonymous said...

I got it to fire and send a SMS message when I changed Line 29 as you suggested. The popup still odesn't work though..my security setting is set to Low which is the lowest it can go. I'll google this issue and see what I can find.

Here is a copy of what the Switchvox sends to my email address.

Dear John Doe:

Just wanted to let you know you just received a 0:03 long message (number 1) in mailbox 5604 from 678491xxxx, on Monday, November 24, 2008 at 01:40:11 PM so you might want to check it when you get a chance.

You can check your message via the phone or use the links below to download your message:

Use the link below to just download the voicemail.
*Note* This does not mark it as read in the system.
https://xx.xx.xxx.xxx/main?cmd=play_voicemail&msgnum=0

Use this link below to download the voicemail and mark it as read.
*Note* This will move this voicemail message to your Old folder and this link will no longer work.
https://xx.xx.xxx.xxx/main?cmd=play_voicemail&msgnum=0&mark=read

Use this link below to download the voicemail and delete it.
*Note* This will completely remove the voicemail from the system and this link will no longer work.
https://xx.xx.xxx.xxx/main?cmd=play_voicemail&msgnum=0&mark=delete


Thanks!

haltenberg said...

Your mailbox number is 4 digits, while my original script expects 3. Please change \d\d\d in line 12 to ([\d:]*) or to \d\d\d\d. Don't forget to revert the test change you've made to line 29 :)

Anonymous said...

thanks tht did it.

call center solutions provider said...

I really admire this, I mean it really looks interesting! Very nice write up. Anyways, its a Great post

HGH Human Growth Hormone said...

constantly i used to read smaller posts which as well clear their motive, and that is also happening with this paragraph which I am reading at this time.

Atlanta Contract Staffing said...

I'd like to thank you for the efforts you've put in penning this site.