Kayako logo
Modifications & Addon Releases Modification guides and addons are posted here to share with the community. Do not post requests in here!

Notices

Reply
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 4 votes, 5.00 average. Display Modes
  (#1) Old
KB3LWJ Offline
New Member
 
Posts: 4
Join Date: Jun 2008
Use the Zeep Mobile SMS Gateway (send text messages for free) - 21-10-2008, 02:29 AM

Here is a modification to allow Kayako to use the free Zeep Mobile SMS Gateway (Note: this service is only available for US phones):

Setup
  1. Register at Zeep Mobile and generate API keys for your site (you can leave "Callback URL" blank).
  2. In the Admin CP, enter your API Key into the "Gateway Username" and your secret key into "Gateway Password".
  3. In includes/functions_smsgateway.php, replace the sendSMSAlert(...) function with this one (be sure to copy the function header as well):
    PHP Code:
    function sendSMSAlert(&$ticketobj$staffid$message) {
            global 
    $dbCore$_SWIFT;

            if (
    $_SWIFT["settings"]["gateway_enable"] != 1)
            {
                    return 
    false;
            }

            
    date_default_timezone_set("GMT");
            
    $appid $_SWIFT["settings"]["gateway_username"];
            
    $secretkey $_SWIFT["settings"]["gateway_password"];
            
    $date date(DATE_RFC1123);

            if(
    strlen($message) > 100)
            {
                    
    $message substr($message,0,100);
            }

            
    $content "user_id=" urlencode($staffid) . "&body=%0D%0A" urlencode($message);
            
    $authcode "$appid:" base64_encode(mhash(MHASH_SHA1,$appid $date $content$secretkey));

            
    $return "";

            
    $fp fsockopen("ssl://api.zeepmobile.com"443$errno$errstr30);
            if (!
    $fp) {
                echo 
    "$errstr ($errno)<br />\n";
            } else {
                
    $out "POST /messaging/2008-07-14/send_message HTTP/1.1\r\n";
                
    $out .= "Host: api.zeepmobile.com\r\n";
                
    $out .= "Date: " $date "\r\n";
                
    $out .= "Authorization: Zeep $authcode\r\n";
                
    $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
                
    $out .= "Content-Length: " strlen($content) . "\r\n\r\n";
                
    $out .= $content "\r\n\r\n";

                
    fwrite($fp$out);
                while (!
    feof($fp)) {
                    
    $return .= fgets($fp128);
                }
                
    fclose($fp);
            }

            
    $retsplit explode("\r\n",$return);

            if (
    $retsplit[0] != "HTTP/1.1 200 OK" && $_SWIFT["settings"]["gat_emailfailure"] == 1) {
                    
    $_staff $dbCore->queryFetch("SELECT * FROM `"TABLE_PREFIX ."staff` AS staff LEFT JOIN `"TABLE_PREFIX ."staffgroup` AS staffgroup ON (staff.staffgroupid = staffgroup.staffgroupid) WHERE staffgroup.isadmin = '1' LIMIT 1;");
                    if (empty(
    $_staff["staffid"]))
                    {
                            return 
    true;
                    }

                    
    mail($_staff["email"],"SMS Failure Notice",$out "\r\n\r\n" $return);
                    return 
    true;
            }

            return 
    true;

  4. In modules/tickets/functions_alertrules.php, find the line that says
    PHP Code:
    sendSMSAlert($this->ticketobj$val["mobilenumber"], $_templateresult); 
    and change it to
    PHP Code:
    sendSMSAlert($this->ticketobj$val["staffid"], $_templateresult); 
  5. In modules/core/staff_preferences.php, find where it says
    PHP Code:
    printTextRow("mobilenumber"$_SWIFT["language"]["staffmobilenumber"], $_SWIFT["language"]["desc_staffmobilenumber"], "text"$_SWIFT["staff"]["mobilenumber"], "20");

    printTextareaRow("signature"$_SWIFT["language"]["staffsignature"], $_SWIFT["language"]["desc_staffsignature"], $_signature["signature"], "60""4"); 
    and change it to
    PHP Code:
    printTextRow("mobilenumber", $_SWIFT["language"]["staffmobilenumber"], $_SWIFT["language"]["desc_staffmobilenumber"], "text", $_SWIFT["staff"]["mobilenumber"], "20");

    ?>
    <tr class="row1" title="" onmouseover="" onmouseout="" onclick="" id="" style="">
    <td class="row1" align="left" valign="top" colspan="2" width="50%">
    <iframe style="width: 100%; height: 300px; border: none;" id="zeep_mobile_settings_panel" src="https://secure.zeepmobile.com/subscription/settings?api_key=<?php echo($_SWIFT["settings"]["gateway_username"]); ?>&user_id=<?php echo($_SWIFT["staff"]["staffid"]); ?>">
    </iframe></td></tr>

    <?php
    printTextareaRow
    ("signature"$_SWIFT["language"]["staffsignature"], $_SWIFT["language"]["desc_staffsignature"], $_signature["signature"], "60""4");
  6. In locale/en-us/staff_dashboard.php, find
    PHP Code:
    'desc_staffmobilenumber' => 'If you wish to receive SMS alerts, enter your mobile telephone number.<br/><i>Note: Enter only your telephone number without spaces, dashes or other symbols.<br/>Example: \'18005551212\'</i> '
    and change it to
    PHP Code:
    'desc_staffmobilenumber' => 'If you wish to receive SMS alerts, enter something in this field.<br/><i>You must configure your phone number using the dialog below.</i> '
Usage

The gateway will act exactly like the Kayako gateway does, with the only exception to this being the way staff users must configure their phone numbers. A new box has been added to the "Preferences" in the Staff CP where users need to enter their phone number (the window looks like this).

The staff members will also need to enter something in the Kayako phone number box in order to receive text messages -- if something isn't entered in the box, Kayako won't try to send text messages at all (since Kayako can't see the phone number entered into the Zeep Mobile dialog, it won't think that the user has a number registered).

Disclaimer

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Last edited by KB3LWJ; 23-12-2008 at 01:02 AM..
   
Reply With Quote
  (#2) Old
chrisduk Offline
New Member
 
Posts: 23
Join Date: Aug 2004
23-10-2008, 01:52 PM

hi

this seems cool, could it be used for clients to enter their mobile number so they receive SMS updates on a update to their support ticket?
   
Reply With Quote
  (#3) Old
supportskins Offline
Senior Member
 
supportskins's Avatar
 
Posts: 3,953
Join Date: Aug 2006
Location: Mumbai, India
23-10-2008, 01:56 PM

Zeep website says - "Service available in the US only"



Professional and Affordable Kayako Skins - Specialists in Kayako Skinning & Customization - Professional Paid Support
Our Skins and Services - http://www.supportskins.com/store/
SupportSkins.com - http://www.supportskins.com/
   
Reply With Quote
  (#4) Old
KB3LWJ Offline
New Member
 
Posts: 4
Join Date: Jun 2008
23-10-2008, 01:59 PM

Quote:
Originally Posted by chrisduk View Post
hi

this seems cool, could it be used for clients to enter their mobile number so they receive SMS updates on a update to their support ticket?
No, Kayako's SMS updates can only be configured for staff users. You could conceivably modify SupportSuite to support sending text messages to users, but that's not something I have planned for this modification.

Quote:
Originally Posted by supportskins View Post
Zeep website says - "Service available in the US only"
Thanks for reminding me of that -- I added a note to the instructions to that effect.
   
Reply With Quote
  (#5) Old
VineHosting.com Offline
New Member
 
Posts: 22
Join Date: Oct 2005
22-12-2008, 10:51 PM

seems this is not working -
I have double checked all the settings :-(

any ideas?
   
Reply With Quote
  (#6) Old
KB3LWJ Offline
New Member
 
Posts: 4
Join Date: Jun 2008
23-12-2008, 12:49 AM

Are you getting any of the SMS failure messages? If the Zeep Mobile gateway returns an error, the function will send an e-mail to the first staff member (by date created) who is an admin (the account created when the program was initially installed, unless that account has been deleted or had its administrative flag removed).

One thing that I've noticed is that the clock on your system must be extremely close to the one on the gateway -- I've seen differences as small as 15 seconds make the server reject the message.

As another option for debugging the script, you could do the following:

Before the line that says
PHP Code:
$retsplit explode("\r\n",$return); 
add a line that says
PHP Code:
mail("YOUR EMAIL ADDRESS HERE","SMS Notice",$out "\r\n\r\n" $return); 
replacing "YOUR EMAIL ADDRESS HERE" with the address that you want to receive the notices. This will cause the script to send an e-mail every time that the system tries to send a text message.

Also, have you set up alerts for each user (or a global alert) that will send a text message on certain events? This has to be done from the Staff CP, under Tickets->Alerts.

Derek
   
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Powered by vBulletin® Version 3.7.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Help desk software by Kayako.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48