Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
sabatale
Contributor
1,882
One of the best things about SAP Cloud ALM is how open and flexible the solution is. You can easily integrate it with standard mappings, such as ServiceNow or Microsoft Teams, but also build your own. With the recent release of External Chat Systems events (see this blog post), customers and partners can now extend SAP Cloud ALM to various chat solutions. The present post will highlight how to do so with Slack, arguably one of the most popular products on the market today.

Event Actions

"Events" are essentially triggers. Whenever SAP Cloud ALM detects an anomaly, such as a failed call on CPI, a high number of dumps in S/4HANA or an unusual peak in late vendor payments on the business side, you have the choice to setup a follow-up action.

The easiest actions would be the automated creation of an alert in CALM itself - the "Create Alert" action - or send an email to a distribution list - the "Send Email To" action. However, most customers already use corporate ticketing solutions, in which case a ticket can be automatically generated in ServiceNow - the "Create Ticket" action.

Another type of action is the "Send Chat Message". This is most likely for events that are critical and require immediate attention, in which case you may want to not only create a ticket but also ping the responsible team on MS Teams, Slack or else.

Slack Webhooks

First you need to create a Slack App. This will allow you to define a custom webhook for SAP Cloud ALM to send data to. The official Slack documentation details the steps very well: https://api.slack.com/messaging/webhooks.

After creating the app, navigate to Incoming Webhooks and active the feature. Then click Add New Webhook to Workspace to generate the target URL (starting with https://hooks.slack.com/services/).

You will need to associate the webhook with a single channel. For testing purpose, I'd recommend you create a separate one until you feel comfortable going live with the integration.


Slack App


The Fun part

Now you need to define your message formatting. Luckily Slack provides you with a template sandbox where you can easily preview how your code will look like: Slack Block Kit Builder.

You can start with something as simple as a single line message:
{ "text": "This is your message." }

Or use Markdown to make it look more professional:
{
"blocks":[
{
"type":"section",
"text":{
"type":"mrkdwn",
"text":"Hello, this is your message! \n *Bold* text goes *here*."
}
}
]
}


Slack Block Builder


Stay CALM

Pretty easy, right? We now have a webhook and payload to be defined in SAP Cloud ALM.

Access the BTP Subaccount and create a destination as follow:

  • URL: Your Slack webhook

  • Type: Internet

  • Authentication: NoAuthentication


Navigate to your instance, open the Administration and find the application External API Management. Go to Webhooks Management and create a new one as follow:

  • Destination Source: BTP Destination

  • Destination ID: The destination you just created

  • External Resource Type: Chat

  • Destination Type: Slack (free text)


Go to Mappings Management and create a new one as well. The Source and Destination are free text fields and do not influence the mapping at this time. It is up to you to choose a Mapping Type based on your own preference - you can learn more about this here: https://help.sap.com/docs/cloud-alm/apis/mapping.

Here is an example for Payload-based mappings to help you start:
{
"_information": {
"_version": "1",
"_source": "SAP Cloud ALM Event Situation",
"_destination": "Slack",
"_name": "SAP Cloud ALM Event Situation to Slack",
"_comment": ""
},
"structure": {
"request": {
"type": "message",
"attachments": [
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*[SAP Cloud ALM for Operations]* #{subject}"
},
"accessory": {
"type": "image",
"image_url": "https://yourimage.jpg",
"alt_text": "SAP Cloud ALM Alerting"
}
}
]
}
]
},
"response": {
"chatCreated": true
}
},
"eventTypeMapping": {
"_comment": "Specific event type mapping",
"operationMappings": [
{
"eventType": "EVENT-SITUATION.CREATED",
"operation": "POST",
"responseRoot": ""
}
]
}
}

Finally go to Subscriptions Management and create one as follow:

  • Type: Built-In

  • Webhook: Your Webhook.

  • Mapping: Your Mapping.


Voilà !

You can now assign your subscription to any of your SAP Cloud ALM Events and test it. All requests are logged in the API Console in SAP Cloud ALM, where you should expect a Status 200 OK with the Response Data:
{ "chatCreated": true }


Slack Alert

1 Comment
Labels in this area