# How to let hubot call rocket.chat api?

**URL:** <https://forums.rocket.chat/t/how-to-let-hubot-call-rocket-chat-api/4349>\
**Category:** Community Support\
**Created:** [August 13, 2019, 4:14am UTC](https://forums.rocket.chat/t/how-to-let-hubot-call-rocket-chat-api/4349 "2019-08-13T04:14:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wangxr1985](https://avatars.discourse-cdn.com/v4/letter/w/f04885/32.png) [@wangxr1985](https://forums.rocket.chat/u/wangxr1985)\
**Post date:** [August 13, 2019, 4:14am UTC](https://forums.rocket.chat/t/how-to-let-hubot-call-rocket-chat-api/4349/1 "2019-08-13T04:14:53Z")

</div>

### 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’ }”
