Git Product home page Git Product logo

Comments (13)

emedvedev avatar emedvedev commented on August 12, 2024

Thanks for reporting. :) Can you give a command to the bot in a PM and then show me post_result output from st2?

from hubot-stackstorm.

lmarty avatar lmarty commented on August 12, 2024

I don't think I understand what you're asking me to do. If I PM the bot and try to run commands, it does not respond at all. I am attempting to execute this from the CLI.

The JSON output that it drops is as follows...

{
"status": "succeeded",
"start_timestamp": "2016-05-13T17:08:35.343502Z",
"parameters": {
"whisper": true,
"message": "test",
"user": "@redacted",
"channel": "REDACTED"
},
"runner": {
"runner_module": "st2actions.runners.announcementrunner",
"description": "A runner for emitting an announcement event on the stream.",
"enabled": true,
"runner_parameters": {
"route": {
"default": "general",
"minLength": 1,
"type": "string",
"description": "The routing_key used to route the message to consumers. Might be a list of words, delimited by dots.",
"maxLength": 255

  • 92 more lines
    {
    "status": "succeeded",
    "start_timestamp": "2016-05-13T17:08:35.343502Z",
    "parameters": {
    "whisper": true,
    "message": "test",
    "user": "@redacted",
    "channel": "REDACTED"
    },
    "runner": {
    "runner_module": "st2actions.runners.announcementrunner",
    "description": "A runner for emitting an announcement event on the stream.",
    "enabled": true,
    "runner_parameters": {
    "route": {
    "default": "general",
    "minLength": 1,
    "type": "string",
    "description": "The routing_key used to route the message to consumers. Might be a list of words, delimited by dots.",
    "maxLength": 255
    },
    "experimental": {
    "default": false,
    "required": true,
    "type": "boolean",
    "description": "Flag to indicate acknowledment of using experimental runner"
    }
    },
    "id": "5720f40f7b12502d4b84d997",
    "name": "announcement"
    },
    "result": {
    "whisper": true,
    "message": "test",
    "user": "@redacted",
    "channel": "REDACTED",
    "extra": null
    },
    "context": {
    "user": "st2admin"
    },
    "action": {
    "runner_type": "announcement",
    "name": "post_message",
    "parameters": {
    "extra": {
    "type": "object",
    "description": "Extra adapter-specific parameters.",
    "_name": "extra"
    },
    "whisper": {
    "default": false,
    "type": "boolean",
    "description": "Send a private message to user",
    "_name": "whisper"
    },
    "route": {
    "default": "chatops",
    "_name": "route"
    },
    "user": {
    "type": "string",
    "description": "Explicitly notify a user",
    "_name": "user"
    },
    "channel": {
    "required": true,
    "type": "string",
    "description": "Channel to post to",
    "_name": "channel"
    },
    "message": {
    "required": true,
    "type": "string",
    "description": "Message to send.",
    "_name": "message"
    },
    "experimental": {
    "default": true,
    "immutable": true,
    "_name": "experimental"
    }
    },
    "tags": [],
    "enabled": true,
    "entry_point": "",
    "notify": {},
    "uid": "action:chatops:post_message",
    "pack": "chatops",
    "ref": "chatops.post_message",
    "id": "5720f4257b12502d4b84d9b9",
    "description": "Post a message to stream for chatops"
    },
    "liveaction": {
    "action": "chatops.post_message",
    "callback": {},
    "runner_info": {
    "hostname": "REDACTED",
    "pid": 12578
    },
    "id": "57360a137b1250322a0e5563",
    "parameters": {
    "whisper": true,
    "message": "test",
    "user": "@redacted",
    "channel": "REDACTED"
    }
    },
    "id": "57360a137b1250322a0e5564",
    "end_timestamp": "2016-05-13T17:08:35.575047Z",
    "execution_time": 1
    }

from hubot-stackstorm.

emedvedev avatar emedvedev commented on August 12, 2024

I don't think I understand what you're asking me to do. If I PM the bot and try to run commands, it does not respond at all. I am attempting to execute this from the CLI.

Which command are you trying to run? Can you just try writing help to the bot and see if it works? Note that you shouldn't place ! or anything else before the command.

from hubot-stackstorm.

lmarty avatar lmarty commented on August 12, 2024

st2 run chatops.post_message message="test" channel="REDACTED" user="REDACTED" whisper=True is the command I am running. With valid data in the channel= and user= fields.

from hubot-stackstorm.

emedvedev avatar emedvedev commented on August 12, 2024

Thanks!

If you PM help to the bot (without exclamation mark or an alias), does it respond at all? Is it online? If the bot doesn't respond to help or is offline, there might be a problem with the Hubot install, and that would be a slightly different issue to troubleshoot.

from hubot-stackstorm.

lmarty avatar lmarty commented on August 12, 2024

Yes. The bot responds fine to help and other st2 commands.

from hubot-stackstorm.

emedvedev avatar emedvedev commented on August 12, 2024

I'm a bit confused here. You said before:

If I PM the bot and try to run commands, it does not respond at all.

Anyway, if the bot responds to an st2 command in PM, it should create a chatops.post_result execution. Could you please show me the data from that execution and also from its child post_message execution?

from hubot-stackstorm.

lmarty avatar lmarty commented on August 12, 2024

If I am in a hipchat room, and I message my bot (e.g: @bot help), it works fine. Any other command issued via hipchat works fine. I am attempting to make the bot whisper message a particular user by executing st2 commands from the stackstorm server itself. (e.g: st2 run chatops.post_message channel="mychannel" message="this is a test from the robot" user="myhipchatusername" whisper=True)

This results in an "action succeeded" message showing in the executions, but user myhipchatusername never receives a message from the bot.

If I execute the same command from the CLI, without the "user=" and "whisper=" options, the bot will speak my message to the room as expected.

What I'm trying to do is have the bot private message a user when something is observed in the event stream. Instead of making that announcement to a room full of people.

Does that make sense?

from hubot-stackstorm.

emedvedev avatar emedvedev commented on August 12, 2024

Yes.

If the bot can send you messages in channels, and the bot can send you messages in PM, then the most likely cause for your error is specifying the user name incorrectly (i.e. nickname instead of JID).

This is why I'm asking to paste a result of a successful chatops.post_result execution here, either from CLI or Web UI: once you replicate the exact parameters the bot does, it should work.

from hubot-stackstorm.

lmarty avatar lmarty commented on August 12, 2024

I think I see where our disconnect is. The bot cannot send me messages in PM. That is what I'm trying to get it to do.

Messages from the bot in channels do work fine.
Public @Mentions in a channel to a user from the bot also work fine.
Help and st2 command in the channels the bot reside in work fine
The bot will not respond to help or other commands sent to it via PM

I am assuming that the whisper=true flags functionality is to have the bot initiate a PM to the specified user, is that correct?

Did a bit more testing after your post as well, thinking I potentially had the wrong data in the user= field. Attempts were made using the following info/formats from my profile on hipchat.com

user="my_NumericJid"
user="[email protected]"
user="[email protected]
user="my FullName"
user="my@mentionName" (without the @ sign)

All give me a status: succeed. A few pertinent examples of the execution output are as follows.

The execution output of a successful post to a room, that @messages my user looks like
id: 57505d606bdb380b89c3f73c status: succeeded (0s elapsed) parameters: channel: myroom message: test user: my@mentionname result: channel: myroom extra: null message: test user: my@mentionname whisper: false

An unsuccessful run, that produces no message in the room and no PM to my user looks like

id: 575060006bdb380b89c3f73f status: succeeded (1s elapsed) parameters: channel: myroom message: test user: my@mentionname whisper: true result: channel: myroom extra: null message: test user: my@mentionname whisper: true

My use case for this is having my bot PM a user when certain account criteria is not being met.
e.g: "hey dude, turn 2fa on or be deleted".
I don't want to publicly display that info, as it may inspire others to attack that account.

from hubot-stackstorm.

emedvedev avatar emedvedev commented on August 12, 2024

Awesome! That should be enough info to proceed.

First of all, let's deal with the commands sent to the bot in PM. Are you trying !help or help? In private messages, the bot will only respond to help without ! — that's how Hubot works. If help doesn't work, the HipChat adapter might be not working for you properly, because the help command is built-in and unrelated to StackStorm.

As for private messages from the bot, with whisper set to True username should go into channel and not into user, which is mighty confusing and counterintuitive, but think of channel as a recipient.

Your exact steps would be:

  1. Try sending help in a PM, without the exclamation mark. If the bot responds, try issuing one of the st2 commands as well.
  2. When an st2 command is issued in PM, StackStorm executes the corresponding action and then starts a chatops.post_result workflow to post the response back to you. Last step of this workflow is a chatops.post_message action, and if you take a look at its parameters, you'll find exactly what syntax you need to send a PM through the bot.
  3. Alternatively, just try every kind of username syntax that you tried before in channel rather than user.

from hubot-stackstorm.

lmarty avatar lmarty commented on August 12, 2024

WOOHOOO!!!! We got it!

The trick was, as you said, dumping the users JID into the channel field of the command.

e.g: st2 run chatops.post_message channel="[email protected]" message="test" whisper=True

So part two of this is a feature request. It would be make this functionality much more useful if there was a mechanism that takes in a users hipchat name and spits out their JID.

Thanks for the help!

from hubot-stackstorm.

emedvedev avatar emedvedev commented on August 12, 2024

Awesome! Glad to know it's resolved.

The feature request part is very reasonable, we'll try to make working with HipChat (and the whole post_message action) easier to use, but I can't give an estimate yet. It is definitely in our plans.

from hubot-stackstorm.

Related Issues (20)

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.