Webhook Powered ArcGIS Monitor Notifications in MS Teams
In our last blog post, we shared how to send simple ArcGIS Monitor notifications to Microsoft Teams. Since then, we have been tinkering more with ArcGIS Monitor in an attempt to get more detailed information from our clients’ servers. In the process, we’ve found the need to set up additional notifications using Teams webhooks.
There are several reasons you might want to set up something similar: Proof of Concept starting blocks or maybe, like us, you want custom notification content. Let’s examine each of those reasons:
- As a proof of concept and starting point, this hits all the marks. We can show successful integration between two powerful tools. Once all these tools are connected together, ideas will start. We have already started down the path of Teams interaction, working with Power Automate in our previous blog post. The next step is integration with automation workflows such as Power Automate, Automate.io, and pushing into systems like ServiceNow or Microsoft Teams Tasks, or even GitHub. We can create support tickets and automatically assign them to the right people to review and resolve Enterprise GIS issues.
- The notifications from ArcGIS Monitor 10.8 allow us to configure alerts from a collection. Direct emails can be sent from individual counters such as System, ArcGIS, Portal, and DB. We can finetune the notifications to better fit the team dynamic. We can combine counters or collections and we can add extra links, information, or images to help the users understand the issue and help them resolve the issue faster.
The first step of this process is to add the WebHook Connector to your Teams channel. Microsoft has a great help document on the webhook connector and how to add it to your Teams channel.
pip install pymsteams
in Command Prompt or Windows PowerShell.The next step is to configure your python script to write to the webhook. A variable that contains the webhook URL from the previous step will need to be put into the code. In our code example you can see where to include this. The business logic will depend on what you’d like to show in your team’s chat. For us, we just wanted to show the overall categories and the descriptions associated with them. You could parse the values to change colors or labels depending on the alerting status. You could also include images and even links. All of this will depend on what you and your team decide is important.
This script will need to be run so that it can check into ArcGIS Monitor and post into Teams. We chose Windows Task Scheduler for this. We set it up to run once an hour, but you might want to adjust it to the start of the day, midday, or any time interval that works for you.
Open Windows Task Scheduler and create a new Task. Name the task and give it a description. You will need to define the Trigger and timing. We chose daily, once an hour, indefinitely. Once you have created the task you can fine tune the trigger times from inside the task.
We have placed the python script into our GitHub repository so you can have a good starting place.
Have questions? Did you get your ArcGIS Monitor notifications set up? We’d love to hear from you! Email us or post a comment below.