Giter Club home page Giter Club logo

hubot-spark's Introduction

Hubot Spark Adapter

Build Status

npm version

Description

This is the Cisco Spark adapter for Hubot that allows communication in Spark channels.

Installation

  • Install dependencies with npm install
  • Set environment variables (below)
  • Run hubot with bin/hubot -a spark -n name

Configuration

The following environment variables are required for connecting :

  • HUBOT_SPARK_API_URI - (optional, defaults to "https://api.ciscospark.com/v1")
  • HUBOT_SPARK_ACCESS_TOKEN - Your API access token, generated from the Cisco Spark developer console
  • HUBOT_SPARK_ROOMS - A list of room IDs that you want your bot to listen to, seperated with commas.

Thanks

I copied the framework from hubot-yammer who copied it from hubot-twitter

hubot-spark's People

Contributors

selesse avatar tonybaloney avatar viveksyngh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

hubot-spark's Issues

Requires coffeescript, but none was isntalled

I'm running into trouble when trying to set the environment variables. Also, I receive the following message when running './bin/hubot -a spark':

"npm WARN [email protected] requires a peer of coffee-script@^1.12.6 but none was installed."

I'm certain it has to do with the coffee-script dependency not being present.

"npm install -g coffee-script" does not solve the issue
wess

No markdown support

the messages post endpoint allows for a markdown option. It would be great to add this as a parameter to the sendMessage function.
It looks like it would just need to be a change this:

  send: (user, message, room) ->
    @robot.logger.debug "Sending message"
    @room_ids.forEach (room_id) =>
      @robot.logger.debug "send message to room #{room_id} with text #{message}"
      @spark.sendMessage
        roomId: room_id
        text: message

to something like

  send: (user, message, room, markdownText) ->
    @robot.logger.debug "Sending message"
    @room_ids.forEach (room_id) =>
      @robot.logger.debug "send message to room #{room_id} with text #{message}"
      @spark.sendMessage
        roomId: room_id
        text: message
        markdown: markdownText

Or would it make sense to pass the desired payload straight through? Something like:

  send: (user, payload, room) ->
    @robot.logger.debug "Sending message"
    @room_ids.forEach (room_id) =>
      @robot.logger.debug "send message to room #{room_id} with text #{message}"
      @spark.sendMessage payload

Where payload is:

var payload = {
  "text": "Some text here",
  "files": ["http://www.example.com/images/media.png"]
}

or

var payload = {
  "markdown": "Some `markdown` text **here**"
}

I'm not sure if that would mess with the generic adapter though?
Thoughts?

Edit: Formatting fixes

Live update to the environment variables

Hello:

Normally, I have to stop hubot, make changes to the environmental variables (i.e. HUBOT_SPARK_API_URI, HUBOT_SPARK_ACCESS_TOKEN, HUBOT_SPARK_ROOMS), and then restart hubot for the changes take into affect.

Is there a way to make changes to the environmental variables live without stop and restart hubot. Like when the token changes, I can update HUBOT_SPARK_ACCESS_TOKEN in real-time. Or when I want to add/delete a room, I can assign the changes to HUBOT_SPARK_ROOMS without restarting hubot.

Commands not getting executed by cisco spark chatops

Hi,

I have been able to successfully install st2chatops with cisco webex teams configuration.

I can see that it is able to get message from the rooms but it is not running the command and sending the message.

Here is the log.

EBUG Matched new message pack get core
[Tue Nov 12 2019 18:25:38 GMT+0000 (Coordinated Universal Time)] DEBUG Fired listener callback for xxxx
[Tue Nov 12 2019 18:25:38 GMT+0000 (Coordinated Universal Time)] DEBUG Received pack get core from <user>
[Tue Nov 12 2019 18:25:38 GMT+0000 (Coordinated Universal Time)] DEBUG No listeners executed; falling back to catch-all

does it have support for running commands.

Unable to execute ./bin/hubot -a spark

$ ./bin/hubot -a spark
audited 5265 packages in 3.187s
found 2 vulnerabilities (1 moderate, 1 high)
run npm audit fix to fix them, or npm audit for details
Mon, 08 Oct 2018 15:53:55 GMT body-parser deprecated undefined extended: provide extended option at node_modules\hubot\src\robot.js:445:21
Error: Not enough parameters provided. I need an access token
at new SparkRealtime (D:\hubot\node_modules\hubot-spark\src\spark.coffee:81:17, :111:15)
at SparkAdapter.run (D:\hubot\node_modules\hubot-spark\src\spark.coffee:53:15, :67:13)
at Robot.run (D:\hubot\node_modules\hubot\src\robot.js:644:18)
at Object. (D:\hubot\node_modules\hubot\bin\hubot.js:112:7)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (D:\hubot\node_modules\coffee-script\lib\coffee-script\coffee-script.js:211:36)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object. (D:\hubot\node_modules\hubot\bin\hubot:9:1, :2:3)
at Object. (D:\hubot\node_modules\hubot\bin\hubot:9:1, :4:4)
at Module._compile (module.js:653:30)
at Object.exports.run (D:\hubot\node_modules\coffee-script\lib\coffee-script\coffee-script.js:103:25)
at compileScript (D:\hubot\node_modules\coffee-script\lib\coffee-script\command.js:171:29)
at D:\hubot\node_modules\coffee-script\lib\coffee-script\command.js:143:18
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)

Heroku and hubot-spark

Hello.

I have no issue running heroku with campfire or locally on my mac with hubot-spark.
However, when I tried to run heroku with hubot-spark, I got this output error in heroku logs.

Please advise.

screenshot 2016-05-10 20 56 08

Failed to authenticate: Invalid or missing credentials

Hi Tony,

First of all thanks a lot for your dev !!!
Sorry for this second line but I've issue even if all appear to be configured properly.
Thanks in advance for your feedback and once again for your job :-D

Conf

# Cisco Spark settings (https://github.com/tonybaloney/hubot-spark):
export HUBOT_ADAPTER=spark
export HUBOT_SPARK_API_URI="https://api.ciscospark.com/v1"
export HUBOT_SPARK_ACCESS_TOKEN="xxxxxx"
export HUBOT_SPARK_ROOMS="yyyyyyyy"

Test

curl -X GET \
  https://api.ciscospark.com/v1/rooms/yyyyyyyy \
  -H 'Authorization: Bearer xxxxxx' \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "StackStorm test"
}'

{"id":"zzzzzzzVk","title":"StackStorm test","type":"group","isLocked":false,"lastActivity":"2018-01-29T17:49:27.237Z","creatorId":"tttttttttttt","created":"2018-01-29T09:19:35.544Z"}

Log

[Mon Jan 29 2018 10:18:19 GMT+0000 (UTC)] DEBUG Loading adapter spark
[Mon Jan 29 2018 10:18:20 GMT+0000 (UTC)] 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
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] DEBUG Connected as a bot? false
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] INFO Created connection instance to Spark
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] DEBUG Completed adding rooms to list
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] DEBUG Created bot, setting up listeners
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] DEBUG Done with custom bot logic
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] DEBUG Loading scripts from /opt/stackstorm/chatops/scripts
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] DEBUG Loading scripts from /opt/stackstorm/chatops/src/scripts
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] DEBUG Loading external-scripts from npm packages
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] INFO Requesting a token...
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] WARNING No supported formatter found for spark. Using DefaultFormatter.
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] DEBUG Using spark post data handler.
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] DEBUG Parsing help for /opt/stackstorm/chatops/node_modules/hubot-stackstorm/scripts/stackstorm.js
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] DEBUG Parsing help for /opt/stackstorm/chatops/node_modules/hubot-help/src/help.coffee
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] ERROR Failed to authenticate: Invalid or missing credentials
(node:1085) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 5): [object Object]

hubot-spark not receiving messages?

I can't get my hubot to receive any messages from spark. Debug logging provides:

Unhandled rejection {"message":"Failed to get activity.","errors":[{"description":"Failed to get activity."}],"trackingId":""}

Hubot dies with: The user has sent too many requests

When I start Hubot using a Bot access token, it dies after about 30 seconds with the below message. Is there a parameter that need to be passed to limit the rate?

[Tue Jul 30 2019 12:02:32 GMT-0400 (Eastern Daylight Time)] ERROR BadRequest: The user has sent too many requests in a given amount of time. Please refer to the Retry-After response header to wait before making a new request.
undefined https://api.ciscospark.com/v1/messages
WEBEX_TRACKING_ID: spark-js-sdk_**********

at BadRequest.ExtendableBuiltin (/opt/stackstorm/chatops/node_modules/@ciscospark/common/dist/exception.js:50:44)
at BadRequest.Exception (/opt/stackstorm/chatops/node_modules/@ciscospark/common/dist/exception.js:99:142)
at BadRequest.HttpError (/opt/stackstorm/chatops/node_modules/@ciscospark/http-core/dist/http-error.js:70:125)
at BadRequest.SparkHttpError (/opt/stackstorm/chatops/node_modules/@ciscospark/spark-core/dist/lib/spark-http-error.js:48:135)
at new BadRequest (/opt/stackstorm/chatops/node_modules/@ciscospark/http-core/dist/http-error-subtypes.js:64:129)
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)

[Tue Jul 30 2019 12:02:32 GMT-0400 (Eastern Daylight Time)] ERROR BadRequest: The user has sent too many requests in a given amount of time. Please refer to the Retry-After response header to wait before making a new request.
undefined https://api.ciscospark.com/v1/messages
WEBEX_TRACKING_ID: spark-js-sdk_**********

at BadRequest.ExtendableBuiltin (/opt/stackstorm/chatops/node_modules/@ciscospark/common/dist/exception.js:50:44)
at BadRequest.Exception (/opt/stackstorm/chatops/node_modules/@ciscospark/common/dist/exception.js:99:142)
at BadRequest.HttpError (/opt/stackstorm/chatops/node_modules/@ciscospark/http-core/dist/http-error.js:70:125)
at BadRequest.SparkHttpError (/opt/stackstorm/chatops/node_modules/@ciscospark/spark-core/dist/lib/spark-http-error.js:48:135)
at new BadRequest (/opt/stackstorm/chatops/node_modules/@ciscospark/http-core/dist/http-error-subtypes.js:64:129)
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)

[Tue Jul 30 2019 12:02:32 GMT-0400 (Eastern Daylight Time)] INFO Hubot will shut down

Incorrectly posting to multiple rooms with hubot-spark

This was: StackStorm/st2chatops#106. Posting here as this appears to be an issue in hubot-spark.

When listing multiple rooms in HUBOT_SPARK_ROOMS, responses from st2 chatops.run are delivered to all rooms instead of only the room the message originated in. Is this intended behavior? I'm currently trying to fix this in spark.coffee and will issue a pull if I get it working.

HUBOT_SPARK_ROOMS is defined as:
export HUBOT_SPARK_ROOMS='xxxxxxx,yyyyyy,zzzzzz'

Thanks.

Starting Hubot using hubot-spark has errors, sometimes fails and chat randomly stops the bot from responding

What versions of Node, Hubot and Spark etc is known to work with hubot-spark?

Can someone please post a package.json that specifies versions of things known to work?

I get errors sometimes when starting the bot:

$ node_modules/.bin/hubot --adapter spark -n roberto
[Wed Sep 13 2017 14:58:15 GMT-0400 (Eastern Daylight 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
[Wed Sep 13 2017 14:58:16 GMT-0400 (Eastern Daylight Time)] INFO Created connection instance to Spark
(node:26888) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 14): BadGateway: Bad Gateway
undefined https://api.ciscospark.com/v1/messages
WEBEX_TRACKING_ID: spark-js-sdk_82b92ea0-2895-4543-aa57-c534ecexxx
and
[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.

Also, after a few minutes Hubot stops hearing my requests and stops answering completely randomly.

Lastly, during the brief periods I can get Hubot to connect and stay connected and hear and respond to chat when using hubot-spark as the adapter type, the responses take like 10 or 15 seconds for my bot to even hear chats which makes it slow to respond. I have been using the hubot-slack adapter for two years without any issues. What do I need to do to get hubot-spark working reliably? Specific versions of stuff or settings?

Multiple rooms

HUBOT_SPARK_ROOMS - A list of room IDs that you want your bot to listen to, seperated with commas.

It works fine when I have only 1 room. When I add more than 1 room separated with comma, I get error message.

HUBOT_SPARK_ROOMS="xxxxxxx,yyyyyyy" (where xxxxxxx and yyyyyyy are room ids)

Please advise.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.