SlackMatlab
Matlab integration for Slack
19th November, 2014Basic integration to send notifications to Slack from Matlab, via an Incoming Webhooks integration. Sending message attachments along with a notification is supported.
This small package allows you to send notifications to your Slack team, programatically from within a Matlab function or script. You can configure most aspects of the notification, including setting the icon displayed within Slack and adding (textual) attachments to be displayed along with the notification. Basic markup is supported by Slack messages.
Installation
- Clone the SlackMatlab repository from github, and add the directory to your Matlab path.
- Set up a Incoming Webhook integration for your Slack team. The channel or user your select for the webhook will be the default target for messages sent from Matlab, but a different target can be set programatically for each message.
- Copy the webhook URL, and store it somewhere accessible to you in Matlab. This string needs to be passed as an argument to the SlackMatlab functions.
- Call
SendSlackNotification
, passing the webhook URL as an argument.
Example
Optionally create a message attachment to send along with a notification, using MakeSlackAttachment
. Slack supports attaching several messages within a single notification.
sA = MakeSlackAttachment('New open task [urgent]:', ... 'Text of the notification message', ... 'Text that will be displayed before the message', '#0000ff', ... {'Field 1 title', 'This is a field that will be shown in a table'}, ... {'Field 2 title', 'This is another field that will be shown in a table'});
Now send the the notification using SendSlackNotification
, including the message as an attachment:
SendSlackNotification('https://this.is.your/webhook/url', ... 'I sent this notification from Matlab, on behalf of @username.', ... '#target-channel', 'Name to post under', ... [], ':bear:', sA);
Resulting notification within Slack: