StackStorm / hubot-stackstorm

Hubot plugin for integration with StackStorm event-driven infrastructure automation platform.
Apache License 2.0
49 stars 39 forks source link

Chatops does not seem to be working for cisco spark [webex teams] #198

Closed viveksyngh closed 4 years ago

viveksyngh commented 5 years ago

Hi,

I am using chatops with cisco spark ( Webex Team). I am able to get messages from webex teams room to st2chatops but it is failing to handle the messages correctly.

  1. When I run any command inside a webex room, It does not respond and I can see in the logs there are no listeners.
Sat Nov 16 2019 20:03:13 GMT+0000 (Coordinated Universal Time)] DEBUG Matched new message pack get chatops
[Sat Nov 16 2019 20:03:13 GMT+0000 (Coordinated Universal Time)] DEBUG Fired listener callback for <roomId>
[Sat Nov 16 2019 20:03:13 GMT+0000 (Coordinated Universal Time)] DEBUG Received pack get chatops from <username>
[Sat Nov 16 2019 20:03:13 GMT+0000 (Coordinated Universal Time)] DEBUG No listeners executed; falling back to catch-all
  1. I am sending the message using chatops.post_message it not able to send the message to correct room.
st2 run chatops.post_message user="room-id"  message="Hey \n this is a Test message" channel=stackstorm  whisper=true

It is able to get message but not able to identify the roomId correctly as it is using nested object for roomId.

[Sat Nov 16 2019 20:21:58 GMT+0000 (Coordinated Universal Time)] DEBUG Send message to room [object Object] with text Hey \n this is a Test message

This one I fixed by fixing the code in hubot-spark adapter.

  1. When hubot starts it prints this error.
[Sat Nov 16 2019 20:08:58 GMT+0000 (Coordinated Universal Time)] DEBUG Loading adapter spark
[Sat Nov 16 2019 20:08:58 GMT+0000 (Coordinated Universal Time)] INFO Trying connection to https://api.ciscospark.com/v1
one flight: attempted to invoke _getBinding while previous invocation still in flight
one flight: attempted to invoke _getBinding while previous invocation still in flight
[Sat Nov 16 2019 20:09:01 GMT+0000 (Coordinated Universal Time)] DEBUG Connected as a bot? true
[Sat Nov 16 2019 20:09:01 GMT+0000 (Coordinated Universal Time)] INFO Created connection instance to Spark
[Sat Nov 16 2019 20:09:01 GMT+0000 (Coordinated Universal Time)] DEBUG Completed adding rooms to list
[Sat Nov 16 2019 20:09:01 GMT+0000 (Coordinated Universal Time)] DEBUG Created bot, setting up listeners
[Sat Nov 16 2019 20:09:01 GMT+0000 (Coordinated Universal Time)] DEBUG Done with custom bot logic
[Sat Nov 16 2019 20:09:01 GMT+0000 (Coordinated Universal Time)] DEBUG Loading scripts from /opt/stackstorm/chatops/bin/scripts
[Sat Nov 16 2019 20:09:01 GMT+0000 (Coordinated Universal Time)] DEBUG Loading scripts from /opt/stackstorm/chatops/bin/src/scripts
(node:4853) UnhandledPromiseRejectionWarning: Forbidden: permission denied
undefined https://api.ciscospark.com/v1/messages
WEBEX_TRACKING_ID: spark-js-sdk_4db8a287-a006-4468-9e90-6733e9e7d8f6_3

    at Forbidden.ExtendableBuiltin (/opt/stackstorm/chatops/node_modules/@ciscospark/common/dist/exception.js:50:44)
    at Forbidden.Exception (/opt/stackstorm/chatops/node_modules/@ciscospark/common/dist/exception.js:99:142)
    at Forbidden.HttpError (/opt/stackstorm/chatops/node_modules/@ciscospark/http-core/dist/http-error.js:70:125)
    at Forbidden.SparkHttpError (/opt/stackstorm/chatops/node_modules/@ciscospark/spark-core/dist/lib/spark-http-error.js:48:135)
    at Forbidden.BadRequest (/opt/stackstorm/chatops/node_modules/@ciscospark/http-core/dist/http-error-subtypes.js:64:129)
    at new Forbidden (/opt/stackstorm/chatops/node_modules/@ciscospark/http-core/dist/http-error-subtypes.js:109:127)
    at HttpStatusInterceptor.onResponse (/opt/stackstorm/chatops/node_modules/@ciscospark/http-core/dist/interceptors/http-status.js:99:39)
    at /opt/stackstorm/chatops/node_modules/@ciscospark/http-core/dist/request/index.js:72:41
    at process._tickCallback (internal/process/next_tick.js:68:7)

(node:4853) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 14)
(node:4853) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

am I missing something in configuration or this is the correct behavior ?

arm4b commented 5 years ago

Thanks for report,

We didn't verify Cisco Spark for quite a long time as 3rd party contributed extension, but maybe someone from Community members is using it successfully and can jump in to share his experience and help.

viveksyngh commented 5 years ago

Looks like hubot-spark adapter is using https://www.npmjs.com/package/ciscospark, which has been deprecated and replaced with https://www.npmjs.com/package/webex.

blag commented 5 years ago

The webex package looks like it's a drop-in replacement for the ciscospark package, which is promising. Hopefully, we may be able to just swap out the dependencies without changing any of our code. This adapter is community supported though, so we'll need somebody who has access to a Webex server to make the changes, test the code, and submit a PR.

Note that the hubot-spark package will need to be updated to depend on and use webex instead of ciscospark, and then st2chatops will need to be updated to use that fork/version of hubot-spark.

blag commented 4 years ago

PR #200 is mostly looking good. And we'll need a new released version of hubot-spark with your fixes in place to rely on in st2chatops.

viveksyngh commented 4 years ago

I have updated it based on the comments.

jcoeder commented 4 years ago

I have access to Webex and will gladly help anyone who is wanting to work on this.