question

Justin Rankin avatar image
Justin Rankin asked Phong Vu answered

Subscribe to SMS Events

Subscribing to a message event is giving me a hard time. I have set up webhook notifications for my account before but a previous integration was failing so I had to remove my old subscription and create a new one to test with locally. Now when I go to subscribe to the webhook using the extensions credentials to sign in, the process responds back with an error message "403 - Forbidden" "Not allowed to subscribe for events of other account". I don't know how this could be though since I am signing in as myself to subscribe to an event.

platform.login({
    "username": 1234567890,
    "password": "nOTmyPaSsword",
    "extension": 999
})

platform.on(platform.events.loginSuccess, async ()=>{
    var body = {
        eventFilters: [
            "/restapi/v1.0/account/1234567890/extension/999/message-store/instant?type=SMS"
        ],
        expiresIn: 315360000,
        "deliveryMode": {
            "transportType": "WebHook",
            "address": "https://bigtest.ngrok-free.app/ring-central",
            "verificationToken": "verificationTOKEN"
        }
    }
    var respose = await platform.post("/restapi/v1.0/subscription", body);
    var json = await respose.json();
    console.log(json);
})

If it really helps I can expose the extension and number (just not the password obviously) but this is what I have been using to try and subscribe to an event. I am logging in with the extension and then if I log in successfully, subscribe. I am able to log-in successfully as I am logging successes back to the console, but as I said earlier, the API returns a 404 Forbidden Response. Is there something that I am inherently missing?

subscription
1 |3000

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

1 Answer

Phong Vu avatar image
Phong Vu answered

This is the key problem.

eventFilters: [
            "/restapi/v1.0/account/1234567890/extension/999/message-store/instant?type=SMS"
        ]

And the error message told you the reason:

error message "403 - Forbidden" "Not allowed to subscribe for events of other account"

The API reference shows you this. The account Id and the extension Id (Not extension number 999 as in your code.

/restapi/v1.0/account/{accountId}/extension/{extensionId}/message-store

If you don't know the account Id nor the extension Id, simple use the tilde like this

/restapi/v1.0/account/~/extension/~/message-store

Check the dev guide for sample code

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