SLACK driver, use text formatting?

Started by Millenium7, May 28, 2020, 07:33:41 AM

Previous topic - Next topic

Millenium7

We've been using the SLACK notification driver for a while to send basic text, with the most advanced formatting to date being simple bold highling of certain text elements. This is done by just putting * around text i.e.
*this part is bold* this part is not

But I want to actually post with different colours, perhaps even with fancy attachments, but for now I just want to stick with colors

Is it possible with the included SLACK driver?
I've tried simply parsing this as text
{"attachments": [{"color": "#ad03fc","text": "Optional text that appears within the attachment"}]}
which pasting it in here shows is valid syntax https://api.slack.com/docs/messages/builder
but I just get the literal text in the SLACK channel. I don't know how the included driver actually works to perhaps further modify the syntax so it works

Any help?

Alternatively can NetXMS do a HTTP Put? because if so I know how to make that work, we already do fancy formatting with Solarwinds that way

Filipp Sudanov

In current implementation of slack driver it creates a simple json like this:
{"channel":"C061EG9SL","text":"mesage_text"}

so anything you write just goes into "text" field. An ability to generate custom jsons would require to make quite some changes in slack notification channel code.

Millenium7

Ok so the SLACK driver is not going to be able to support fancy formatting beyond anything that can be expressed in regular text, i.e. bolding

However can NetXMS do a HTTP PUT? As that would allow me to post whatever I want. As mentioned before this is how we get fancy formatting from Solarwinds NCM as it pushes to slack via a HTTP PUT operation

Filipp Sudanov

You can create action that "executes command on the management server" and call curl in that action.

Millenium7

#4
I know nothing about curl or executing commands from NetXMS. So is this the correct syntax to put into the 'command' box?

curl -d "{"attachments": [{"color": "#ad03fc","text": "Example message from node %n message is %m %M"}]}" -X PUT http://{SLACK URL}

Was close. This is the correct syntax

curl -d 'payload={"attachments": [{"color": "#36a64f","text": "Text example from node %n message is %m %M"}]}' -X PUT https://{SLACK WEBHOOK URL}

Filipp Sudanov