CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviSMS »
  • Clarification of SMS sending behaviour
Pages: [1]

Author Topic: Clarification of SMS sending behaviour  (Read 1139 times)

nickholden

  • I post occasionally
  • **
  • Posts: 111
  • Karma: 1
  • CiviCRM version: 4.4.1
  • CMS version: Drupal 7
  • MySQL version: 5.5.32
  • PHP version: 5.4
Clarification of SMS sending behaviour
December 06, 2013, 05:23:47 am
I'm working on an extension to provide SMS via the NHS.net email->SMS gateway.

Currently I'm seeing odd behaviour in Civi, and I can't tell if it is intended, or a bug.

When a recipient is designated who does not have a mobile phone number they will not be sent a message. This makes sense. But if they do have a mobile, but it isn't marked as their primary phone, then Civi includes them in the attempts but doesn't supply the necessary variables to send() so I don't think it can be working.

Example:

Three contacts fit some search criteria. The first has '1111111111' as their home mobile, marked as primary. The second has '2222222222' as their home mobile, and '3333333333' as their home landline, marked as primary. The third has '4444444444' as their home landline, marked as primary.

Expected behaviour - two SMS messages should be sent, one to 1111111111111 and one to 2222222222 (the two mobile numbers available).

Actual behaviour - correctly, CiviCRM tells me "SMS will not be sent to 1 contact", and it sets up the Send SMS form with 1111111111 and 2222222222 as the intended recipients. It says "2 messages were sent successfully". BUT ... here is the result of outputting the various supplied variables to the send() function:

First pass:

Code: [Select]
$recipient: 1111111111

$header:
Array
(
    [qfKey] => c6e706fb05060a9b056736c31450d150_1841
    [entryURL] => http://localhost/drupal-7.15/civicrm/contact/search?reset=1
    [to] => 488::1111111111,486::2222222222
    [activity_subject] => TEST 2 - more array exploding
    [sms_provider_id] => 3
    [token3] => Array
        (
        )

    [token1] => Array
        (
        )

    [token2] => Array
        (
        )

    [template] => 60
    [saveTemplateName] =>
    [MAX_FILE_SIZE] => 2097152
    [provider_id] => 3
    [To] => 1111111111
    [contact_id] => 488
    [parent_activity_id] => 1533
)

$message: THIS IS THE TEST TEXT

$job ID:


Second pass:

Code: [Select]
$recipient:

$header:
Array
(
    [qfKey] => c6e706fb05060a9b056736c31450d150_1841
    [entryURL] => http://localhost/drupal-7.15/civicrm/contact/search?reset=1
    [to] => 488::1111111111,486::2222222222
    [activity_subject] => TEST 2 - more array exploding
    [sms_provider_id] => 3
    [token3] => Array
        (
        )

    [token1] => Array
        (
        )

    [token2] => Array
        (
        )

    [template] => 60
    [saveTemplateName] =>
    [MAX_FILE_SIZE] => 2097152
    [provider_id] => 3
    [To] =>
    [contact_id] => 486
    [parent_activity_id] => 1533
)

$message: THIS IS THE TEST TEXT

$jobID:


Note how both contact IDs and both mobile numbers show up in $header['to'], but only one gets passed as $recipient, and $header['To'] - and since this is what the clickatell exension uses to actually send the text messages, it seems to me that the extension should be failing to send to any mobile number not marked as primary.

I suppose it is possible that the intended behaviour is to only text people who have set their mobile as their primary number, but just because I want people to voice call me on my landline doesn't mean I don't want to receive text messages on my mobile, does it?

Looking at CRM/Activity/BAO/Activity.php I think the problem is that the sendSMS() function sets $smsParams['To'] to be blank if the supplied primary phone number for the contact is not a mobile, or to the phone number if it is a mobile, and then the sendSMSMessage() function 'fixes' this by looking up all the phone numbers for contacts where $smsParams['To'] is blank. However, when it finds the mobile number it doesn't write it back in $smsParams['To'], it puts it into a new variable called $toPhoneNumber - which is never passed to the provider send() function!

So, unless I've misread something (entirely possible), CiviSMS is not correctly sending messages to contacts who have their mobile number not set as primary, unless the provider extensions are adding a supplementary fix in cases where $smsParams['To'] is blank. I don't think they are, and I don't think they should have to.

Are clickatell users not seeing lots of errors?

Our provider extension for NHS mail gateway works a lot better, when the value in $toPhoneNumber is also assigned back in to the empty $smsParams['To']. YMMV.

Line 1505, CRM/Activity/BAO/Activity.php
        $smsParams['To'] = $toPhoneNumber = CRM_Utils_Array::value('phone', $toPhoneNumerDetails); // Adding value back into smsParams again



Nick

Deepak Srivastava

  • Ask me questions
  • ****
  • Posts: 677
  • Karma: 65
Re: Clarification of SMS sending behaviour
December 06, 2013, 10:50:37 pm
Just did a check with latest (>= 4.3 compatible) clickatell extension on my local, and seems to be working fine.

Mobile phone need not be a primary. Possible it could be a problem / bug with earlier version.

Code: [Select]
Dec 07 12:04:27  [info] $$recipients = 919892078376

Dec 07 12:04:27  [info] $$header = Array
(
    [qfKey] => 8d565a0b0b8065a3c091ac4f0f134cf0_8111
    [entryURL] => http://cms.loc/civicrm/contact/search?reset=1
    [to] => 204::919892078376,205::919892078377
    [activity_subject] => morning test
    [sms_provider_id] => 1
    [token3] => Array
        (
        )

    [token1] => Array
        (
        )

    [token2] => Array
        (
        )

    [template] =>
    [saveTemplateName] =>
    [MAX_FILE_SIZE] => 2097152
    [provider_id] => 1
    [To] => 919892078376
    [contact_id] => 204
    [parent_activity_id] => 626
)


Dec 07 12:04:27  [info] $$postDataArray = Array
(
    [session_id] => 1709207269
    [to] => 919892078376
    [text] => morning test
    [callback] => 3
)


Dec 07 12:04:27  [info] $$send = Array
(
    [0] => ID
    [1] => 403707316
)


Dec 07 12:04:28  [info] $$recipients = 919892078377

Dec 07 12:04:28  [info] $$header = Array
(
    [qfKey] => 8d565a0b0b8065a3c091ac4f0f134cf0_8111
    [entryURL] => http://cms.loc/civicrm/contact/search?reset=1
    [to] => 204::919892078376,205::919892078377
    [activity_subject] => morning test
    [sms_provider_id] => 1
    [token3] => Array
        (
        )

    [token1] => Array
        (
        )

    [token2] => Array
        (
        )

    [template] =>
    [saveTemplateName] =>
    [MAX_FILE_SIZE] => 2097152
    [provider_id] => 1
    [To] => 919892078377
    [contact_id] => 205
    [parent_activity_id] => 626
)


Dec 07 12:04:28  [info] $$postDataArray = Array
(
    [session_id] => 1709207269
    [to] => 919892078377
    [text] => morning test
    [callback] => 3
)


Dec 07 12:04:28  [info] $$send = Array
(
    [0] => ID
    [1] => 51475878
)
« Last Edit: December 06, 2013, 10:54:40 pm by Deepak Srivastava »
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Clarification of SMS sending behaviour
February 01, 2014, 09:52:24 am
When a contact has a mobile number which is not the primary, bulk SMS messages go out just fine.   But, if I am looking at the contact's record and click the "Actions" button the action "Send SMS" is missing.

Also, what if I send a bulk SMS message to a contact who has more than one mobile number?  Does it send to all their mobile numbers?
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviSMS »
  • Clarification of SMS sending behaviour

This forum was archived on 2017-11-26.