Skip to Content
Technical Articles
Author's profile photo Gregor Wolf

Combine Power Automate, Microsoft Teams Approvals and an SAP Cloud Application Programming Model (CAP) App

Context and possible options

Right now, I’m involved in a Side-by-Side Extension Product development. The application is implemented using the SAP Cloud Application Programming Model (CAP) using the NodeJS runtime. The documents maintained in the application need to be approved by a second person (approver) after a specific step. To provide the approver a seamless experience I see these options:

  • Integrate into the SAP S/4HANA on Premise “My Inbox” app
  • Integrate into SAP Task Center service
  • Integrate into Microsoft Outlook
  • Integrate into Microsoft Teams
  • Send a mail

The first option to integrate into the “My Inbox” app requires the implementation of a custom task provider class as nicely described by harish vyas in his post Integrating 3rd Party Workflow to Fiori My Inbox.

Update, 14th May 2021: I found another option to integrate into the “My Inbox”. You can implement a TCM (task consumption model)-compliant OData adapter as described in the blog post How to implement an OData provider for My Inbox from Lena Grothaus and the SAP Note: 2304317 – How to implement an OData provider for Task Gateway/My Inbox.

The SAP Task Center service isn’t yet available. According to the SAP TechEd 2020 session Central Workflow Inbox as a Key Intelligent Enterprise Quality [DEV112] by Georgi Mladenov and Ivan Vasev the GA is planned for Q2/2021. My question SAP Task Center – Add tasks from partner applications was answered by Ivan Mirisola. The integration is possible using the SAP Workflow Service.

While composing this post I’ve re-discovered the blog post Integrating SAP Cloud Platform Workflow with Microsoft Outlook by Harald Schubert. It describes in great detail how to leverage Adaptive Cards for SAP Workflow service approvals in Outlook.

Integration to Microsoft Teams

For the moment I give the Microsoft Teams option a try. First, I thought that building a Microsoft Teams Chatbot that can send proactive notifications to users might be the way to go. But even after I found this nice tutorial video Proactive messages in Microsoft Teams bots (JavaScript/Typescript) with its corresponding GitHub repository this way was too cumbersome.

During my research I’ve found the app Approvals in Microsoft Teams. From there the solution was just a link away: Microsoft Teams approvals with custom connectors. It seems to be possible to trigger a new approval from a Power Automate Flow and send the approval result back via a custom connector. That’s the Architecture I’ve came up with:

 

As the bookshop-demo application already is setup for API access it was quite easy to setup security using authentication type “OAuth 2.0” with Identity Provider “Generic Oauth 2”:

You find the needed Client ID and Client Secret in the credentials when you’ve followed my description in API access. The authorizationUrl and tokenUrl end up in the Swagger definition:

  "securityDefinitions": {
    "undefined": {
      "type": "oauth2",
      "flow": "accessCode",
      "authorizationUrl": "https://subaccount.authentication.eu10.hana.ondemand.com/oauth/authorize",
      "tokenUrl": "https://subaccount.authentication.eu10.hana.ondemand.com/oauth/token",
      "scopes": {}
    }
  }

For the connector I’ve defined several actions. Here you see the one for the approval. The action provides the parameters that can be filled in the flow:

After establishing the connection, I started to create this flow:

For the final result please check out this demo video:

Final thoughts

The setup was straight forward. I would think that with a combination of the blog posts from Martin Raepple it should be possible to achieve even SSO from Microsoft Teams to the CAP App. Right now, other users use the connection that I’ve established. So I will be the user stored in the change history. For this scenario I would prefer the OAuth2 Client Credentials Flow. But that is not yet supported. You can vote at Add support for OAuth2 Client Credentials auth flow in Custom Connectors Security for it.

This is the result when searching for SAP connectors:

The question that came to my mind was then: Haven’t there been announcements about a partnership between Microsoft and SAP? OK, Microsoft Teams and SAP BTP were not in the focus for the announcement: SAP partners with Microsoft for first-in-market cloud migration offerings in October 20, 2019. But in the announcement “SAP and Microsoft expand partnership and integrate Microsoft Teams across solutions January 22, 2021” it’s front and center.

On the SAP Road Map Explorer (S-User required) I can see quite a list regarding SAP Cloud for Customer. But I can’t find any other products. 3 months after the announcement I would expect more. Where is the promised integration scenarios between SAP S/4HANA and Microsoft Teams that Thomas Saueressig mentioned in the LinkedIn post Microsoft and SAP: Expanding Our Partnership? Seems we have to wait until the announcements at SAPPHIRE NOW 2021 starting 2nd June 2021.

Assigned tags

      10 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Thomas Jung
      Thomas Jung

      Really nice example of using CAP outside the usual use cases. Great inspiration for others.

      Author's profile photo Pierre Dominique
      Pierre Dominique

      I don't know why but we often seem to work on the exact same topics Gregor. 😉

      Thanks for sharing this, this is another scenario I had on my todo list so this should be very useful.

      Author's profile photo Cedric Heisel
      Cedric Heisel

      Great stuff, Gregor! This is the out-of-the-box thinking who is helping to see the opportunities in the cloud. At the end it's just REST-(wonder-) full.

      I am also having the challenge how to explain the customer why they will need 2 different inboxes on S/4 right now .. so this could be another useful approach!

      Thank you for sharing!

      Author's profile photo Mustafa Bensan
      Mustafa Bensan

      Hi Cedric,

      For your scenario, assuming that with S/4HANA you already have the Fiori My Inbox app implemented, why is there a need to develop another inbox instead of integrating the new workflow with the existing My Inbox?

      Author's profile photo Cedric Heisel
      Cedric Heisel

      Hi Mustafa,

      it is about S/4 HANA Public Cloud and there we do not have the chance to add custom made workflows within the S/4-My Inbox.

      SAP was announcing back in 2019 something called "One Inbox" or "Central Inbox" - unfortunately I do not know what the progress is about. The idea was to provide a central place for all workitems within the hole landscape.

      In my case, this resolved into 2 different "My Inbox" apps on the S/4 FLP.

      Author's profile photo Mustafa Bensan
      Mustafa Bensan

      Hi Gregor,

      A very good example of integrating multiple technologies.  If I have understand correctly, you are implementing a side-by-side extension for S/4HANA on-premise.  During workflow discussions I've had, it comes up that the best practice is to use the workflow engine of the core system (eg. S/4HANA) so that there is a single, consistent workflow hub that can be accessed by multiple channels.  Indeed, even the Microsoft Teams approvals with custom connectors reference states "You can use the approvals hub in Microsoft Teams to quickly integrate approvals workflows into existing line of business apps that do not have their own approvals system".  What are your thoughts about this?

      Also, since your extension is deployed on BTP, what about using the BTP Workflow Service?

      Author's profile photo Gregor Wolf
      Gregor Wolf
      Blog Post Author

      Hi Mustafa,

      thank you for your feedback. Have you read through the section "Context and possible options"? I've checked the option to use the S/4HANA My Inbox. But if you know about about another option then implementing the custom feeder class I'm open for ideas. Is there maybe a way to create a generic workflow with just a link to our Side-by-Side extension via an released API?

      Best regards
      Gregor

      Author's profile photo J. Graus
      J. Graus

      Hello

      You use a customer connector to connect from Power Automate to SAP. What is the benefit of using a customer connector ? As using the Power Automate HTTP connector would also be possible and prevents developing a customer connector.

      Regards Jack

      Author's profile photo Gregor Wolf
      Gregor Wolf
      Blog Post Author

      Dear Jack,

      I would hope for a connector that allows user propagation. Right only one user is used.

      Best regards
      Gregor

      Author's profile photo J. Graus
      J. Graus

      Thanks, that clarifies. We do use a similar Power Automate invoice approve scenario where we exchange invoice and invoice release by IDOC. Where the IDOC's are exchanged by HTTP and the standard Power Automate HTTP connector. In that scenario a single SAP service user is being used. So when user propagation is required a customer connector might be required.

      Regards