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
Issues with ringcentral-chatbot package
Tags: bots
Mar 29, 2021 at 4:10pm   •   1 replies  •  0 likes
Paul Thompson

I am using the node ringcentral-chatbot package along with the ringcentral. I am using the ringcentral-chatbot package to subscribe to and receive webooks, and I am currently getting an exception in the ringcentral-chatbot package when I receive the following webhook

WebHook payload: {"uuid":"2249990457863490969","event":"/restapi/v1.0/glip/posts","timestamp":"2021-03-29T22:49:33.826Z","subscriptionId":"fb6f0643-0eb4-4996-b4dd-96dcecc9181b","ownerId":"292777004","body":{"id":"4790575108","groupId":"616022018","type":"TextMessage","text":"good","creatorId":"292005004","addedPersonIds":null,"creationTime":"2021-03-29T22:49:33.509Z","lastModifiedTime":"2021-03-29T22:49:33.509Z","attachments":null,"activity":null,"title":null,"iconUri":null,"iconEmoji":null,"mentions":null,"eventType":"PostAdded"}}

POST /bot/webhook 200 0 - 0.650 ms

/home/ec2-user/my-bot/node_modules/ringcentral-chatbot/dist/handlers/postAdded.js:30

const group = await bot.getGroup(groupId);

^


TypeError: Cannot read property 'getGroup' of null

at postAdded (/home/ec2-user/my-bot/node_modules/ringcentral-chatbot/dist/handlers/postAdded.js:30:27)

at async /home/ec2-user/my-bot/node_modules/ringcentral-chatbot/dist/apps/bot.js:52:28


Any ideas on what might be causing this?

I have the following defined as environment variables

RINGCENTRAL_SERVER 
RINGCENTRAL_CHATBOT_ADMIN_USERNAME 
RINGCENTRAL_CHATBOT_ADMIN_PASSWORD 
RINGCENTRAL_CHATBOT_EXPRESS_PORT 
RINGCENTRAL_CHATBOT_CLIENT_ID 
RINGCENTRAL_CHATBOT_CLIENT_SECRET
RINGCENTRAL_CHATBOT_SERVER
RINGCENTRAL_APP_REDIRECT_URL
RINGCENTRAL_CHATBOT_DATABASE_CONNECTION_URI
RINGCENTRAL_CHATBOT_AUTH_CODE
I am also using the following code for authentication

const rcsdk = new SDK({
    server: SDK.server.sandbox,
    appKey: process.env.RINGCENTRAL_CHATBOT_CLIENT_ID,
    appSecret: process.env.RINGCENTRAL_CHATBOT_CLIENT_SECRET
});
const platform = rcsdk.platform();

let data = platform.auth().data();
data.token_type = "bearer"
data.expires_in = 1000000
data.access_token = process.env.RINGCENTRAL_CHATBOT_AUTH_CODE
data.refresh_token = 'xxx'
data.refresh_token_expires_in = 1000000
platform.auth().setData(data)


I also setup

1 Answer
answered on Mar 30, 2021 at 9:13am  

If you use the chatbot framework, why do you need to write code to do authentication? The framework handles it for you.


I think there is no data in your database, so the bot is null:

https://github.com/ringcentral/ringcentral-chatbot-js/blob/master/src/handlers/postAdded.js#L16


It seems that you are trying the bot on a EC2 server. Does it work on your dev server? Maybe you can try remove and re-add the bot, if the bot doesn't exist in your db.


 0



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