Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chatops.post_message seems to be ignoring Slack pretext #4561

Open
lingfish opened this issue Feb 21, 2019 · 8 comments
Open

chatops.post_message seems to be ignoring Slack pretext #4561

lingfish opened this issue Feb 21, 2019 · 8 comments

Comments

@lingfish
Copy link

SUMMARY

chatops.post_message seems to be ignoring Slack pretext.

ISSUE TYPE

Pick one below and delete the rest:

  • Bug Report
STACKSTORM VERSION

st2 2.10.1, on Python 2.7.6

OS / ENVIRONMENT / INSTALL METHOD

Standard docker install.

STEPS TO REPRODUCE
st2 run chatops.post_message channel=testing message='To get a list of commands type: ```!help```' extra='{"slack": {"color":"#f48527","pretext":"Hey <!channel>, Ready for ChatOps?","title": "Ansible and ChatOps. Get started :rocket:","title_link":"https://stackstorm.com/2015/06/24/ansible-chatops-get-started-%f0%9f%9a%80/","author_name":"by StackStorm - IFTTT for Ops","author_link":"https://stackstorm.com/","author_icon":"https://stackstorm.com/wp/wp-content/uploads/2015/01/favicon.png","image_url":"https://i.imgur.com/HWN8T78.png","fields":[{"title":"Documentation","value":"https://docs.stackstorm.com/chatops/","short":true}]}}' > /dev/null
EXPECTED RESULTS

A pretext line in the Slack channel.

ACTUAL RESULTS

Pretext line missing.

@lingfish lingfish changed the title chatops.post_message seems to be ignoring Slack pretext chatops.post_message seems to be ignoring Slack pretext Feb 21, 2019
@nzlosh
Copy link
Contributor

nzlosh commented Feb 21, 2019

I tested this using err-stackstorm and the problem isn't situated with the chatops.post_message action. It handles and extra.slack options correctly and passes them on to the bot.

$ st2 run chatops.post_message channel='#ops' message='To get a list of commands type: `!st2help`' extra='{"slack": {"color": "#f48527","pretext": "Hey <!channel>, Ready for ChatOps?","title": "Ansible and ChatOps. Get started :rocket:","title_link": "https://stackstorm.com/2015/06/24/ansible-chatops-get-started-%f0%9f%9a%80/","author_name": "by StackStorm - IFTTT for Ops","author_link": "https://stackstorm.com/","author_icon": "https://stackstorm.com/wp/wp-content/uploads/2015/01/favicon.png","image_url": "https://i.imgur.com/HWN8T78.png","fields": [{"title": "Documentation","value": "https://docs.stackstorm.com/chatops/","short": true}]}}'

.
id: 5c6e6b47d506c3bda13ab35c
status: succeeded
parameters: 
  channel: '#ops'
  extra:
    slack:
      author_icon: https://stackstorm.com/wp/wp-content/uploads/2015/01/favicon.png
      author_link: https://stackstorm.com/
      author_name: by StackStorm - IFTTT for Ops
      color: '#f48527'
      fields:
      - short: true
        title: Documentation
        value: https://docs.stackstorm.com/chatops/
      image_url: https://i.imgur.com/HWN8T78.png
      pretext: Hey <!channel>, Ready for ChatOps?
      title: 'Ansible and ChatOps. Get started :rocket:'
      title_link: https://stackstorm.com/2015/06/24/ansible-chatops-get-started-%f0%9f%9a%80/
  message: 'To get a list of commands type: ```!st2help```'
result: 
  channel: '#ops'
  extra:
    slack:
      author_icon: https://stackstorm.com/wp/wp-content/uploads/2015/01/favicon.png
      author_link: https://stackstorm.com/
      author_name: by StackStorm - IFTTT for Ops
      color: '#f48527'
      fields:
      - short: true
        title: Documentation
        value: https://docs.stackstorm.com/chatops/
      image_url: https://i.imgur.com/HWN8T78.png
      pretext: Hey <!channel>, Ready for ChatOps?
      title: 'Ansible and ChatOps. Get started :rocket:'
      title_link: https://stackstorm.com/2015/06/24/ansible-chatops-get-started-%f0%9f%9a%80/
  message: 'To get a list of commands type: `!st2help`'
  output:
    channel: '#ops'
    extra:
      slack:
        author_icon: https://stackstorm.com/wp/wp-content/uploads/2015/01/favicon.png
        author_link: https://stackstorm.com/
        author_name: by StackStorm - IFTTT for Ops
        color: '#f48527'
        fields:
        - short: true
          title: Documentation
          value: https://docs.stackstorm.com/chatops/
        image_url: https://i.imgur.com/HWN8T78.png
        pretext: Hey <!channel>, Ready for ChatOps?
        title: 'Ansible and ChatOps. Get started :rocket:'
        title_link: https://stackstorm.com/2015/06/24/ansible-chatops-get-started-%f0%9f%9a%80/
    message: 'To get a list of commands type: `!st2help`'
    user: null
    whisper: false
  user: null
  whisper: false

The output contains the pretext.
chatops post_message_pre_text_ok

This leads me to think the problem is with how the hubot-stackstorm adapter is handling the extra parameters.

@lingfish
Copy link
Author

Agreed. How do we proceed?

@nzlosh
Copy link
Contributor

nzlosh commented Feb 21, 2019

It would probably be best to open an issue under the hubot-stackstorm repo https://github.com/StackStorm/hubot-stackstorm/issues and reference this issue in it.

@ghost
Copy link

ghost commented Feb 21, 2019

Not sure if this helps but using mattermost I have no problem with the pretext in following format

{
  "color": "#474C5D",
  "mattermost": {
    "attachments": [
      {
        "pretext": "---",
        "actions": [
          {
            "integration": {
              "url": "https://example.com",
              "context": {
                "some": "value"
              }
            },
            "name": "button name"
          }
        ],
        "text": "example"
      }
    ]
  }
}

@lingfish
Copy link
Author

Thanks @nzlosh, done here: StackStorm/hubot-stackstorm#162

@lingfish
Copy link
Author

Hi, so after much work with @blag over in the other issue, his conclusion is I need to come back here.

Can someone kindly review what we've done there, and give me some thoughts?

@blag
Copy link
Contributor

blag commented Jun 4, 2019

@lingfish To help folks who haven't kept up on StackStorm/hubot-stackstorm#162, please copy and paste the following files here:

  • Your sensor YAML file
  • Your sensor Python code (if you don't want to post this publicly please DM it to me on Slack)
  • Rule YAML file
  • The exact data that is being passed into chatops.post_message (please redact any private data)
  • The full trigger instance data (please redact any private date)

@stale
Copy link

stale bot commented Sep 2, 2019

Thanks for contributing to this issue. As it has been 90 days since the last activity, we are automatically marking is as stale. If this issue is not relevant or applicable anymore (problem has been fixed in a new version or similar), please close the issue or let us know so we can close it. On the contrary, if the issue is still relevant, there is nothing you need to do, but if you have any additional details or context which would help us when working on this issue, please include it as a comment to this issue.

@stale stale bot added the stale label Sep 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants