cancel
Showing results for 
Search instead for 
Did you mean: 

Webhooks in Slack or Teams...

SOLVED
Conversationalist

Webhooks in Slack or Teams...

Anyone got that working? 

1 ACCEPTED SOLUTION

Accepted Solutions
Meraki Employee

Re: Webhooks in Slack or Teams...

After some quick research, it looks like the POST format of the Slack webhook API requires a specific JSON format as discussed.
This means you cannot just point Meraki to Slack, since you will need some middleware to format the data first. Zapier does this with their integration. Alternatively, you could write a micro-service to do this. 

 

https://api.slack.com/incoming-webhooks#enable_webhooks

Expected Slack format

POST https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
Content-type: application/json
{
    "text": "Hello, world."
}

Meraki Format

{
  "alertData" : {
    "kbTotal" : 10750,
    "nodeTag" : "",
    "period" : 1200,
    "usageThreshold" : 10240
  },
  "alertId" : "643451796765320956",
  "alertType" : "Network usage alert",
  "networkId" : "L_123456789123456789",
  "networkName" : "Network - 1",
  "networkUrl" : "https://n1.meraki.com/...",
  "occurredAt" : "2018-10-25T17:17:38.623000Z",
  "organizationId" : "123456",
  "organizationName" : "Organization",
  "organizationUrl" : "https://n1.meraki.com/o/.../organization/overview",
  "sentAt" : "2018-10-25T17:17:46.608245Z",
  "sharedSecret" : "asdf1234",
  "version" : "0.1"
}

Middleware would convert JSON to look like this, where "text" could be the "alertType" and then you could parse out any other important details to format the message. 

POST https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
Content-type: application/json
{
    "text":"Network usage alert /n more info.."
}

 

9 REPLIES
A model citizen
Conversationalist

Re: Webhooks in Slack or Teams...

Nothing for Slack/Teams Webhooks though and test in the dashboard also fails... The hook does work fine with curl though...

Head in the Cloud

Re: Webhooks in Slack or Teams...


@GolfKilo wrote:

Nothing for Slack/Teams Webhooks though and test in the dashboard also fails... The hook does work fine with curl though...


These statements don't sound right... If the test webhook isn't received then your receiver isn't listening, or something is blocking the Post from coming through. I would start there.

 

I also didn't realize you could make curl listen for an HTTP Post from an external source. Can you share the switches you're using to do that? I'm interested in knowing how to do that.

Conversationalist

Re: Webhooks in Slack or Teams...

curl -X POST -H 'Content-type: application/json' --data '{"Hello":"World"}' https://hooks.slack.com/services/{{whatever}}


The hook works, it seems like Slack (&MS Teams) don't like the json Meraki provides... As most probably use Slack or Teams. It's a bit useless Meraki feature at the moment.

Head in the Cloud

Re: Webhooks in Slack or Teams...

Ahh! OK I misunderstood. I thought you were saying you were using curl to receive the post from Meraki. Now I understand. 

 

I'm not sure I have much to offer here. I've been playing with webhooks a bit, but not with Slakc or Teams. I just made a little LED rig and attached it to a Raspberry Pi so that I get little flashing lights when an alert goes off. But I have that working at least. Not sure why it's not working for you... 

 

One thing that did hang me up for a bit was that you have to add the server on the alerts page, AND then you have to add the server to each specific alert you want to (or add it to the default recipient). Maybe that's where you're going wrong?

Conversationalist

Re: Webhooks in Slack or Teams...

Nope, it's the only recipient, and if I add an email admin, the email gets thru...

 

And the "send test webhook" in the dashboard fails also... Can only be that Slack doesn't like the json...

New here

Re: Webhooks in Slack or Teams...

I believe you're correct - in the above links, they are using Zapier to do the translation from Meraki webhook payload, to webex teams friendly payload.

 

Zapier is rather straightforward, and though I've not played with it in a year or two, I believe they have a free tier.

 

Your other option is to host an app yourself, and do that message translation.  To that end, for testing webhooks on your laptop, look at ngrok- it creates an http(s) tunnel to your laptop, giving you a public URL.  Also lets you replay webhook payloads, amazing for testing!

Meraki Employee

Re: Webhooks in Slack or Teams...

After some quick research, it looks like the POST format of the Slack webhook API requires a specific JSON format as discussed.
This means you cannot just point Meraki to Slack, since you will need some middleware to format the data first. Zapier does this with their integration. Alternatively, you could write a micro-service to do this. 

 

https://api.slack.com/incoming-webhooks#enable_webhooks

Expected Slack format

POST https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
Content-type: application/json
{
    "text": "Hello, world."
}

Meraki Format

{
  "alertData" : {
    "kbTotal" : 10750,
    "nodeTag" : "",
    "period" : 1200,
    "usageThreshold" : 10240
  },
  "alertId" : "643451796765320956",
  "alertType" : "Network usage alert",
  "networkId" : "L_123456789123456789",
  "networkName" : "Network - 1",
  "networkUrl" : "https://n1.meraki.com/...",
  "occurredAt" : "2018-10-25T17:17:38.623000Z",
  "organizationId" : "123456",
  "organizationName" : "Organization",
  "organizationUrl" : "https://n1.meraki.com/o/.../organization/overview",
  "sentAt" : "2018-10-25T17:17:46.608245Z",
  "sharedSecret" : "asdf1234",
  "version" : "0.1"
}

Middleware would convert JSON to look like this, where "text" could be the "alertType" and then you could parse out any other important details to format the message. 

POST https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
Content-type: application/json
{
    "text":"Network usage alert /n more info.."
}

 

Conversationalist

Re: Webhooks in Slack or Teams...

Not really a workable solution for us, but might work for someone else.