# MS Teams

{% hint style="info" %}
Adding notification integrations requires admin privileges in groundcover
{% endhint %}

To integrate groundcover with MS Teams, follow the steps below. Note that you’ll need at least a **Business** subscription of MS Teams to be able to create workflows.

1. **Create a webhook workflow for your dedicated Teams channel**\
   Go to Relevant Team -> Specific Channel -> "Workflows", and create a webhook workflow
2. **The webhook workflow is associated a URL** which is used to trigger the MS Teams integration on groundcover - make sure to copy this URL
3. **Set Up the Webhook in groundcover**

   * Head out to the integrations section: Settings -> Integrations, to create a new [Webhook](https://docs.groundcover.com/integrations/workflow-integrations/webhook-integration)
   * Start by giving your Webhook integration a name. This name will be used below in the provider block sample .
   * Set the `Webhook URL` to the url you copied from field (2)
   * Keep the HTTP method as `POST`

   <figure><img src="/files/B8CfLxmlSsYuAi5EK8fF" alt=""><figcaption></figcaption></figure>

   \
   \\

   <figure><img src="/files/frzPsHgarvYc122wLOaw" alt="" width="375"><figcaption></figcaption></figure>
4. **Create a Workflow**\
   Go to `Monitors --> Workflows --> Create Workflow`, and paste the YAML configuration provided below.
5. **Configure the `provider` Blocks (There are two of them)**\
   In the `provider` block, replace `{{ providers.your-teams-integration-name }}` with your actual Webhook integration name (the one you created in step 3)\
   For example, if you named your integration `test-ms-teams`, the config reference would be: `{{ providers.test-ms-teams }}`

{% hint style="info" %}
The following example shows a pre-configured MS Teams workflow template. You can easily modify workflows to support different formats based on the MS Teams workflow schema.
{% endhint %}

**Sample code for your groundcover workflow:**

```yaml
workflow:
  id: teams-webhook
  description: Sends an API to MS Teams alerts endpoint
  name: ms-teams-alerts-workflow
  triggers:
  - type: alert
    filters:
    - key: annotations.ms-teams-alerts-workflow
      value: enabled
  consts:
    silence_link: 'https://app.groundcover.com/monitors/create-silence?keep.replace(keep.join(keep.dict_pop({{ alert.labels }}, "_gc_monitor_id", "_gc_monitor_name", "_gc_severity", "backend_id", "grafana_folder"), "&", "matcher_"), " ", "+")'
    monitor_link: 'https://app.groundcover.com/monitors?backendId={{ alert.labels.backend_id }}&selectedObjectId={{ alert.labels._gc_monitor_id }}'
    title_link: 'https://app.groundcover.com/monitors/issues?backendId={{ alert.labels.backend_id }}&selectedObjectId={{ alert.fingerprint }}'
    description: keep.dictget( {{ alert.annotations }}, "_gc_description", '')
    redacted_labels: keep.join(keep.dict_pop({{alert.labels}}, "_gc_monitor_id", "_gc_monitor_name", "_gc_severity", "backend_id", "grafana_folder", "_gc_issue_header"), "-\n")
    title: keep.dictget( {{ alert.annotations }}, "_gc_issue_header", "{{ alert.alertname }}")

  actions:
  - if: '{{ alert.status }} == "firing"'
    name: teams-webhook-firing
    provider:
      config: ' {{ providers.your-teams-integration-name }} '
      type: webhook
      with:
        body:
          type: message
          attachments:
          - contentType: application/vnd.microsoft.card.adaptive
            content:
              $schema: http://adaptivecards.io/schemas/adaptive-card.json
              type: AdaptiveCard
              version: "1.2"
              body:
              - type: TextBlock
                text: "\U0001F6A8 Firing: {{ consts.title }}"
                weight: bolder
                size: large
              - type: TextBlock
                text: "[Investigate Issue]({{consts.title_link}})"
                wrap: true
              - type: TextBlock
                text: "{{ consts.description }}"
                wrap: true
              - type: TextBlock
                text: "[Silence]({{consts.silence_link}})"
                wrap: true
              - type: TextBlock
                text: "[See monitor]({{consts.monitor_link}})"
                wrap: true
              - type: TextBlock
                text: "{{ consts.redacted_labels }}"
                wrap: true
  - if: '{{ alert.status }} != "firing"'
    name: teams-webhook-resolved
    provider:
      config: ' {{ providers.your-teams-integration-name }} '
      type: webhook
      with:
        body:
          type: message
          attachments:
          - contentType: application/vnd.microsoft.card.adaptive
            content:
              $schema: http://adaptivecards.io/schemas/adaptive-card.json
              type: AdaptiveCard
              version: "1.2"
              body:
              - type: TextBlock
                text: "\U0001F7E2 Resolved: {{ consts.title }}"
                weight: bolder
                size: large
              - type: TextBlock
                text: "[Investigate Issue]({{consts.title_link}})"
                wrap: true
              - type: TextBlock
                text: "{{ consts.description }}"
                wrap: true
              - type: TextBlock
                text: "[Silence]({{consts.silence_link}})"
                wrap: true
              - type: TextBlock
                text: "[See monitor]({{consts.monitor_link}})"
                wrap: true
              - type: TextBlock
                text: "{{ consts.redacted_labels }}"
                wrap: true
  
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.groundcover.com/~/revisions/wppaVAUQcsAgts3lmC6b/integrations/workflow-integrations/ms-teams.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
