question

test-re2qa8668 avatar image
test-re2qa8668 asked Anirban edited

SMS API for sending text to customers and get reply against SMS

we have created an application which sends SMS to customer through Rest API (curl) hit.

SMS is Sending Successfully, but the issue is, when any customer reply against any (or specific) Message.

we are not identify the reply of Message.


can we use any event or webhooks? for reply of message, which we have sent to customers and we want to store that reply against

specific message. how we can do this in PHP.


if any body have done such type of work, pleas share your response on it. we don't want to use Message store method or with message Id.



Thanks



rest apisms and text messaging
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

John Wang avatar image
John Wang Deactivated answered
The RingCentral API supports both webhooks (server-side) and pub/sub (client-side) subscriptions. To retrieve SMS message content, you can create a subscription with the SMS Instant Message Event event filter.

The filter has the following format:

/restapi/v1.0/account/{accountId}/extension/{extensionId}/message-store/instant?type=SMS 

The Developer Guide has general information on webhooks (and pub/sub):

http://ringcentral-api-docs.readthedocs.io/en/latest/webhooks/

Some PHP example code for setting up a webhook is available here:

https://github.com/anilkumarbp/ringcentral-demos-webhooks/tree/master/php

A JavaScript example app is also available:

https://github.com/ringcentral-tutorials/webhook-basics-nodejs-demo

More information on this is available on the SMS Instant Message Event filter here:

https://developer.ringcentral.com/api-docs/latest/index.html#!#RefGetInstantMessageEvent
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

test-re2qa8668 avatar image
test-re2qa8668 answered John Wang Deactivated commented
Hi

Thanks for response, i am using below link.

https://github.com/grokify/ringcentral-sdk-php-lite

and how i can use webhooks (server-side) and pub/sub (client-side) subscriptions or set event in such type of code, which contains the link (file sms.php or in
ringcentral-sdk-php-lite/ src/ ringcentrallite.php).








8 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

John Wang avatar image John Wang ♦♦ commented ·
Using the lite SDK is straight-forward for webhooks and a small demo app can be provided.

However, it does not have a pub/sub client to manage the connection so if you want to use that approach, it would be easier to use the official PHP SDK:

https://github.com/ringcentral/ringcentral-php

We have both webhook and pub/sub examples using the official PHP SDK.

Is there any reason you chose to use the lite SDK over the official one?
0 Likes 0 ·
test-re2qa8668 avatar image test-re2qa8668 commented ·
I have a custom application for send sms to client, SMS send from different interfaces. i get message string, to number and send it to client through this code Lite SDK.
this is a centralized file behave like as a web service. due to this it was suitable for me.
for this link  https://github.com/ringcentral/ringcentral-php it requires  PHP 5.5+ version, we are using 5.6.23 when i Install composer
$ curl -sS https://getcomposer.org/installer
it gives error 

" Problem 1

    - phpunit/php-token-stream 2.0.1 requires php ^7.0 -> your PHP version (5.6.23) does not satisfy that requirement.
    - phpunit/php-token-stream 2.0.1 requires php ^7.0 -> your PHP version (5.6.23) does not satisfy that requirement.
    - Installation request for phpunit/php-token-stream (locked at 2.0.1) -> satisfiable by phpunit/php-token-stream[2.0.1].
"

this is the reason to use the lite SDK over the official one. it fulfill the requirements for sending sms but not for  reply from clients response.

if any client reply against any message we want to store that reply in our DB because further action will be triggered.


please tell me any solution for PHP Version 5.6.23, if i use this link https://github.com/ringcentral/ringcentral-php and leave lite SDK. we can't update php version at now.




0 Likes 0 ·
test-re2qa8668 avatar image test-re2qa8668 commented ·
if i use this one

$ composer require ringcentral/php-sdk
 
get same response
 Problem 1
    - phpunit/php-token-stream 2.0.1 requires php ^7.0 -> your PHP version (5.6.23) does not satisfy that requirement.
    - phpunit/php-token-stream 2.0.1 requires php ^7.0 -> your PHP version (5.6.23) does not satisfy that requirement.
    - Installation request for phpunit/php-token-stream (locked at 2.0.1) -> satisfiable by phpunit/php-token-stream[2.0.1]



0 Likes 0 ·
John Wang avatar image John Wang ♦♦ commented ·
Thanks. That's good info.

I've created a GitHub issue here:

https://github.com/ringcentral/ringcentral-php/issues/61

If this remains an issue with PHP 5.6.23, I can create a demo webhook app using the Lite PHP SDK.

We have webhook examples in JS and Go that can be used as a reference.

0 Likes 0 ·
test-re2qa8668 avatar image test-re2qa8668 commented ·

We are stuck on it. i have deleted old app and create a new one, also set webhook url, in my last app there were not permission set (readMessage,webhooksubscription) but in current these permission sets are exists.


also when i run demo/ subscription.php it gives me  "Hosting Server Read Timeout" and link stop working, but sms.php, authData.php working well. When i check in api-explorer  i get this response

{
                    
  "uri": " https://platform.ringcentral.com/restapi/v1.0/subscription";,
  "records": [
    {
      "uri": " https://platform.ringcentral.com/restapi/v1.0/subscription/bb50584d-b22f-43e2-9bd7-b29f7eed2f47";,
      "id": "bb50584d-b22f-43e2-9bd7-b29f7eed2f47",
      "creationTime": "2018-02-02T10:25:36.037Z",
      "status": "Active",
      "eventFilters": [
        "/restapi/v1.0/account/304393018/extension/1446699019/message-store"
      ],
      "expirationTime": "2018-02-02T10:40:36.037Z",
      "expiresIn": 363,
      "deliveryMode": {
        "transportType": "PubNub",
        "encryption": false,
        "address": "268263456096097_0688d736",
        "subscriberKey": "sub-c-b8b9cd8c-e906-11e2-b383-02ee2ddab7fe"
      }
    }
  ]
}

Now confusion is, SMS is sending well but when any to number reply against message we are unable to get any trigger or webhook url. this url was verified when app deploy for production. in this url that is   "https:// "my server name" .com/ringcentral/ webhook.php"

$callbackBody = file_get_contents('php://input');

$txt = "Server Hit from webhook call";
$fp = fopen('webhook.txt', 'w');
fwrite($fp, $txt);
fclose($fp);

$callbackSignature = $_SERVER['HTTP_VALIDATION_TOKEN'];
header('Validation-Token: '. $callbackSignature);
http_response_code(200);

we need to that response store in DB for further action.
i think this link do not hit when any message recieved from customer to company number. please guide me what i am doing wrong here and why webhook link is not working.






0 Likes 0 ·
Show more comments
vyshakhbabji avatar image
vyshakhbabji Deactivated answered
You indicated you typed this :  

curl -sS https://getcomposer.org/installer 


Make sure you have the  pipe symbol as shown in the read me :  https://github.com/ringcentral/ringcentral-php#with-composer-recommended

curl -sS https://getcomposer.org/installer | php

I run php 5.6.3
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

scott-gordon9782 avatar image
scott-gordon9782 answered John Wang Deactivated commented
Hello - I am seeking if there is anyone out there that I can hire to write a PHP script for me to allow me to send and receive SMS messages from my RingCentral #.  Ideally the script would monitor a POP3 mailbox, when a new email exists the subject is the phone # to send, the message body is the SMS to send.  I can't find anything out there already made and assume a programmer who is familiar with the RingCentral SMS API platform can write this in a few hours?

Any help would be appreciated!

Scott
2 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Tyler Liu avatar image Tyler Liu ♦ commented ·
You can try  https://www.ringcentral.com/solutions/professional-services.html  I know the professional service team does write code for customers.
0 Likes 0 ·
John Wang avatar image John Wang ♦♦ commented ·
You can also use the following developer-specific page for our Professional Services team. This also has a request form:

https://developer.ringcentral.com/support/services.html
0 Likes 0 ·
Anirban avatar image
Anirban answered Anirban edited

Apart from both webhooks (server-side) and pub/sub (client-side) subscriptions, most simple way to receive message content is by RingCentral API :

/restapi/v1.0/account/~/extension/~/message-store/<message id>/content/<attachment id> 

Get Message Content API return the sms content in the API which can be consumed directly from PHP, Java or anything. Message store method or with message Id will be the easiest way to get content through API and can be integrated into any script without much effort.


You can also check both webhook and pub/sub examples using the PHP SDK:

https://github.com/ringcentral/ringcentral-php

1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys