Page 269 - Asterisk™: The Future of Telephony
P. 269

Integrate with Your Desk Phone Using Micromenus
               With increasing competition between modern IP-enabled desk phone manufacturers,
               the microbrowser feature has snuck in relatively unnoticed and underutilized. The
               principle is simple: physical desk phones construct interactive menus on a phone by
               pulling  XML  over  HTTP  or  the  like.  Contending  interests,  however,  lead  this
               technology amiss: every vendor’s XML differs, microbrowsers are often quirky, and
               available features vary vastly.
               The Micromenus framework exists as an Adhearsion helper and aims to abstract the
               differences between vendors’ phones. For this very particular development domain
               (i.e., creating menus), Micromenus use a very simple Ruby-based “Domain Specific
               Language” to program logic cleanly and independent of any phone brands.
               Below is a simple example Micromenu:
                   image 'company-logo'
                   item "Call an Employee" do
                     # Creates a list of employees as callable links from a database.
                     Employee.find(:all).each do |someone|
                       # Simply select someone to call that person on your phone.
                       call someone.extension, someone.full_name
                     end
                   end
                   item "Weather Information" do
                     call "Hear the weather report" do
                       play weather_report("Portland, OR")
                     end
                     item "Current: " + weather("Portland, OR")[:current][:temp]
                   end
                   item "System Uptime: " + `uptime`
               A list item displays in two ways. If given only a text String, Micromenus renders only
               a text element. If the arguments contain a do/end block of nested information, that text
               becomes a link to a sub-page rendering that nested content.
               A call item also has two uses, each producing a link which, when selected, initiates a
               call. When call receives no do/end block, it simulates physically dialing the number
               given as the first argument. When a do/end block exists and all calls route through
               Adhearsion, selecting that item executes the dialplan functionality within the block.
               This is a great example of how handling the dialplans and on-screen microbrowsers
               within the same framework pays off well.
               From this example we can see a few other neat things about Micromenus:
                 • Micromenus support sending images. If the requesting phone does not support
                   images, the response will have no mention of them.
                 • All Adhearsion helpers work here, too. We use the weather helper in this example.
                 • The Micromenus sub-framework can use Adhearsion’s database integration.




                                                           Asterisk Development with Adhearsion | 241
   264   265   266   267   268   269   270   271   272   273   274