How to let hubot call rocket.chat api?

Version

version1: hubot 2.19.0 & nodejs 4.8.3 & coffeescript 1.12.7
version2: hubot 3.3.2 & nodejs 8+ & coffeescript 2.2.2

Description

I want to use hubot to call rocket.chat API,but hubot documentation give me too little information to know how to do it.

I search on internet and find to ways, for example, get user info:
robot.adapter.api.get(‘users.info’, { “username”: “Tom” })
robot.adapter.callMethod(‘users.info’, { ‘username’: ‘Tom’ })

But the both two methods can not work correctly.

“robot.adapter.api.get” throws exception directly(both in version1 and version2): Cannot read property ‘get’ of undefined

“robot.adapter.callMethod” can only be used in old version(version1) and it’s result is not as we needed,when I use console.log to show the return value it shows “{ state: ‘pending’ }”

1 Like