Tag Archives: Connection

Command-line mailbox downloader for Cisco Unity Connection

Starting in version 8 of Cisco Unity Connection, it is simple to write scripts to manipulate various aspects of Unity Connection, including user attributes (password/PIN, for example), messages, call handlers, and more, thanks to a new REST API. There are interfaces to both administrative and end-user functions. And not only scripts, but custom web portals or other web integrations. No SOAP and AXL required!

See Cisco’s DocWiki for the details: http://docwiki.cisco.com/wiki/Cisco_Unity_Connection_APIs
And read the rest of this entry for a simple PHP script that connects to a user’s mailbox, dumps all the contents to a local folder, writes out a table of contents and gzips the whole thing up.
#!/usr/bin/php <?php if ($argc !== 3) {   fwrite(STDERR, "Usage: n");   fwrite(STDERR, "  php $argv[0] <mailbox> <password>n");   exit(1); } /* Web connection setup */ $baseURL = "https://YOUR-UCONN-SERVER-HERE:8443"; $auth = base64_encode("$argv[1]:$argv[2]"); $opts = array( 'http' => array ('method' => 'GET',                                 'timeout' => 4,                                 'header' => "Authorization: Basic $auth"),                'ssl' =>  array ('allow_self_signed' => TRUE)              ); $context = stream_context_create($opts); /* Get the user's folders list and counts */ $foldersURL = "$baseURL/vmrest/mailbox/folders"; if (!($result = file_get_contents($foldersURL, false, $context))) {   fwrite(STDERR, "Could not connect to Unity Connection for mailbox folders list.n");   exit(1); } $folders = simplexml_load_string($result); /* Now get contents of each mailbox that has messages */ $currtime = datestring(time()); $outputdir = $argv[1] . "_$currtime"; if (!mkdir($outputdir)) {   fwrite(STDERR, "Couldn't create directory $outputdirn");   exit(1); } $INDEX = fopen("$outputdir/index.txt", 'w'); $mainheader = "Mailbox of $argv[1] downloaded at $currtime"; fwrite($INDEX, "$mainheadern" . sprintf("%'=" . strlen($mainheader) . "snn", "")); foreach ($folders as $folder) {   if ($folder->MessageCount > 0) {     $folderheader = "Folder: $folder->DisplayName";     fwrite($INDEX, "$folderheadern" . sprintf("%'-" . strlen($folderheader) . "snn", ""));     $messagedir = $outputdir . "/" . $folder->DisplayName;     mkdir($messagedir);     $result = file_get_contents($baseURL . $folder->URI . "/messages", false, $context);     $xml = simplexml_load_string($result);     $counter = 1;     foreach ($xml->Message as $message) {       fwrite($INDEX, "$counter. Message from ". ($message->CallerId->CallerName == ""?"(no name listed)":$message->CallerId->CallerName));       fwrite($INDEX, " at " . ($message->CallerId->CallerNumber == ""?"(no number listed)":$message->CallerId->CallerNumber));       fwrite($INDEX, "n");       fwrite($INDEX, "Listened: " . $message->Read . "n");       fwrite($INDEX, "Length: " . $message->Duration/1000 . " secondsn");       fwrite($INDEX, "Timestamp:" . datestring($message->ArrivalTime/1000) . "n");       fwrite($INDEX, "Filename: ");       $filename = datestring($message->ArrivalTime/1000) . "_from_" . $message->CallerId->CallerNumber . ".wav";       fwrite($INDEX, "$filenamenn");       $innerResult = file_get_contents($baseURL . $message->URI, false, $context);       $messageContainer = simplexml_load_string($innerResult);       $audio = file_get_contents($baseURL . $messageContainer->Attachments->Attachment->URI, false, $context);       if (!file_put_contents("$messagedir/$filename", $audio, LOCK_EX))         fwrite(STDERR, "Error writing audio to file: $filenamen");       $counter++;     }     fwrite($INDEX, "n");   } } fclose($INDEX); $tarresult = system("tar czf $outputdir.tar.gz $outputdir"); if ($tarresult !== FALSE) {   system("rm -rf $outputdir"); } else {   fwrite(STDERR, "Unable to create tar.gz file, but the folder is still there.n"); } fwrite(STDERR, "Mailbox dump completed successfully.n"); exit(0); function datestring ($unixtime) {   return date('Y-m-d_H-i-s', $unixtime); } ?>

What may drive opening the Unity Connection web interface

At this week’s meeting of the PSU VoIP tech folks, we had a short review of the Unity Connection upgrade from a couple weeks ago and discussed getting to the next version, 8.x, where we will have the ability (though not the scripting and configuration, yet) to open the web interface to end users.

I think the primary feature of interest to end users on the web interface will be the visual voicemail, called Unity Connection Inbox. But what may drive getting the web interface up and running, at first, will be the ability for end users to change their own PIN.

Very roughly speaking, from some stats I received a few weeks ago, our NOC gets about 1,000 voicemail PIN resets a year. They account for 18% of all voice-related tickets and 11,000 minutes of staff time.

With the web interface, voicemail users could log in with other credentials they know and use daily–their single sign-on access accounts–and reset their voicemail PIN. The concept is simple but the implementation, at least in our environment, may not be.

PSU voicemail upgrade – Unity Connection 7

This Friday, the University Park VoIP voicemail system, currently Cisco Unity 4.0.5, will be upgraded–migrated, actually–to Unity Connection 7. A number of us received training on this last fall, and we are eager to move ahead to the new system.

In terms of features, this is a one-for-one migration–no features lost, and no features added at the time of the upgrade. We have been running Unity in voice-mail-only (VMO) mode, where an Exchange mail system acts as the voice mail storage facility and nothing more–no e-mail integration, web access, or other Exchange features. Connection is designed for the VMO-type deployment, so while the feature set remains the same, we are gaining a lot with this upgrade, administratively:

  • no more Exchange
  • no more domain management to support an isolated Exchange
  • no more Microsoft patching for the above
  • two messaging servers rather than two (Unity) + two (DC) + two (Exchange) = six
  • Cisco Linux platform, including the better Disaster Recovery System (DRS) and upgrade/patch deployment

And lastly, this gets PSU un-stuck from 2004 and able to move ahead more easily as new versions or features come along.

Coworkers Chris (who needs to update his blog) and Sean are the ones making this happen. Huge thanks, guys.

Going beyond the straight migration of this weekend, what’s next? I wrote about some end-user web features we saw in training:

End-user Web Features
  • Unity assistant – per-user settings manager, like Communications Manager User Options site
  • Unity inbox – view, listen to, forward, reply, etc. to voice messages. Play messages through the web browser or download to PC.

I believe that with some reconfiguration on the back end having to do with the way accounts are keyed (need some affiliation with the PSU access account ID), a proxy written similar to what we did with Call Manager 6, and some gentle but consistent pressure from users for such useful features, we could enable the two listed above. And in time, and depending on where University e-mail is headed presently, we may even be able to deposit voicemail in people’s e-mail boxes. (NOTE: this is my wishlist and not a statement that these things are planned or that I am even working on them… but I’d like to.)