11-13-2018 02:01 AM
Anyone got that working?
Solved! Go to Solution.
11-21-2018 07:36 AM
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.." }
11-13-2018 06:59 AM
11-13-2018 08:01 AM
Nothing for Slack/Teams Webhooks though and test in the dashboard also fails... The hook does work fine with curl though...
11-13-2018 10:51 AM
@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.
11-14-2018 01:51 AM
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.
11-14-2018 07:09 AM
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?
11-14-2018 07:15 AM
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...
11-20-2018 07:09 AM
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!
11-21-2018 07:36 AM
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.." }
11-21-2018 09:19 AM
07-11-2019 05:33 PM
Here is how the Zapier settings for my Meraki <--> Zapier<--> Slack integration look like... in case it helps.
ps: Keep up the great work Tony Carmichael!
10-07-2021 05:14 AM
UPDATE
- with Webhook Payload Templates (beta) you can now send alerts DIRECTLY to Slack or Teams without middleware.
More info here
01-14-2019 08:13 AM
I have spent a few hours trying to configured webhook to work with slack. I agree, it seems like a a useless feature. All tech support does is pointing you to un-relevant documents.
03-05-2019 08:26 AM
I needed this ability, so I wrote a nodejs app to be the middleware. To try and make it easy to use I turned that into a docker container (because isn't everything in a docker container now??). Added support for Slack, MS Teams, and Telegram. Would be easy to add services like Discord, or any other services that has an API you can POST to.
Also posted the code on Github
03-07-2019 02:21 AM
Nice work! This will be a great benefit to all.
.. I had to make a small change to the app.js file line 29
res.render('error');by using this method, it doesn't require a default view to be setup and works great.res.json({ error: err });> node ./bin/www POST / 400 24.616 ms - 1314 Error: No default engine was specified and no extension was provided. at new View (/Users/u/dev/merakialerts/node_modules/express/lib/view.js:61:11)
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide