[Asterisk-Dev] Voicemail Envelope (cid, date/time playback)

Brad Bergman bradley at bergman.ca
Fri Jun 27 15:46:52 MST 2003


Tilghman's datetime patch is very clever. If it were me, I would patch the
datetime part of say.c so that the better functionality was available more
generally....

I still think that message envelope is a legitimate feature of its own as
a way to obtain the number of the calling party as well as the date/time
if the user does not choose to have that information played automatically.
It is a fairly standard feature on other systems (Octel & Meridian for
example), and my recent experience with end users' reactions to Comedian
mail is, to paraphrase, "this is not exactly like my old voicemail; I
don't like it", and that, "things change, grow up" is not a satisfactory
response.

My suggestion would be to give users a "mailbox option" to turn on/off
automatic date/time playback at the start of a message according to the
default format that's specified in the .conf file, as well as a playback
option to play the calling party number & date/time, when requested. Octel
works this way.

Now that I think about all this, it should be possible to play the name of
internal callers that have recorded one in their own mailbox. Here's my
conceptualization of how to do it. I can see where there would be
confusion if multiple voicemail contexts were involved, since the context
of the message is that of the recipient, whereas the name is based on the
CID of a caller who could be in a different context. But anyways....

        /* Read calling party number or name */

        if (strlen(cid)) {
                ast_streamfile(chan, "vm-from", chan->language);
                ast_waitstream(chan, "");
                ast_callerid_parse(cid, &name, &num);
                snprintf(prefile, sizeof(prefile), "vm/%s/greet", num);
	/* If there's a mailbox matching the caller id say the name 
recorded there */
                if (strlen(prefile)) {
                        if (ast_fileexists(prefile, NULL, NULL) > 0) {
                                if (ast_streamfile(chan, prefile, 
chan->language) > -1)
                                    res = ast_waitstream(chan, "#0");
                        }
	/* Otherwise just say the number */
                else
                        ast_say_digit_str(chan, num, "", chan->language);
                }
	/* Or not */ 
        } else {
                ast_streamfile(chan, "unknown-caller", chan->language);
                ast_waitstream(chan, "");
        }



On Fri, 27 Jun 2003, John Todd wrote:

> 
> This is a good start!  However, your inspiration was perhaps too 
> well-founded.  Tilghman has created some really well thought-out 
> patches to do just what you're doing, with customizable date/time 
> zone speech syntax and per-user methods for date/time readout.  He's 
> said that he'll have some additional time to finish the patches and 
> apply to Voicemail and Voicemail2 shortly, but they're already almost 
> done from what I've seen.
> 
> His patches play the received times at the beginning of the message, 
> instead of as a DTMF sequence trigger inside the message.  I don't 
> find that to be too much of a problem, especially with the 
> customizable date/timestamps for each user or group (yes, there are 
> defaults.)
> 
> There is additional delay in that I have to get a handful of 
> recordings done to support the extensions, but that should be no big 
> deal.
> 
> JT
> 
> >Inspired by Tilghman Lesher's "Patch for voicemail date/time" and the
> >voicemail details that can be displayed on an ADSI phone, I thought I'd
> >see what I could do about an audible message envelope feature--something
> >that's commonly available on various voicemail systems. Not being a
> >programmer, I'd hesitate to call this a patch, more something worth (if
> >anything) a look, and I thought I'd see if anyone has any thoughts.
> >
> >A couple of obvious deficiencies: it relies on the precious spare '3' key
> >to trigger the envelope playback, the envelope can't be interrupted by any
> >DTMF sequence, and it uses voice prompts that don't exist... other than
> >that it seems to me to work okay.
> >
> >
> >diff -rcs app_voicemail2.c app_voicemail2.c.bwb
> >*** app_voicemail2.c 2003-06-27 03:14:43.000000000 -0600
> >--- app_voicemail2.c.bwb 2003-06-27 03:14:30.000000000 -0600
> >***************
> >*** 1999,2004 ****
> >--- 1999,2006 ----
> >             if (!res)
> >              res = play_and_wait(chan, "vm-toforward");
> >             if (!res)
> >+            res = play_and_wait(chan, "vm-getenvelope");
> >+           if (!res)
> >              res = play_and_wait(chan, "vm-savemessage");
> >           }
> >          }
> >***************
> >*** 2277,2282 ****
> >--- 2279,2289 ----
> >              cmd = play_and_wait(chan, "vm-messages");
> >             vms.starting = 1;
> >             break;
> >+
> >+         case '3':
> >+           cmd = message_envelope(chan, vms.fn);
> >+                                 break;
> >+
> >           case '4':
> >             if (vms.curmsg) {
> >              vms.curmsg--;
> >***************
> >*** 2613,2618 ****
> >--- 2620,2695 ----
> >         }
> >   }
> >
> >+
> >+ static int message_envelope(struct ast_channel *chan, char *fn)
> >+ {
> >+         int res = 0;
> >+         char filename[256], buf[256];
> >+         char cid[256];
> >+         char *name, *num;
> >+         char datetime[21]="";
> >+         char *val;
> >+         FILE *f;
> >+
> >+         time_t t;
> >+         /* Get envelope info */
> >+
> >+         snprintf(filename, sizeof(filename), "%s.txt", fn);
> >+
> >+         f = fopen(filename, "r");
> >+
> >+         if (f) {
> >+
> >+                 while(!feof(f)) {
> >+                         fgets(buf, sizeof(buf), f);
> >+                         if (!feof(f)) {
> >+                                 char *stringp = NULL;
> >+                                 stringp=buf;
> >+                                 strsep(&stringp, "=");
> >+                                 val = strsep(&stringp, "=");
> >+                                 if (val && strlen(val)) {
> >+                                         if (!strcmp(buf, "callerid"))
> >+                                          
> >+                                                 strncpy(cid, val,
> >sizeof(cid) -1);
> >+                                         if (!strcmp(buf, "origtime"))
> >+                                                 strncpy(datetime, val,
> >sizeof(datetime) - 1);
> >+                                 }
> >+                         }
> >+                 }
> >+                 fclose(f);
> >+
> >+           /* Read calling party number */
> >+
> >+           if (strlen(cid)) {
> >+                  ast_streamfile(chan, "vm-from", chan->language);
> >+                  ast_waitstream(chan, "");
> >+                  ast_callerid_parse(cid, &name, &num);
> >+                  ast_say_digit_str(chan, num, "", chan->language);
> >+
> >+
> >+               } else {
> >+                  ast_streamfile(chan, "unknown-caller", chan->language);
> >+                  ast_waitstream(chan, "");
> >+           }
> >+
> >+           /* Read date */
> >+
> >+           ast_streamfile(chan, "vm-received", chan->language);
> >+           ast_waitstream(chan, "");
> >+
> >+           sscanf(datetime,"%i",&t);
> >+
> >+           res = ast_say_datetime(chan, t, "", chan->language);
> >+
> >+           return res;
> >+
> >+               }
> >+
> >+
> >+         return res;
> >+ }
> >+
> >+
> >   int reload(void)
> >   {
> >         return(load_config());
> >
> >
> >
> >
> >
> >_______________________________________________
> >Asterisk-Dev mailing list
> >Asterisk-Dev at lists.digium.com
> >http://lists.digium.com/mailman/listinfo/asterisk-dev
> 
> _______________________________________________
> Asterisk-Dev mailing list
> Asterisk-Dev at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-dev
> 

-- 
Brad Bergman







More information about the asterisk-dev mailing list