Sending Alerts to Slack and Microsoft Teams

Set up a webhook to receive notifications about failed events in your integration runs.

To monitor the status of your integrations, you can set up a webhook to receive real-time notifications about events that fail during integration runs. This allows you to promptly address issues, minimizing downtime and ensuring the smooth operation of your integrations. To learn more about webhooks, see Webhooks.

You can access synchronization logs for integrations in the Synchronization Logging section of the administration area. For more information, see Synchronization Logging.

📘

Note

You can modify the webhook callback to receive notifications for specific event types, not only for failed ones. To learn how to use callbacks, see Manipulating the Webhook Payload Using a Callback.

Sending Alerts to Slack

To send alerts for failed integration events to Slack, in SAP LeanIX, create a PUSH webhook. For instructions, see Creating a Webhook. When creating a webhook, specify the following details:

  • Triggering Events: Select INTEGRATION_RUN_FINISHED and INTEGRATION_RUN_ABORTED.

  • Target URL: You can get a target URL from the incoming webhook that you've set up in Slack.

  • Callback: Enter the following code to filter failed events. Replace workspace_url with your workspace URL that includes the workspace name, for example, https://your-company.leanix.net/WorkspaceName.

    var payload = delivery.payload;
    delivery.active = false;
    var base_url = 'workspace_url';
    if (payload.errorCount > 0) {
        delivery.active = true;
        var text = payload.type + ' with Scope: ' + payload.scope + ' has status: ' + payload.progress + ' and error count: ' + payload.errorCount; text += '. Synclog link : ' + base_url + '/admin/synclog/' + payload.synchronizationId;
    }
    delivery.payload = { text: text } 
    

Sending Alerts to Microsoft Teams

To send alerts for failed integration events to Microsoft Teams, in SAP LeanIX, create a PUSH webhook. For instructions, see Creating a Webhook. When creating a webhook, specify the following details:

  • Triggering Events: Select INTEGRATION_RUN_FINISHED and INTEGRATION_RUN_ABORTED.

  • Target URL: To get a target URL for event notifications, create a workflow in Microsoft Teams. Wokrflows enable you to automate processes that connect one or more apps to Microsoft Teams. To learn how to create workflows, refer to the Microsoft documentation. If you're using Office 365 connectors, migrate your existing connectors to workflows. To learn more, see the blog entry Retirement of Office 365 connectors within Microsoft Teams on the Microsoft 365 Developer Blog.

  • Callback: Enter the following code to filter failed events. Replace workspace_url with your workspace URL that includes the workspace name, for example, https://your-company.leanix.net/WorkspaceName.

    var payload = delivery.payload;
    delivery.active = false;
    var base_url = 'workspace_url';
    if (payload.errorCount > 0) {
        delivery.active = true;
        var uri = base_url + '/admin/synclog/' + payload.synchronizationId
        var text = payload.type + ' with Scope: ' + payload.scope + ' has status: ' + payload.progress + ' and error count: ' + payload.errorCount + '.';
        text += "Click **Sync Log** to check details!";
    }
    delivery.payload = {
    
        "type":"message",
        "attachments":[
           {
              "contentType":"application/vnd.microsoft.card.adaptive",
              "contentUrl":null,
              "content":{
                 "$schema":"http://adaptivecards.io/schemas/adaptive-card.json",
                 "type":"AdaptiveCard",
                 "version":"1.2",
                 "body":[
                    {
                        "type": "TextBlock",
                        "size": "Medium",
                        "weight": "Bolder",
                        "text": payload.type+" Failed",
                        "style": "heading",
                        "wrap": true
                    },
                     {
                     "type": "TextBlock",
                     "text": text,
                     "wrap":true
                     }
                 ],
                 "actions": [
                     {
                        "type": "Action.OpenUrl",
                        "title": "Sync Log",
                        "url": uri,
                        "role": "Button"
                    }
                ],
              }
           }
        ]
    }