Elastix SMS module

Discussion in 'General' started by jolive, Mar 30, 2011.

  1. jolive

    Joined:
    Feb 28, 2011
    Messages:
    13
    Likes Received:
    0
    Hi guys,

    Here you are an SMS Module for Elastix, developed by our company. Yo can creatre trunks (SMPP providers), create groups of mobile phones, send individial SMS messajes, and create bulk sms campaigns.

    You can download it from:

    http://sourceforge.net/projects/elastix-sms

    Now is available in english and in spanish.
    Documentation is available in spanish.

    It's free!

    http://www.iberoxarxa.es
     
  2. fmvillares

    Joined:
    Sep 8, 2007
    Messages:
    1,785
    Likes Received:
    0
    please send this module to the elastix crew...pestrella at palosanto.com elandivar at palosanto.com....
     
  3. cheeks

    Joined:
    Apr 11, 2009
    Messages:
    49
    Likes Received:
    0
    jolive thanks for the sms module

    i installed it but need some help on setting up the sms trunk

    i have a Huawei E1550 USB Modem installed on my Elastix server and I have chan_datacard loaded without any problems

    I can send an sms via cli when i do CLI>datacard sms huawei 0791234567 Test Message

    I have a Custom Trunk in Elastix: Custom Dial string: = DATACARD/huawei/$OUTNUM$

    What can I do with your sms module to use my Hauwei E1550 3G Usb Modem to send an sms

    any help greatly appreciated
     
  4. jolive

    Joined:
    Feb 28, 2011
    Messages:
    13
    Likes Received:
    0
    cheeks, thanks for trying our module.

    now, SMS module, works only with SMPP providers, over internet ant without hardware.

    we have plans for support hardware.

    in your case, firts try if you can send sms executing this from your prompt:

    asterisk -rx "datacard sms huawei 0791234567 Test Message"

    if this works changes in trunk module are required: for example, is not need to entry server, port, user, password ....

    please, give me some time for thinking about this.

    Now we are working for support Portech gateways and we are making changes in trunk module now.
     
  5. cheeks

    Joined:
    Apr 11, 2009
    Messages:
    49
    Likes Received:
    0
    jolive thanks for your quick response

    when i do
    #asterisk -rx "datacard sms huawei 0791234567 Test Message"

    i received the sms message on my mobile without any problems. this is great news.

    what changes must i do in your trunk module???

    thanks again
     
  6. cheeks

    Joined:
    Apr 11, 2009
    Messages:
    49
    Likes Received:
    0
    jolive

    any ideas on a solution for using the sms module with a working Huawei Modem

    this will really help if you can assist me in getting it to work
     
  7. jolive

    Joined:
    Feb 28, 2011
    Messages:
    13
    Likes Received:
    0
    Please upgrade to latest version:

    Module: http://sourceforge.net/projects/elastix ... z/download

    Documentation: http://sourceforge.net/projects/elastix ... f/download

    If you are using Elastix 2.0. first remove module in delete module option in developer menu.

    Install new version.

    Go to configuration option of SMS and fill according to your country.

    Create a trunk of type Bash Script.

    This type of trunk allow you to develop your own shell script for sending an SMS message.

    You have an example of shell script in /var/www/html/libs/sms/scripts/sample, and follow the instructions.

    In your script you must call asterisk -rx "datacard sms huawei 0791234567 Test Message", passing thr right arguments.

    Please test, and send me your feedback.

    Best regards,

    Jaume Olivé
    www.iberoxarxa.es
     
  8. cheeks

    Joined:
    Apr 11, 2009
    Messages:
    49
    Likes Received:
    0
    Jaume Olivé thanks for the update much appreciated

    Removed sms 01 module in installed sms 02 module

    Now my Problem is that i am not sure what to place where in your sample script so that i can send the same message to 30 mobile numbers.

    " In your script you must call asterisk -rx "datacard sms huawei 0791234567 Test Message", passing thr right arguments. " ?????

    please assist

    thanks again :)
     
  9. cheeks

    Joined:
    Apr 11, 2009
    Messages:
    49
    Likes Received:
    0
    guys hope you can help

    this is the sample sms script:
    ======================================
    #!/bin/bash

    #Get script arguments
    clid="$1"
    destination="$2"
    text="$3"
    unicode="$4"

    #Init return values
    ret_code=0
    ret_message="Message delivered for sending"
    stop_trunk=0
    stop_message=0

    #Process message
    #Errors must be processed, if an error occurs fill
    # ret_code: a value different to 0
    # ret_message: string error message
    # stop_trunk: 1 if this error must stop all messages for this trunk, for example, if there's no credit
    # stop_message: 1 if this error mist stop this message, for example, if number is invalid

    #Begin
    #Write process message code

    #End

    #Return
    echo "$ret_code;$ret_message;$stop_trunk;$stop_message"
    exit $ret_code
    ==========================================

    i have a trunk setup for my hauwie modem with a custom dial string: " DATACARD/huawei/$OUTNUM$ "

    from the shell when i do: " asterisk -rx "datacard sms huawei 0791234567 Test Message "
    i receive the sms test message with no problems

    In the sms sample script i need to call " asterisk -rx "datacard sms huawei 0791234567 Test Message", passing the right arguments.

    Now i need to create a sms campaign to send the same message to 30 mobile numbers. Please can you assist in telling me where in the sms sample script i need to place the correct statement.

    any help greatly appreciated

    sorry for the noob questions :blush:
     
  10. jolive

    Joined:
    Feb 28, 2011
    Messages:
    13
    Likes Received:
    0
    Hi cheeks!

    you must put something like this between "#write process message code" and "#end" section in the
    sample code:

    asterisk -rx "datacard sms huawei $destination $text"

    Notes:

    * Test what happens with a text message like: hello
    * Test what happens with a text message like: hello it's funny
    * Test what happens with a text message like: hello it's "funny"

    Do this tests with an individual send (not a campaign).

    Be careful! Now the custom trunk don't accept unicode, this is, messages with accents will not work. Do you know how to send an unicode message with datacard?.

    Best regards,

    Jaume Olivé
    http://www.iberoxarxa.es
     
  11. cheeks

    Joined:
    Apr 11, 2009
    Messages:
    49
    Likes Received:
    0
    Jaume Olivé

    thanks so much for your help

    did what you said and IT'S WORKING GREAT

    Notes:

    * Test what happens with a text message like: hello - No Problem
    * Test what happens with a text message like: hello it's funny - No Problem
    * Test what happens with a text message like: hello it's "funny" - SMS Received: hello it's funny and NOT hello it's "funny"

    Do you know how to send an unicode message with datacard?. - NO I DO NOT (Help)

    Thanks again for this great Module :)
     
  12. johnme

    Joined:
    Nov 28, 2008
    Messages:
    148
    Likes Received:
    0
    Hi

    Nice to hear about this module.

    I have a working portech mv370.
    Can you please give some instructions how to setup this module with mv370?
    Or i must wait for another version to support it?

    Thanks
    John
     
  13. jolive

    Joined:
    Feb 28, 2011
    Messages:
    13
    Likes Received:
    0
    Hi johme,

    Thanks for your interest.

    We have plans to develop a module for a mv732 but now there's not budget for this.

    We have a test script for sending throught a mv372. We attach this script. You need to fill the correct data for working.

    Note: this scripts selects SIM1 for sending, but mv372 has 2 sims. When you send throught SIM1 you must wait about 2 seconds for sending again from the same SIM, if not, fails.

    The Script is only for sending messages in SMS alphabet. Portech can send throught ISO, but we don't know how at this moment.

    First steep is a full - function test script.

    Can you work on this?


    function waitEndChar($oSocket,$endChar=">") {
    while(1) {
    $c = fgetc($oSocket);

    if (($c == $endChar)) {
    break;
    }
    }
    }

    function waitStr($oSocket,$str,$waitPrompt=false,$endChar=">") {
    $readed = "";

    if ($str != "") {
    while (1) {
    $char = fgetc($oSocket);

    $c = trim($char,"\n\r");

    if ($c != "") {
    $readed .= $c;

    if ($readed == $str) {
    if ($waitPrompt) {
    waitEndChar($oSocket,$endChar);
    break;
    }

    break;
    }
    } else {
    $readed = "";
    }
    }
    } else {
    waitEndChar($oSocket,$endChar);
    }
    }

    function send() {
    $strHost = "portech ip";
    $strPort = "23";
    $strUser = "portech user";
    $strSecret = "portech password";

    $errno=0 ;
    $errstr=0 ;

    $oSocket = fsockopen ($strHost, $strPort, $errno, $errstr, 20);
    if (!$oSocket) {
    echo "$errstr ($errno)<br>\n";
    } else {
    waitStr($oSocket,"username: ");
    fputs($oSocket, "$strUser\r\n");
    waitStr($oSocket,$strUser);

    waitStr($oSocket,"password: *");
    fputs($oSocket, "$strSecret\r\n");
    waitStr($oSocket,"****",true);

    fputs($oSocket, "module1\r");
    waitStr($oSocket,"module1");

    waitStr($oSocket,"getting",true,".");
    waitStr($oSocket,"got",true,".");

    fputs($oSocket, "ate1\r");
    waitStr($oSocket,"0");

    fputs($oSocket, "at+cmgf=1\r");
    waitStr($oSocket,"0");

    fputs($oSocket, "at+cmgs=\"your phone number\"\r");
    waitStr($oSocket,"",true);

    fputs($oSocket, "POLO");
    fputs($oSocket, chr(26));
    waitStr($oSocket,"0");

    fclose($oSocket);
    }
    }

    send();
    ?>
     
  14. jolive

    Joined:
    Feb 28, 2011
    Messages:
    13
    Likes Received:
    0
  15. cheeks

    Joined:
    Apr 11, 2009
    Messages:
    49
    Likes Received:
    0
    jolive thanks for your reply

    i require the campaign option to work but i am not sure what i am doing wrong.

    do i need to have a new script to be able to send a message to 30 mobile numbers.

    please assist in explaining what i need to do

    thanks again :)
     
  16. jolive

    Joined:
    Feb 28, 2011
    Messages:
    13
    Likes Received:
    0
    Hi cheeks,

    It's very easy.
    Create a new campaign.
    Fill the fields according to your requirements for the campaign.
    Prepare a csv file with the phone numbers to send, like this,

    687......
    639......
    878......

    Select one sms trunk for the campaign.
    Save.

    Campaign is created in pause mode.
    Start campaign.

    Rebember that you have to run ixxmassivesms from your console, making:

    service ixxmassivesms start

    If you want to start this service on every reboot of your pbx make

    chkconfig ixxmassivesms on

    There's a user manual in:

    http://sourceforge.net/projects/elastix ... f/download

    best regards

    Jaume Olivé
    http://www.iberoxarxa.es
     
  17. cheeks

    Joined:
    Apr 11, 2009
    Messages:
    49
    Likes Received:
    0
    jolive

    thanks so much for your input

    i forgot to issue the command " service ixxmassivesms start " to get my campaign to start.

    it all works brilliantly now.

    much appreciated

    i have one question regarding vtiger crm.

    you can add a sms service provider on the vtiger system however the code is a bit confusing for me.

    is it at all possible that you can help me with the vtiger sms code to explain what i must enter where so that i can use your sms system to send messages via vtiger with my huawie usb modem


    ================vtiger - modules/SMSNotifier/ext/ISMSProvider.php START ==========
    <?php
    /*+**********************************************************************************
    * The contents of this file are subject to the vtiger CRM Public License Version 1.0
    * ("License"); You may not use this file except in compliance with the License
    * The Original Code is: vtiger CRM Open Source
    * The Initial Developer of the Original Code is vtiger.
    * Portions created by vtiger are Copyright (C) vtiger.
    * All Rights Reserved.
    ************************************************************************************/
    include_once dirname(__FILE__) . '/../ISMSProvider.php';
    include_once 'vtlib/Vtiger/Net/Client.php';

    class MyProvider implements ISMSProvider {

    private $_username;
    private $_password;
    private $_parameters = array();

    const SERVICE_URI = 'http://localhost:9898';
    private static $REQUIRED_PARAMETERS = array('app_id');

    function __construct() {
    }

    public function setAuthParameters($username, $password) {
    $this->_username = $username;
    $this->_password = $password;
    }

    public function setParameter($key, $value) {
    $this->_parameters[$key] = $value;
    }

    public function getParameter($key, $defvalue = false) {
    if(isset($this->_parameters[$key])) {
    return $this->_parameters[$key];
    }
    return $defvalue;
    }

    public function getRequiredParams() {
    return self::$REQUIRED_PARAMETERS;
    }

    public function getServiceURL($type = false) {
    if($type) {
    switch(strtoupper($type)) {

    case self::SERVICE_AUTH: return self::SERVICE_URI . '/http/auth';
    case self::SERVICE_SEND: return self::SERVICE_URI . '/http/sendmsg';
    case self::SERVICE_QUERY: return self::SERVICE_URI . '/http/querymsg';

    }
    }
    return false;
    }

    public function send($message, $tonumbers) {
    if(!is_array($tonumbers)) {
    $tonumbers = array($tonumbers);
    }
    $serviceURL = $this->getServiceURL(self::SERVICE_SEND);

    $httpClient = new Vtiger_Net_Client($serviceURL);
    $response = $httpClient->doPost(array(
    'user' => $this->_username,
    'pwd' => $this->_password,
    'app_id' => $this->getParameter('app_id'),

    'text' => $message,
    'to' => implode(',', $tonumbers)
    ));


    $responseLines = split("\n", $response);

    $results = array();
    foreach($responseLines as $responseLine) {

    $responseLine = trim($responseLine);
    if(empty($responseLine)) continue;

    $result = array( 'error' => false, 'statusmessage' => '' );
    if(preg_match("/ERR:(.*)/", trim($responseLine), $matches)) {
    $result['error'] = true;
    $result['to'] = $tonumbers[$i++];
    $result['statusmessage'] = $matches[0]; // Complete error message
    } else if(preg_match("/ID: ([^ ]+)TO:(.*)/", $responseLine, $matches)) {
    $result['id'] = trim($matches[1]);
    $result['to'] = trim($matches[2]);
    $result['status'] = self::MSG_STATUS_PROCESSING;

    } else if(preg_match("/ID: (.*)/", $responseLine, $matches)) {
    $result['id'] = trim($matches[1]);
    $result['to'] = $tonumbers[0];
    $result['status'] = self::MSG_STATUS_PROCESSING;
    }
    $results[] = $result;
    }
    return $results;
    }

    public function query($messageid) {

    $serviceURL = $this->getServiceURL(self::SERVICE_QUERY);
    $httpClient = new Vtiger_Net_Client($serviceURL);
    $response = $httpClient->doPost(array(
    'user' => $this->_username,
    'pwd' => $this->_password,
    'app_id' => $this->getParameter('app_id'),

    'apimsgid' => $messageid
    ));

    $response = trim($response);

    $result = array( 'error' => false, 'needlookup' => 1 );

    if(preg_match("/ERR: (.*)/", $response, $matches)) {
    $result['error'] = true;
    $result['needlookup'] = 0;
    $result['statusmessage'] = $matches[0];

    } else if(preg_match("/ID: ([^ ]+) Status: ([^ ]+)/", $response, $matches)) {
    $result['id'] = trim($matches[1]);
    $status = trim($matches[2]);

    // Capture the status code as message by default.
    $result['statusmessage'] = "CODE: $status";

    if($status === '1') {
    $result['status'] = self::MSG_STATUS_PROCESSING;
    } else if($status === '2') {
    $result['status'] = self::MSG_STATUS_DISPATCHED;
    $result['needlookup'] = 0;
    }
    }

    return $result;
    }
    }
    ?>
    ================ vtiger - modules/SMSNotifier/ext/ISMSProvider.php END ============

    thanks again
     
  18. logdog

    Joined:
    Apr 10, 2009
    Messages:
    21
    Likes Received:
    0
    Hi2all!
    I installed the module, but create SMS Trunk (smpp) to my Russian service provider for its settings, I could not.
    Is it possible to add the logs files?
     
  19. elastix-user

    Joined:
    Dec 15, 2010
    Messages:
    7
    Likes Received:
    0
    Hi,

    is there a module that enables this distribution to receive SMS please?

    J
     
  20. cheeks

    Joined:
    Apr 11, 2009
    Messages:
    49
    Likes Received:
    0
    jolive

    one problem with the sms module

    It will Only send up to 70 characters in the text box. You cannot send more than 70 Characters

    any ideas what i must do as i need to send at least 100 Characters

    please help :(
     

Share This Page