Skip to content
SRB Consulting Team
Technology & ABAP

SAP & external AI – is that possible?

By Niklas Kasper
Screenshot SAP Grafik AI

AI is on everyone's lips. Some time ago, we began to engage with the topic. One of the questions: What possibilities exist to use non-SAP AI alongside SAP, and how easy is it? We looked at a simple case.

AI is on everyone's lips. So it is at SRB. We started engaging with the topic both inside and outside SAP some time ago. One of the questions: What possibilities exist to use non-SAP AI alongside SAP, and how easy is it? We examined a fairly simple case – a bot for Microsoft Teams.

AI is here to support processes and workflows and simplify all our working lives, is the general consensus. So far, so good. But is this also true when combining non-SAP AI and SAP?

We wanted to put it to the test and had an idea: to provide information from SAP in MS Teams as simply as possible without logging into SAP and without knowledge of transactions and their functions. Because as we all know: The login process for SAP Cross-Application Time Sheets (CATS) on the web or in the SAP GUI can be 'cumbersome'.

Retrieving SAP information via MS Teams chatbot – how easy is that?

The aim of our small project was to investigate the capabilities of artificial intelligence (AI) in extracting structured information from SAP for unstructured queries. Or more concretely: We wanted to develop a chatbot in Microsoft Teams that enables employees to retrieve relevant information from SAP using natural language. In our example, working hours.

At the beginning, we defined 10 questions that the chatbot should answer. For example: 'What are my working hours from last month?' I found two different options during my first brief look, and I chose one:Power Virtual Agents (PVA), a low-code service offered by Microsoft. I initially discarded the other option, which was to programme the bot myself and run it on a server, although I realised that I would have had more freedom there and would not have been so restricted in terms of functionality.

In PVA, it is possible to connect a Power Automate flow via special 'cards'. Since PVA alone does not offer many options, most of the logic is implemented in Power Automate. Here, information is processed and prepared using loops and conditions.

To recognise the intentions or questions of users, an AI model is still needed. Naturally, ChatGPT immediately came to mind… but not without concerns. The central questions that arose were whether and what information would be stored and whether the recognition of different sentences would always return the same information. After careful consideration, we ultimately decided against ChatGPT for exactly those two reasons.

After careful consideration, I chose theCognitive CloudfromMicrosoft Azure.This can also be integrated via special actions in Power Automate.

To format the output and present it more attractively, Azure Functions were used. These allow code to be written in predefined programming languages and executed serverlessly. For retrieving data from the SAP system, API management and a pre-made service (CATS) are used. The data can be retrieved via an HTTP request.

Screenshot für externe KI Systeme

An AI workflow in the making

So how does it all work? Microsoft Teams is our starting point. Here, a new chat partner appears, in our case the chatbot we named 'SRBot'. To ask specific questions, one must first call up the appropriate topic. This can be done via several commands, such as 'Open SRB Time Management' or 'Retrieve times'. This starts the appropriate topic as a flow in PVA. Then, one of the 10 questions can be asked, even in a modified form.

Screenshot von externem KI Bot

The security card, visible in the lower left image, logs the user in with their Microsoft credentials. When writing to the bot for the first time, one is prompted to log in with their company email address. The login generates an auth token, in which important data about the user is encrypted. This will be important later.

The right image shows how Power Automate is called. Here, the user's question and the auth token are passed to the flow. Only the output is returned, which is then sent back to the bot as a message by PVA.

Screenshot einer Grafik, die den SAP Prozess näher beschreibt

In Power Automate, the individual steps are then merged and coordinated. On one hand, the request from PVA arrives, and on the other hand, requests are made to the Azure Cognitive Services and the SAP system.

The variables themselves are initialised inCLU Recognition.A pre-made component sends a call to the Azure Cognitive Services, and the user's question is passed on. Depending on what the component returns as a response, i.e., which intent was recognised, different follow-up flows are called.

Screenshot Externe KI Unterhaltungen

In theTimeRecordsRequestthe flow also starts with the initialisation of variables. Then the parameters, i.e., the two dates, are formatted appropriately and checked whether a period is being queried or just a single day, and then whether only a certain type of time entries, such as vacation or sick leave, is needed.

Subsequently, there is a try and catch block in which an HTTP request is made to the SAP CATS service. If the entries are empty, a pre-made message is returned. Otherwise, the result is processed and prepared for output, depending on what the user's intent was.

Screenshot SAP Grafik externe KI Reihenfolge

In theLanguage Studioa language understanding model was created, which is capable of categorising the intent of a sentence into predefined categories. For this, many example sentences are written and assigned to a self-created category. In our case, 'Retrieve Times'.

In addition, other important key features, the entities, are recognised. There are different possibilities: predefined categories that autonomously recognise the entities, machine-learned entities that can be marked in the sentences and are determined by their position, as well as regex patterns.

Screenshot einer Grafik, die den SAP Prozess näher beschreibt

Since Power Automate becomes very quickly very confusing with more complex tasks, I used Azure Functions for the output. Here, one can choose from several predefined programming languages, and the function can be accessed via an API call. The data for output is sent in the body to the URL, then processed by the function for output and sent back.

Grafik Code für externe KI

And how good are the results?

The bot was able to answer all known questions without any problems. Remaining or new questions could be implemented with relatively little effort. After all, the basic structure of the programmes and interfaces is already in place. There would also still be the possibility to get a detailed view or a summary of the hours, but this currently only happens with certain queries.

The bot takes about 10 seconds to respond. This is quite long, but considering the workflow's structure, it is still reasonable. This time is mainly due to the many blocks in Power Automate, but also due to some requests to other services. Due to the choice of PVA and Power Automate, many interfaces have arisen where time is lost. As a result, it sometimes takes longer for the bot to send a response.

All of this shows that Power Automate is actually only suitable for small logics. As soon as a bit of complexity comes into play, it becomes very quickly very confusing. Therefore, I also chose Microsoft Azure Functions for data processing. Here, one can achieve a result that is much clearer and better. The downside, however: one more interface.

Moreover, it is disheartening: with Microsoft, one must pay separately for each product. But at least one can test these for a long time for free to assess whether they fulfil their actual purpose. The prices of Microsoft Azure solutions are very confusing, and it is difficult to find the exact or best price for one's individual use case, as there are different payment methods for most, e.g., packages with certain limits or 'pay as you go'.

For the AI model, there are also only a few data available for training. Furthermore, in Language Studio, the search mainly focuses on the position of the keywords. These two points together make it somewhat difficult to recognise the right keywords or cover a wide range of intents.

All in all, it can be summarised that non-AI solutions work with SAP, but do entail a certain effort. The quality, however, is perfectly acceptable. However, looking at the speed at which AI is developing and the hype surrounding the topic, it can be assumed that this will soon become a true commodity in everyday work.