SAP CLOUD ALM API: Integration with External Chat System (Alerts to Slack)

Estimated read time 10 min read

Objectives

You want to forward SAP Cloud ALM alerts (Event situation) tasks events to external chat systems like Slack.

Prerequisites

Any chat external system can be connected to SAP Cloud ALM using the provided External API Integration capabilities.

The external tool must:

Expose REST APIs to receive messages.Expose an API endpoint accessible from your SAP Cloud ALM BTP sub-account.Support one of the following authentication protocol described in the following documentation.Support a compatible payload for REST operations. The list of supported mapping rules can be found in the help.sap.com.

If the external tools do not match the requirements for a simple integration, an integration can still be achieved by using SAP Integration Suite or a third-party API Integration HUB platform.
 

Procedure Overview

 

Configure Slack channel to receive data from SAP Cloud ALM.Configure an SAP BTP destination to enable connectivity to your external system.Configure an SAP Cloud ALM web-hook to enable communication between your external system and your SAP Cloud ALM tenant.Create an SAP Cloud ALM mapping to define the transformation rules to apply to messages exchanges between SAP Cloud ALM and the external system.Add a SAP Cloud ALM subscription to associate the external system with the event types raised by SAP Cloud ALM.Send an alert from SAP Cloud ALM to associate SAP Cloud ALM subscriptions and see the result in the external system.

 

Configure Slack channel to receive data from SAP Cloud ALM

Go to https://api.slack.com/apps and click on  then select “From scratch”.

Enter a name and select your workspace:

Open the permissions:

Copy the oAuth token (will be use in the BTP destination) and add the scopes:

Install the app:

Open the channel details:

Copy the channel ID (will be used in the SAP Cloud ALM subscription):

Add the app to the channel:

Then

Result:

The configuration on Slack side is done.

 

Configure SAP BTP destination

In your SAP BTP Cockpit create a destination to your external Slack system.

The SAP BTP destination enables the connectivity from your SAP BTP tenant to your external system.

Add an additional property: URL.headers.Authorization = Bearer xoxb-3512166….. (Bearer oAuth2_token)

Configure SAP Cloud ALM Web-hook

 

In the SAP Cloud ALM External API Management application, create a web-hook for your destination with the following parameters:

External resource type: Chat. Destination type: Enter Other.

Check the help.sap.portal for more information.

Create a SAP Cloud ALM mapping

The mapping defines the transformation rule to apply before sending the request and after receiving the response from the external system.

You can use the following mapping example and adjust it to your needs.

The mapping content is:

 

 

{
“_information”: {
“_version”: “1”,
“_source”: “IEP”,
“_destination”: “SLACK”,
“_name”: “IEP to SLACK”,
“_comment”: “SLACK – Channel #sap-cloud-alm-2-slack”
},
“switches”: [
{
“name”: “switchPriority”,
“cases”: [
{
“when”: “FATAL”,
“then”: “Highest”
},
{
“when”: “ERROR”,
“then”: “High”
},
{
“when”: “WARNING”,
“then”: “Low”
},
{
“when”: “INFO”,
“then”: “Lowest”
}
],
“default”: “Lowest”
}
],
“structure”: {
“request”: {
“ok”: true,
“username”: “SAP_CLOUD_ALM”,
“channel”: “#{@USER_VAR(channel)}”,
“blocks”: [
{
“type”: “section”,
“text”: {
“type”: “mrkdwn”,
“text”: “*SAP Cloud ALM Event: EVENT-SITUATION.CREATED*”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “Subject: #{subject}”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “Description: rating:#{rating} – priority:${SWITCH(switchPriority,rating)} – serviceType:#{serviceType} – serviceId:#{serviceId} – eventType:#{eventType} – eventName:#{eventName}”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “workNotes: #{workNotes}”
}
}
]
},
“response”: {
“externalStatus”: “New”,
“displayUrl”: “https://www.sap.com”,
“externalNumber”: “1234”,
“externalId”: “0123456789”
}
},
“eventTypeMapping”: {
“_comment”: “Specificeventtypemapping”,
“operationMappings”: [
{
“eventType”: “EVENT-SITUATION.CREATED”,
“operation”: “POST”,
“responseRoot”: “”
},
{
“eventType”: “EVENT-SITUATION.CLOSED”,
“operation”: “POST”,
“responseRoot”: “”,
“structure”: {
“request”: {
“ok”: true,
“username”: “SAP_CLOUD_ALM”,
“channel”: “#{@USER_VAR(channel)}”,
“blocks”: [
{
“type”: “section”,
“text”: {
“type”: “mrkdwn”,
“text”: “*SAP Cloud ALM Event: EVENT-SITUATION.CLOSED*”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “Subject: #{subject}”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “Description: rating:#{rating} – priority:${SWITCH(switchPriority,rating)} – serviceType:#{serviceType} – serviceId:#{serviceId} – eventType:#{eventType} – eventName:#{eventName}”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “workNotes: #{workNotes}”
}
}
]
},
“response”: {
“externalStatus”: “New”,
“displayUrl”: “https://www.sap.com”,
“externalNumber”: “1234”,
“externalId”: “0123456789”
}
}

},
{
“eventType”: “EVENT-SITUATION.UPDATED”,
“operation”: “POST”,
“responseRoot”: “”,
“structure”: {
“request”: {
“ok”: true,
“username”: “SAP_CLOUD_ALM”,
“channel”: “#{@USER_VAR(channel)}”,
“blocks”: [
{
“type”: “section”,
“text”: {
“type”: “mrkdwn”,
“text”: “*SAP Cloud ALM Event: EVENT-SITUATION.UPDATED*”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “Subject: #{subject}”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “Description: rating:#{rating} – priority:${SWITCH(switchPriority,rating)} – serviceType:#{serviceType} – serviceId:#{serviceId} – eventType:#{eventType} – eventName:#{eventName}”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “workNotes: #{workNotes}”
}
}
]
},
“response”: {
“externalStatus”: “New”,
“displayUrl”: “https://www.sap.com”,
“externalNumber”: “1234”,
“externalId”: “0123456789”
}
}
},
{
“eventType”: “EVENT-SITUATION.PING”,
“operation”: “POST”,
“responseRoot”: “”,
“structure”: {
“request”: {
“ok”: true,
“username”: “SAP_CLOUD_ALM”,
“channel”: “#{@USER_VAR(channel)}”,
“blocks”: [
{
“type”: “section”,
“text”: {
“type”: “mrkdwn”,
“text”: “*SAP Cloud ALM Event: EVENT-SITUATION.PING*”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “Subject: #{subject}”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “Description: rating:#{rating} – priority:${SWITCH(switchPriority,rating)} – serviceType:#{serviceType} – serviceId:#{serviceId} – eventType:#{eventType} – eventName:#{eventName}”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “workNotes: #{workNotes}”
}
}
]
},
“response”: {
“externalStatus”: “New”,
“displayUrl”: “https://www.sap.com”,
“externalNumber”: “1234”,
“externalId”: “0123456789”
}
}
}
]
}
}

 

 

Check the help.sap.portal for more information.

 
Add a SAP Cloud ALM subscription

Create a subscription based on your web-hook and your mapping with the following parameters:

Resource type: Event Situation to use this subscription for events raised for resources managed by the monitoring applications.TypeBuilt-in to apply a transformation payload.

Use the channel id from Slack in the user variable.

Check the help.sap.portal for more information. 

Send an alert from Health Monitoring

Open an alert in Health Monitoring and click on Send Chat Notification:

Select the previously created subscription:

The alert content is sent to the slack channel:

Monitor resources changes events

In the SAP Cloud ALM External API Management application, you can monitor the events exchanged with your external system.

More Information

SAP Cloud ALM API Guide

Thanks for reading

 

​ ObjectivesYou want to forward SAP Cloud ALM alerts (Event situation) tasks events to external chat systems like Slack.PrerequisitesAny chat external system can be connected to SAP Cloud ALM using the provided External API Integration capabilities.The external tool must:Expose REST APIs to receive messages.Expose an API endpoint accessible from your SAP Cloud ALM BTP sub-account.Support one of the following authentication protocol described in the following documentation.Support a compatible payload for REST operations. The list of supported mapping rules can be found in the help.sap.com.If the external tools do not match the requirements for a simple integration, an integration can still be achieved by using SAP Integration Suite or a third-party API Integration HUB platform. Procedure Overview Configure Slack channel to receive data from SAP Cloud ALM.Configure an SAP BTP destination to enable connectivity to your external system.Configure an SAP Cloud ALM web-hook to enable communication between your external system and your SAP Cloud ALM tenant.Create an SAP Cloud ALM mapping to define the transformation rules to apply to messages exchanges between SAP Cloud ALM and the external system.Add a SAP Cloud ALM subscription to associate the external system with the event types raised by SAP Cloud ALM.Send an alert from SAP Cloud ALM to associate SAP Cloud ALM subscriptions and see the result in the external system. Configure Slack channel to receive data from SAP Cloud ALMGo to https://api.slack.com/apps and click on  then select “From scratch”.Enter a name and select your workspace:Open the permissions:Copy the oAuth token (will be use in the BTP destination) and add the scopes:Install the app:Open the channel details:Copy the channel ID (will be used in the SAP Cloud ALM subscription):Add the app to the channel:ThenResult:The configuration on Slack side is done. Configure SAP BTP destinationIn your SAP BTP Cockpit create a destination to your external Slack system.The SAP BTP destination enables the connectivity from your SAP BTP tenant to your external system.Add an additional property: URL.headers.Authorization = Bearer xoxb-3512166….. (Bearer oAuth2_token)Configure SAP Cloud ALM Web-hook In the SAP Cloud ALM External API Management application, create a web-hook for your destination with the following parameters:External resource type: Chat. Destination type: Enter Other.Check the help.sap.portal for more information.Create a SAP Cloud ALM mappingThe mapping defines the transformation rule to apply before sending the request and after receiving the response from the external system.You can use the following mapping example and adjust it to your needs.The mapping content is:  {
“_information”: {
“_version”: “1”,
“_source”: “IEP”,
“_destination”: “SLACK”,
“_name”: “IEP to SLACK”,
“_comment”: “SLACK – Channel #sap-cloud-alm-2-slack”
},
“switches”: [
{
“name”: “switchPriority”,
“cases”: [
{
“when”: “FATAL”,
“then”: “Highest”
},
{
“when”: “ERROR”,
“then”: “High”
},
{
“when”: “WARNING”,
“then”: “Low”
},
{
“when”: “INFO”,
“then”: “Lowest”
}
],
“default”: “Lowest”
}
],
“structure”: {
“request”: {
“ok”: true,
“username”: “SAP_CLOUD_ALM”,
“channel”: “#{@USER_VAR(channel)}”,
“blocks”: [
{
“type”: “section”,
“text”: {
“type”: “mrkdwn”,
“text”: “*SAP Cloud ALM Event: EVENT-SITUATION.CREATED*”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “Subject: #{subject}”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “Description: rating:#{rating} – priority:${SWITCH(switchPriority,rating)} – serviceType:#{serviceType} – serviceId:#{serviceId} – eventType:#{eventType} – eventName:#{eventName}”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “workNotes: #{workNotes}”
}
}
]
},
“response”: {
“externalStatus”: “New”,
“displayUrl”: “https://www.sap.com”,
“externalNumber”: “1234”,
“externalId”: “0123456789”
}
},
“eventTypeMapping”: {
“_comment”: “Specificeventtypemapping”,
“operationMappings”: [
{
“eventType”: “EVENT-SITUATION.CREATED”,
“operation”: “POST”,
“responseRoot”: “”
},
{
“eventType”: “EVENT-SITUATION.CLOSED”,
“operation”: “POST”,
“responseRoot”: “”,
“structure”: {
“request”: {
“ok”: true,
“username”: “SAP_CLOUD_ALM”,
“channel”: “#{@USER_VAR(channel)}”,
“blocks”: [
{
“type”: “section”,
“text”: {
“type”: “mrkdwn”,
“text”: “*SAP Cloud ALM Event: EVENT-SITUATION.CLOSED*”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “Subject: #{subject}”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “Description: rating:#{rating} – priority:${SWITCH(switchPriority,rating)} – serviceType:#{serviceType} – serviceId:#{serviceId} – eventType:#{eventType} – eventName:#{eventName}”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “workNotes: #{workNotes}”
}
}
]
},
“response”: {
“externalStatus”: “New”,
“displayUrl”: “https://www.sap.com”,
“externalNumber”: “1234”,
“externalId”: “0123456789”
}
}

},
{
“eventType”: “EVENT-SITUATION.UPDATED”,
“operation”: “POST”,
“responseRoot”: “”,
“structure”: {
“request”: {
“ok”: true,
“username”: “SAP_CLOUD_ALM”,
“channel”: “#{@USER_VAR(channel)}”,
“blocks”: [
{
“type”: “section”,
“text”: {
“type”: “mrkdwn”,
“text”: “*SAP Cloud ALM Event: EVENT-SITUATION.UPDATED*”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “Subject: #{subject}”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “Description: rating:#{rating} – priority:${SWITCH(switchPriority,rating)} – serviceType:#{serviceType} – serviceId:#{serviceId} – eventType:#{eventType} – eventName:#{eventName}”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “workNotes: #{workNotes}”
}
}
]
},
“response”: {
“externalStatus”: “New”,
“displayUrl”: “https://www.sap.com”,
“externalNumber”: “1234”,
“externalId”: “0123456789”
}
}
},
{
“eventType”: “EVENT-SITUATION.PING”,
“operation”: “POST”,
“responseRoot”: “”,
“structure”: {
“request”: {
“ok”: true,
“username”: “SAP_CLOUD_ALM”,
“channel”: “#{@USER_VAR(channel)}”,
“blocks”: [
{
“type”: “section”,
“text”: {
“type”: “mrkdwn”,
“text”: “*SAP Cloud ALM Event: EVENT-SITUATION.PING*”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “Subject: #{subject}”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “Description: rating:#{rating} – priority:${SWITCH(switchPriority,rating)} – serviceType:#{serviceType} – serviceId:#{serviceId} – eventType:#{eventType} – eventName:#{eventName}”
}
},
{
“type”: “section”,
“text”: {
“type”: “plain_text”,
“text”: “workNotes: #{workNotes}”
}
}
]
},
“response”: {
“externalStatus”: “New”,
“displayUrl”: “https://www.sap.com”,
“externalNumber”: “1234”,
“externalId”: “0123456789”
}
}
}
]
}
}  Check the help.sap.portal for more information. Add a SAP Cloud ALM subscriptionCreate a subscription based on your web-hook and your mapping with the following parameters:Resource type: Event Situation to use this subscription for events raised for resources managed by the monitoring applications.Type: Built-in to apply a transformation payload.Use the channel id from Slack in the user variable.Check the help.sap.portal for more information. Send an alert from Health MonitoringOpen an alert in Health Monitoring and click on Send Chat Notification:Select the previously created subscription:The alert content is sent to the slack channel:Monitor resources changes eventsIn the SAP Cloud ALM External API Management application, you can monitor the events exchanged with your external system.More InformationSAP Cloud ALM API GuideThanks for reading   Read More Technology Blogs by SAP articles 

#SAP

#SAPTechnologyblog

You May Also Like

More From Author