News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
Bot Add in installation failing due to subscription
Tags: developer sandbox, webhooks
Mar 23, 2022 at 6:11pm   •   1 replies  •  0 likes
Julia Dalton

Is anyone else currently unable to install bot add-ins in the sandbox environment?


It seems like the subscriptions aren't being created during the bot installation process, and hitting the create subscription endpoint returns a 401.

1 Answer
answered on Mar 24, 2022 at 8:20am  

Did you follow the instructions in this Walkthrough dev guide? If you did, can you share a few lines of code of your app so I can help.


 0
on Mar 24, 2022 at 8:43am   •  0 likes

Yes (although we did not opt to use the js bot framework we wrote our own api wrapper in c#), we already have a bot add-in promoted to production that is currently functioning. My oauth redirect url is responding with 200 within the allotted time and everything on my end seems to be behaving as expected as far as I can tell.

I was hoping to just confirm whether this is an isolated issue or not.

If this is not an isolated issue, I did notice that there were some changes made to enforcement of expiresIn arg for createSubscription mentioned in another post around the same time I started encountering this issue.

on Mar 24, 2022 at 9:30am   •  0 likes

Yes, there was a change in the Webhook subscription max expiresIn value that was reduced from 20 years down to 10 years. That change got impact on Mar 17. But on Mar 18, we temporarily restored the old max value of 20 years for now so it should not be a problem. Can you reduce the expiresIn value to 10 years (to make sure there would not be a problem later), remove the bot and reinstall it again to see if that helps. Otherwise, give me the bot app client id so I can have a look at it settings.

on Mar 24, 2022 at 11:35am   •  0 likes

From what I understand, the bot add-in event subscriptions are defined on the Bot Webhooks tab with the chips under subscribe to events. And then the creation of those event subscriptions are triggered by the Add to RingCentral button on the Bot tab. Whenever I press the add to ringcentral button I see the request come through ngrok and a 200 response is sent back in time, however adding in the bot fails and the error messsage "We are unable to add the bot to the account since subscription is failed." appears in the portal. If I make a subsequent call to list subscriptions, it returns empty results and if I try to create a subscription subsequently I get a 401 (presumably because the bot wasn't successfully installed).


My first assumption is that my settings are causing the issue, however, I've tried both cloning the app and creating a new app and configuring from scratch with the same end result. If you can take a peek at my settings and see if you can find anything suspect that would be greatly appreciated.


My client Id: tYNhVWWDT7SDbhc-6HNYSQ



on Mar 24, 2022 at 12:04pm   •  0 likes

To be honest, I don't use the app setting to setup the webhook notification for a bot. I use code instead. But having a look at your bot app, I see the missing event notification and I added it to your bot. Not sure if that was the root cause to your problem or not, but give it a try again and let me know.

screen-shot-2022-03-24-at-120120-pm.png

If you want to implement it in your code, see this walkthrough sample code.

// Method to Subscribe for events notification.
async function subscribeToEvents(){
  console.log("Subscribing to posts and groups events")
  var requestData = {
    eventFilters: [
      "/restapi/v1.0/glip/posts", // Team Messaging (a.k.a Glip) events.
      "/restapi/v1.0/glip/groups", // Team Messaging (a.k.a Glip) events.
      "/restapi/v1.0/account/~/extension/~", // Subscribe for this event to detect when a bot is uninstalled
      "/restapi/v1.0/subscription/~?threshold=60&interval=15" // For subscription renewal
    ],
    deliveryMode: {
      transportType: "WebHook",
      address: WEBHOOKS_DELIVERY_ADDRESS
    },
    expiresIn: 604799
  };
  try {
    var resp = await platform.post('/restapi/v1.0/subscription', requestData)
    var jsonObj = await resp.json()
    console.log('Team Messaging events notifications subscribed successfully.');
    // Save the subscription id to a file so that we can check its status every time the
    // bot is restarted.
    fs.writeFileSync( SUBSCRIPTION_ID_TEMP_FILE, jsonObj.id )
    console.log('Your bot is ready for conversations ...');
  }catch (e) {
    console.error('Team Messaging events notifications subscription failed. ', e);
    throw e;
  }
}
on Mar 30, 2022 at 12:49pm   •  0 likes

Still haven't been able to successfully install my app in the test environment for quite a while now. It's a public app, if I enable webhooks subscriptions the install fails with the previously mentioned subscription failed error. If I disable webhooks adding the app to the environment works but the subsequent api call to create a subscription fails, even with retry and backoff delays. Oauth and event callbacks all seem to be behaving as expected.


I dont currently seem to have a path forward.

on Mar 30, 2022 at 8:09pm   •  0 likes

"SUB-406 : Not allowed subscribe for events to extensions of other account".

on Mar 31, 2022 at 11:17am   •  0 likes

So you are working on the new app now? I see you still use the Bot Webhooks setting to define the webhooks callback and I see only the Glip:Posts event filter. It is getting a bit confuse here as I don't know what you changes since last time.

on Mar 31, 2022 at 11:33am   •  0 likes

Yes I did get subscription creation to work via the api. Setting the event subscription in the ui does appear to still be broken. Leaving it disabled in the ui, adding the bot, and then passing in solely the post event filter and calling create subscription is what worked for me.

on Mar 31, 2022 at 11:40am   •  0 likes

You need to have the Glip:Groups event as that is the event for when the bot or any user join a group. So if this event is missing from your code, please add it and try again.

"/restapi/v1.0/glip/groups"
on Mar 30, 2022 at 12:52pm   •  0 likes

And I did try re-creating the app that I'm using for development and reconfigured all of the settings - new client id: F-Oh0nZrSKeNdDtikCUclw

on Mar 24, 2022 at 1:07pm   •  0 likes

I did attempt installing a few times just now with the same result. I've tried with just Glip:Posts, just Glip:Groups and both Glip:Posts and Glip:Groups with the same end result. Now I am able to install the bot successfully if I disable webhooks on the bot webhooks tab. And then as long as I'm able to create the subscription after the fact via the api that should give me a path to move forward with on this, I will try that now. I wonder if anyone else is currently having issues setting the event subscription via the app settings.



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us