How to send basic messages into Microsoft Teams channel | Nutanix Community
Skip to main content

So I recently asked this question… 

https://next.nutanix.com/api-31/playbook-rest-api-post-teams-37756?postid=51764#post51764

I saw support for slack but no teams… I got to looking and sure enough API’s are available to call from within playbooks yipee! 

 

Youll need to create an incoming web-hook in teams (google this if you dont have it setup). 

open up a team channel, click connectors

 

select configure
give it a name, upload an image and hit create

Once you do that you now have a url which an be used to post messages to via script or whatever your flavor is. 

 

In nutanix heres what i set

 

Prism Central 

 

set a custom alert policy to 5-10% cpu so it would trigger a lot and selected my test vm

 

Result:

niceeeee

Obviously this is my very fist time attempting this and I literally just figured it out but in the near future Id like to see if I can call the alert parameters, include useful information automatically e.g only alert on critical, and include the alert info.

Cheers! 

Aidan

Nicely done @adoyle . 

Cheers :smiley:


now i just need to try figure out how to get alert info into that message instead of manually, becuase then ill end up with 100 manual messages and playbooks:sweat_smile:


Well done @adoyle Thanks for sharing, this will certainly help a lot of other community folks with the same desire :thumbsup:


so what im now thinking i will have to do is build my own api so I can run a get on the nutanix api and return the values to my teams post message…. and devs willing to point me in the general direction? Is there something natively on nutanix I can/should use for this? or would I be better off just building something in node myself? 

or anyone running something remotely to call the nutanix apis and generating the slack/teams alerts form there? 

Just some ideas… 


That actually sounds like an amazing plan @adoyle . :smile: So if I am not wrong you want to send the alert details inside that message to the MS teams.

Maybe the below REST API resources can help::sweat_smile:

1) REST API v2 alerts: https://www.nutanix.dev/reference/prism_element/v2/api/alerts/post-alerts-acknowledge-acknowledgealerts/

2)REST API v3 Alerts: https://www.nutanix.dev/reference/prism_central/v3/api/alerts/postalertsactionaction/

3)Here are some links to using Nutanix REST APIs https://www.nutanix.dev/api-reference/​​​​​​​ and some other useful stuff at https://www.nutanix.dev/ .

 

 


Hey, @adoyle did you try using the above alert related APIs?

 

Also I thought this might help too: https://next.nutanix.com/api-31/filter-alerts-via-api-from-prism-central-37704?postid=51487#post51487

 

Let me know if you need anything else which could help:smiley:

 

 


dudes ive just figured it all out… will add in the update when I get a bit of time and work on the MS json a little more. 

You can use the inbuilt nutanix parameters to get the alert info… pure magical bliss


Hey @adoyle , that sounds great. Really excited to know how you accomplished it.:smiley:

 


So here is how you add messagecards to teams…. few things: 

 

  1. using teams webhooks means you cannot do any of the really cool stuff 
  2. You must use messagecards and include the schema @context
  3. you want to do more - look at building a bot + flow 
  4. I wish we could change the nutanix alert policies to include the API as manually creating playbooks for single alerts is terrible (im going to see what options are available)

https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference

 

Here is a very functional json body for teams including the Nutanix parameters : 

 

{

"@context": "https://schema.org/extensions",

"@type": "MessageCard",

"summary": "\"Nutanix Card\"",

"themeColor": "ff001a",

"sections": c

{

"activityTitle": "**TX1PRDNTNXCL01**",

"activitySubtitle": " _Alert: Creation Time_ ",

"activityImage": "https://futurumresearch.com/wp-content/uploads/2019/09/Nutanix-Logo.gif",

"facts": "

{

"name": "Severity:",

"value": "**Alert: Severity**"

},

{

"name": "Created On:",

"value": " _Alert: Creation Time_ "

},

{

"name": "Alert Name:",

"value": " Alert: Alert Name"

},

{

"name": "Alert Source: Alert: Source Entity Name",

"value": " Alert: Source Entity Name"

}

]

}

],

"potentialAction": A

{

"@type": "OpenUri",

"name": "View alerts",

"targets": a

{

"os": "default",

"uri": "https://yourecvmorpcvm:9440/console/#page/explore/s/alerts/?term_1=alert&term_2=alert%2Cattribute%2Cresolved%2C%3D%2Cfalse"

}

]

}

]

}

 


which looks like so

and you can go to the alerts via link in the message


Thanks for sharing your findings @adoyle :clap: