By using the Aculab site, you agree with our use of cookies.
right  Talk To Us!

Voicemail Lesson 3

We now know how to play and record messages. Let's introduce a few more interesting techniques, including use of the file management system to check for the existence of specific files and use of application parameters to determine the voicemail box that the application is accessing.


    • Sample Files:
      • Samples\voicemail_3.py

      Specifying a Voicemail Box

      This step makes use of the application_parameters argument that contains the user-defined string originating from the Inbound Service configuration. This string is expected to contain the name we have set up to be our voicemail box. We set up a format for all voicemail filenames that locates them in a voicemailbox subfolder on the cloud.

      After answering the call the application identifies the level of access for the caller. It does this by comparing the caller Id with the voicemail box name, as determined from application_parameters.

      If the caller Id and voicemail box name match then the caller is deemed to be the owner of the voicemail box and the application calls top_level_menu() that allows the caller to listen and delete all messages. In the main function, we can do this using the file_man.exists() function, with the filename as a parameter. This will test for the existence of the file on the Cloud. We keep incrementing a counter until the filename is not found.

      If the caller Id and voicemail box name do not match, the caller is simply allowed to record a new message.

      Using the channel

      One of the first things we do is to call our get_caller function. This extacts information from the call_from property of the channel we've been given, which supplies a SIP address. Our telephony system which answers the client encapsulates the phone number information within a SIP format, which is then used by our Cloud. Our function extracts the phone number information from the SIP address.

      The application parameters are given to us as a string, accessable by the application_parameters variable. In our example, we compare the parameter against the caller number, to identify if the caller is actually the owner of our voicemail service. If they are the caller, the application jumps to the top_level_menu subroutine, otherwise to record_new_message.

      Dealing with DTMF

      The top level menu subroutine uses a function called get_menu_select. We saw in the previous example how to access DTMF tones via the keypad. This routine will play some TTS to the user, and then wait for a valid response. Once the user has entered a valid response, the keypad press will be returned. We can then simply check the return code and act appropriately.

      In play_all_messages(), we use a counter, checking if a filename derived from the counter exists, and if so, says some TTS and then the file itself. delete_all_messages() works in a similar manner, but rather than play each file, we delete the file using the file_man.delete_file call.

Next time...

So, we have a simple bare-bone voicemail system up and running. We could personalise the voicemail box some more though. How about allowing the owner of the voicemail box to record their own introduction message and use the file as a welcome message? Additionally we could allow the owner to select messages to keep or delete. Read on to find out how...

Lesson 4