Active IQ Unified Manager Discussions

Slack Integration from WFA


Hi, I am looking at sending notifications from WFA into slack channels. So rather than using the current mail code I'll be looking at trying to write something to hit a slack channel. 


I'm wondering before I begin if anyone has something written already? I have an easy enough powershell script which does that but I'm learning how to invoke these in WFA atm. 




Re: Slack Integration from WFA


Hi Frazer,


It's possible in PowerShell (like this example) so it should be possible in WFA.

I would "guess" it's something like this (though I've not tested it):


   [Parameter(Mandatory=$True, HelpMessage="The slack URI")] 
   [Parameter(Mandatory=$True, HelpMessage="The slack hostname, FQDN or IP address for authentication")] 
   [Parameter(Mandatory=$True, HelpMessage="The slack channel name")] 
   [Parameter(Mandatory=$True, HelpMessage="The slack channel message")] 
   [Parameter(Mandatory=$True, HelpMessage="The slack channel icon")] 
#'Enumerate the slack credentials from the WFA credential cache.
$Credentials = Get-WFACredentials $HostName
[String]$userName = $Credentials.GetNetworkCredential().Username
$BodyTemplate = @"
      "channel": "$ChannelName",
      "username": "$userName",
      "text": "$Message. \nTime: DATETIME.",
#'Send the message to the slack channel.
   Invoke-RestMethod -uri $Uri -Method Post -body $body -ContentType "application/json" -Credential $Credentials -ErrorAction Stop
   Get-WFALogger -Info -Message "Sent message ""$Message"" to slack channel ""$ChannelName"" using URI ""$Uri"""
   Get-WFALogger -Error -Message $("Failed invoking URI ""$Uri"". Error " + $_.Exception.Message)
   Throw "Failed sending message ""$Message"" to slack channel ""$ChannelName"" using URI ""$Uri"""

In addition to the PowerShell code link, I would assume the REST POST method would require authentication hence i added the $HostName parameter which is used to retrieve a WFA credential object for invoking the REST API.

EG add a WFA credential using '' and the username (EG #wfaslackbot)


Hope that helps



If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.
2021 NetApp Partner Experience Survey
PES Banner
All Community Forums