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

  • 1
  • Question
  • Updated 3 months ago
  • Answered
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
Photo of Test RE2QA

Test RE2QA

  • 120 Points 100 badge 2x thumb

Posted 6 months ago

  • 1
Photo of John Wang

John Wang, Official Rep

  • 5,278 Points 5k badge 2x thumb
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
Photo of Test RE2QA

Test RE2QA

  • 120 Points 100 badge 2x thumb
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).
Photo of John Wang

John Wang, Official Rep

  • 4,798 Points 4k badge 2x thumb
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.

Photo of Test RE2QA

Test RE2QA

  • 120 Points 100 badge 2x thumb
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

https://platform.ringcentral.com/restapi/v1.0/subscription
{
  "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.
Photo of Test RE2QA

Test RE2QA

  • 120 Points 100 badge 2x thumb
i am getting notification when any reply received, but not write in this file $fp = fopen('webhook.txt', 'w');.
if you can create webhook example for SMS in Lite PHP SDK. it will be very helpful.Thanks


also please guide in screenshot registrationId. what it will be ? and certificationName ? if i select webhook it require registrationId. if it Client ID or something else ?
(Edited)
Photo of Tyler Long

Tyler Long, Official Rep

  • 5,190 Points 5k badge 2x thumb
As far as I can tell, when you create a webhook using code, you don't need to specify registrationId. Here is some sample code: https://github.com/tylerlong/glip-ping-bot/blob/master/index.js#L31-L48

Code is JS instead of PHP, but at least it proves that registrationId is not needed.
Photo of John Wang

John Wang, Official Rep

  • 4,798 Points 4k badge 2x thumb
@Test RE2QA

I put together a simple webhook app using the Lite PHP SDK.

https://github.com/grokify/ringcentral-sdk-php-lite/tree/master/examples/webhook

You will see that you don't need `registrationId`. You just need the following:

  • eventFilters
  • deliveryMode.transportType
  • deliveryMode.address

Here is an example request:

$reqBody = array(
    'eventFilters' => array(
        '/restapi/v1.0/account/~/extension/~/message-store/instant?type=SMS',
        '/restapi/v1.0/subscription/~?threshold=86400&interval=3600'
    ),
    'deliveryMode'      => array(
        'transportType' => 'WebHook',
        'address'       => 'https://12345678.ngrok.io/hook.php'
    ) 
);

Let us know if you are up and running or if there's anything else we can assist with.
(Edited)
Photo of VB

VB, Official Rep

  • 1,410 Points 1k badge 2x thumb
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
(Edited)
Photo of Scott Gordon

Scott Gordon

  • 100 Points 100 badge 2x thumb
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
Photo of Tyler Long

Tyler Long, Official Rep

  • 5,658 Points 5k badge 2x thumb
You can try https://www.ringcentral.com/solutions/professional-services.html  I know the professional service team does write code for customers.
Photo of John Wang

John Wang, Official Rep

  • 4,862 Points 4k badge 2x thumb
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