Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
mountaindude
Partner Ambassador
Partner Ambassador

Howto: Posting to Slack from Qlik Sense load script

Being a heavy Slack user, I have for some time thought about the possibility to integrate Slack and Sense.

Turns out it isn't hard at all..

Oh, never heard of Slack? Check it out - it's a really good instant messaging/group communication tool.

Being able to post Slack messages from the Sense load script opens up all sorts of possibilities, for example

  • Have different reload tasks post to different Slack channels, depending on what the tasks do.
  • Post messages when a scheduled reload job starts and ends.
  • Post status messages for long running reload tasks. It is suddenly trivial to get an idea of how far along that 3 hour reload task has come.
  • Post information about failures during the reload. This is especially relevant if a reload task should continue even if some failure occurs – quite often you would still want to notify someone about the failure that did happen.
  • Notify end users and stakeholders that their Sense apps have been refreshed with new data.

Full writeup here.

Should be noted that the approach described in the post above may introduce security risks in a Sense server setting - so do read the Sense help pages for the "execute" command before deploying this in a production setting.

I'll post an alternative solution in the next few days too, where security can be kept on default (=higher) levels.

Which one should be used depends on your use case - if you are running Sense desktop you can probably use the approach described above. In a setup with sensitive data you might want to go with the proxy based setup described in the coming post (need a few days to wrap it up..).

Please mark the post as a solution if it provided you with a solution to the topic at hand. Thanks!
4 Replies
robert_mika
Master III
Master III

Interesting.

Thank you.

Feeling Qlikngry?

How To /Missing Manual(23 articles)

mountaindude
Partner Ambassador
Partner Ambassador
Author

Adding to the previous post, at the link below is a write-up on how to use Node.js to create a small proxy service, which via a REST API makes it possible to post Slack messages without lowering the security settings of Sense.

https://ptarmiganlabs.com/blog/2015/12/10/posting-slack-qlik-sense-load-scripts-web-service-style-pa...

Please feel free to extend the (very basic) Node proxy code - I am sure there are lots of good things that can be added there. Github pull requests always welcome!

/Göran

Please mark the post as a solution if it provided you with a solution to the topic at hand. Thanks!
mountaindude
Partner Ambassador
Partner Ambassador
Author

Update:

Added another endpoint to the proxy, for creating directories on the server where the proxy app is running.

The rationale for this is that you probably don't want to lower Sense's security settings, but those settings prevent you from (among other things) creating directories on disk.

Another option is then to have a small proxy app do this for you..

The proxy app now has two endpoints:

/slack          for posting to Slack

/createDir   for creating directories on disk

It is pretty easy to add additional endpoints, if/when needed.

Everything available at the GitHub repository.

Please mark the post as a solution if it provided you with a solution to the topic at hand. Thanks!
gbme
Partner - Contributor
Partner - Contributor

I managed to do this without proxies or windows executables, by calling the REST connector and disabling error temporarily because QLIK has issues parsing the response from SLACK (which makes sense since it is not valid json or CSV)

  1. Create a REST connector using POST as method. The url should be the Slack webhook url. (looks like https://hooks.slack.com/services/xxxxxxxxxxxxx/yyyyyyyyyyy/zzzzzzzzzzzzzzzzzzzzzz)
  2. Set a temporary Request Body: {"text":"test"}. We will override this later.
  3. Data options: Uncheck both (Auto detect response type and Check response type during 'Test Connection'
  4. Set a name for the connector ('Slack')

Create a sub for posting:

 

sub notifySlack(labeltext)
//insert connect statement for REST connector just created below
	LIB CONNECT TO 'slack (qlikcloud_qlikid_xxxx_xxxx)';
	set ErrorMode=0;
    	let user = osuser();
	let doc = DocumentTitle();

	RestConnectorMasterTable:
	Select
	"test"
	from  CSV "CSV_Source"
	With Connection(
	BODY "{'text':'*[$(doc)]* $(labeltext)\n{$(user)','mrkdwn':'true'}"
		);
	set ErrorMode=1;
end sub;

 

 

Call the function:

 

call notifySlack('Start Loading data');

 

 

I call the function at the beginning and the end of the data-load. Hope to improve this so it can run without disabling the errors, ideas anyone?