NetXMS Support Forum

English Support => General Support => Topic started by: Millenium7 on May 28, 2020, 07:33:41 AM

Title: SLACK driver, use text formatting?
Post by: Millenium7 on May 28, 2020, 07:33:41 AM
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
Title: Re: SLACK driver, use text formatting?
Post by: Filipp Sudanov on May 29, 2020, 06:09:50 PM
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.
Title: Re: SLACK driver, use text formatting?
Post by: Millenium7 on June 01, 2020, 08:34:33 AM
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
Title: Re: SLACK driver, use text formatting?
Post by: Filipp Sudanov on June 01, 2020, 08:59:58 AM
You can create action that "executes command on the management server" and call curl in that action.
Title: Re: SLACK driver, use text formatting?
Post by: Millenium7 on June 02, 2020, 02:41:33 AM
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}
Title: Re: SLACK driver, use text formatting?
Post by: Filipp Sudanov on June 02, 2020, 01:18:47 PM
Thanks for sharing