Skip to content
blak3r edited this page Apr 4, 2012 · 27 revisions

There are a lot of things that could be done to improve this project... Most of which don't really learning any of the domain specific Asterisk backend stuff. Would love to collaborate with people on this project and make it even better. So, any help would be greatly appreciated. Don't be shy about editing this page or any of the documentation for that matter. That's the part many of us like least!

Table of Contents

Features

  • Multiple Matching Contact Handling. When multiple contacts match a given phone number, we should return them to the user in the call window. The user would pick the contact with radio buttons. Once selected the form will submit an ajax post to AsteriskController with action=setContactId. The controller will then write the contact ID to the asterisk_log table... Then, in asteriskLogger we check if the contactId is already set before trying to relate contact to call during the hangup event.
  • Have Button to create a new contact when inbound number isn't recognized... (Add to contact--> create new or add to existing)
  • Have ability to assign a call to a contact but not change add phone to the contact. For example, when you join a conference call... you need to be able to assign the call to the contact but can't do it automatically since conf. call number may be generic.
  • Need to do custom code for Contacts Subpanels.. (doesn't show magic call icon there).
  • Update language files for german and whatever the other language is.
  • Add Transfer Support (See Enhancements in Issues).

Minor Bugs

  • $sugar_config['asterisk_dialin_ext_match'] = 'Local\/(?:.*?)(\d\d\d?\d?\d?)@'; -- Make this take 3-11 digits. If longer then say 5 characters we need to implement a method to look at users's mobile phones.
  • See issues for bug on RingGroups

Potential Enhancements

  • Better handling for answering on mobile phone through a ring group. I forget if call window appears.
  • Would be cool if we displayed voicemail inside sugar. From what i've read this sounds doable given the options in AMI.
  • Ability to record the call... It's unclear whether or not this can be done without complicated AGI scripts or not?

SugarCRM Architecture Improvements

Original plugin was developed in the sugar v4.5 days. A lot of effort has gone into modernizing it and making it upgrade safe but it's still has some rough edges. If you have any experience with developing for sugarcrm these would be a great way to help the project. These include:

Module Loader / Package

  • Fields are added to User, but user needs to go into studio to then add them to template. (This is fine in 6.4 since Users are now "Studioable". Users who are using older versions of Sugar have to manually merge the user fields. This is discussed in more detail in the installation steps.
  • Installer manually drop/creates a table in the mysql database.
    • At the very least we should detect and inform the user of this...
    • Long term solution would be to use the sugarcrm module builder to create the base package instead. Then let sugarcrm handle all the database creation. This would also make the asterisk_log table usable in reports/etc. I think I stopped because I wasn't sure how you ever. This fix should coincide with mysql refactorings.
  • Installer adds several entry points in an install script. Is there a way to do this in the manifest?

Performance Improvements

I'm not aware of any performance issues with using this plugin. That being said... I'm sure there are some optimizations that could be made. This section outlines what we should focus on.

The CallListener.php class is called by every active browser tab that each user has open about every 5 seconds (this is for the call popups). Therefore, this is where any optimization efforts should take place.

  1. Optimize the query that executes against the asterisk_log table. It selects any recent calls that have occurred in the last hour which haven't been closed by the user. I have very little experience with optimizing database queries.
    1. Perhaps indexing the timestampCall column would improve performance?
    2. Alternatively, perhaps we should move older calls to an archive table periodically to improve table scanning.
Other Improvements:
  1. When there are active calls, CallListener looks up the contact in the database by phone number each time. We should stop doing this each time by persisting the contact to the asterisk log table once it's been determined. I plan on tackling this when I add multiple matching contact support.
Originally, this plugin continued to make AJAX calls even after the user session died (like when you login on a different computer)... I changed the code to only schedule subsequent ajax calls when the previous call returns successful. This will work from a performance standpoint but if there is ever a case where a single request fails for a legit reason... the call popup will not appear until user refreshes their page. I think this is an acceptable tradeoff. I'm just documenting it here in case the call popups seem to be sporatically failing.

Configuration Changes Needed

  • Need configurable Channel detection in order to assign calls to users when they answer on cell phones.
  • Add a configurable option for how long to display call popups before they hide automatically.
  • (DONE) Need to add dialin prefix (its in sugarListener)
  • (DONE) Need to make config option for the dialout. Currently hardcoded to /SIP (in my case i need to do the Local/##@sugarsip/n... see CreateCall... for some reason I don't need it in callListener (presumably b/c it's already SIP at that point).
  • (DONE) Parametize the channel --> assigned user id detection, search for Local/LC-52@from-internal-4bbbb in asteriskLogger.
  • (DONE) Add max subject length to controller.php (also variables for IBC, OBC);

MISC

  • Verify Asterisk Logger fix to relogin to AMI works if asterisk goes down.
  • (DONE) Currently language is hardcoded in sugarListener.php
  • (DONE) AsteriskLogger -> findUser method --> add to query something to detect that user is "Active" so you don't get past employees matchin.
  • Process the AMI response in CallCreate / controller and display errors when they fail in javascript.
  • If the database cannot be accessed, this is the error message you get
! FATAL: Cannot find login credentials for user admin which is a bit misleading... as it makes you think soap is the problem

JQUERY Include or Not To Include on Page Problem Notes =

In my production system, I have 6.4.1. I have an extension which uses JQUERY already (1.4 something)...

In AsteriskJS.php if I force include: echo '<script type="text/javascript" src="custom/include/javascript/jquery/jquery.pack.js"></script>'; Asterisk Plugin works fine... But, my Dispage plugins fail. If I remove it so that the asterisk plugin doesn't include jquery, everything is fine.

This then of course will not work for people who don't already have jquery loaded.

On my demo 6.4 instance (I don't have any other extensions so jquery isn't loaded).

My conditional include solution I found on stackoverflow adds the script tag to the end of head. But, the code that is adding the code is in the body. (Where the after_ui_frame javascript is loaded)

As a result, I get Uncaught ReferenceError: $ is not defined

Experimented with surrounding my jquery wth some YUI code... but didn't have too much luck. I tried: YAHOO.util.Event.onDomReady --> nothing happened YAHOO.util.Event.onContentReady --> Uncaught ReferenceError: jQuery is not defined

So, for now the workaround is... by default we include jquery and the user can go in and comment it out if they run into problems.