1 min read

Connect SAP Hybris Commerce with Slack API’s

Introduction

Slack has experienced a significant increase in its popularity and use since it first launched back in 2014. It has become the go-to collaboration tool for major enterprises of all sizes and industries. The ability to build your own slack apps and easily integrating with other systems makes it even more popular within the tech community. In this blog post, I explore the different features available within a slack app and how they can be leveraged with SAP Hybris Commerce using a quick and dirty prototype.

Scenario Overview

The yIntegration Slack App will be using the following features and functionality of the Slack API:

  • Incoming Webhooks: A simple way to post messages to Slack from external sources. In this case, I will be using incoming webhooks to post Hybris Cronjob status messages to Slack.
  • Slash Commands: This offers a convenient way to trigger actions for the yIntegration app directly from the Slack message box. In this prototype, I have used slash commands to interact with the Hybris Stock Service and get stock updates for products.
  • Bots & Events: We can create a bot user and bundle it with the Slack app to facilitate more conversational interactions. Event subscriptions are the primary way to interact with the bot events. I have this functionality to connect with the Hybris Stock Service more conversationally.

PoC Explained

The integration app uses two slash commands to interact with Hybris Commerce, which is explained below:

PoC Explained

/Stock: This command is used to get the stock of all the products and post it into the slack channel. If the product id is also provided as a parameter in the stock command, it will look up the stock for that particular product and get the stock status.

Stock for all products:

Stock for all products

Stock for specified Product:

Stock for specified Product

edit command

general

The yIntegration app also contains a bot which I used to trigger events using the Events API. I have subscribed the ‘hybrisbot to “app_mention” event which will be triggered every time the bot is mentioned in the slack chat. There are many other events that are available which can be used to subscribe to bot events.

yIntegration app also contains a bot

slack

Another use case which is implemented in the app is to notify slack about the cronjob results. I have extended the OOTB ‘electronics-CartRemovalJob’ to send notifications to slack about the cronjob results using the Slack Incoming Webhooks.

Another use case