How to update RingCentral Chatbot tokens

Tyler Liu
RingCentral Developers
3 min readAug 2, 2022

Today one of my chatbots stopped working — I hadn’t done anything to it for the past year. It was usually pretty stable in the past. I was wondering what caused the issue,so I checked the logs printed by my chatbot, and I found something like this:

{
"errorCode": "OAU-149",
"message": "Invalid token"
}

For some reason, the token became invalid. So I decided to try to figure out why this was the case.

How to check the token?

My chatbot is a private one. So I can view the token directly on developers.ringcentral.com:

If your bot is a public one, you won’t be able to see the token on developers.ringcentral.com. Because, for public users, by design, there could be multiple chatbot users. In such cases, most likely the tokens are saved somewhere by your chatbot app. If you are using the official chatbot SDK. There is an command to check the saved token:

If you prefer a copy-paste version of the command, here it is:

curl -X GET -u admin:password https://<bot-server>/admin/dump-database

By checking the token on developers.ringcentral.com and the token saved in my chatbot app’s database. I found that they are actually identical. Not sure why it would stop working even though they are identical. But here is how you fix it.

How to update the token?

You generate a new token like this:

If your bot is a public bot, you will not be able to regenerate tokens like this. It will be trickier in that case. You may need to remove it from the bot and re-add it. We will not be covering that in this article.

Once you have the new token, you will have to replace your chatbot’s token with it. If you are using the official chatbot SDK, there is a convenient command:

curl -X PUT -u admin:password https://<bot-server>/admin/update-token?id=<bot-extension-id>&token=<access-token>'

Where can you get the “bot-extension-id” value? You may find the bot user in the RingCentral app, and its ID is its email prefix:

What is the “admin:password” credentials pair? They are the chatbot admin’s credentials. You will find them in the environment variables https://github.com/ringcentral/ringcentral-chatbot-js/blob/master/.express.env#L7-L8. Your values may be different.

Summary

In this article, I shared my experience updating the RingCentral chatbot tokens. You do not need it as long as your bot works well. But in case you have this issue as well, please refer to this article to resolve it.

Please let us know what you think by leaving your questions and comments below. To learn even more about other features we have make sure to visit our developer site and if you’re ever stuck make sure to go to our developer forum.

Want to stay up to date and in the know about new APIs and features? Join our Game Changer Program and earn great rewards for building your skills and learning more about RingCentral!

--

--