- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Webhooks in Slack or Teams...
Anyone got that working?
Solved! Go to solution.
- Labels:
-
Dashboard API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.." }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
https://create.meraki.io/build/network-alerting-in-webex-teams-with-webhooks/
https://meraki.cisco.com/blog/2018/10/real-time-alerting-with-webhooks/
https://create.meraki.io/guides/webhooks/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nothing for Slack/Teams Webhooks though and test in the dashboard also fails... The hook does work fine with curl though...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.." }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
UPDATE
- with Webhook Payload Templates (beta) you can now send alerts DIRECTLY to Slack or Teams without middleware.
More info here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks! Was hoping this would be useful to someone.
Since there is no view engine defined there is no view to render the error, so that makes sense. I will update with that change and upload new docker container/commit to github.
Will also add documentation to github 😉 It's been on my todo list...
Edit: have uploaded new docker container, and committed updated code to github.
