Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 
Product and Topic Expert
Product and Topic Expert
This blog post is part of a series of technical enablement sessions on SAP BTP for Industries. Check the full calendar here to watch the recordings of past sessions and register for the upcoming ones! The replay of this session available here.

Authors:, amagnani, edward.neveux, jacobtan

Disclaimer: SAP notes that posts about potential uses of generative AI and large language models are merely the individual poster's ideas and opinions, and do not represent SAP's official position or future development roadmap. SAP has no legal obligation or other commitment to pursue any course of business, or develop or release any functionality, mentioned in any post or related content on this website.


Large Language Models (LLMs) like ChatGPT and GPT-4 have gained significant popularity with emergent capabilities. In this fourth session of the series, we’ll explore the potentials of GPT in SAP ecosystem. In this series, we will discuss how SAP partners can leverage this powerful AI technology in combination with SAP technologies to accelerate their solution development processes, and create more intelligent solutions on SAP Business Technology Platform (SAP BTP).

Here list the full blog post series of Exploring the potential of GPT in SAP ecosystem:

Exploring the potential of GPT in SAP ecosystem

Part 1 – GPT in SAP ecosystem

Part 2 – GPT as code assistance for SAP CAP and RAP Application development

Part 3 – Prompt Engineering for Advanced Text Processing on Customer Messages

Part 4 – Integrate with GPT Chat API for Advanced Text Processing

Part 5 – Integrate with GPT Embedding API for Customer Message Classification (this blog post)

In this blog post (the last of the series), we will cover is how to implement message intent classification in our intelligent ticketing solution. We will achieve it by using the GPT embedding API.

Customer message classification with GPT embeddings

As we have discussed in previous blog post about GPT in SAP ecosystem, text embeddings allow to represent words or sentences in vectorial form, and to introduce a concept of distance between the meaning of sentences. We will use distance to classify incoming customer messages into a few predefined categories, as in the example below.

The first step to achieve this is understanding how to use the GPT embedding API. The video below shows how to get the embedding for one of the message categories we have chosen. It’s necessary to submit a title and brief description in the payload that we post to the dedicated API, and we will get the embedding array as a response.

Below, you can see how to do the same with NodeJS code. As we have seen earlier with the chat completion API, there are different ways we can implement the API call. Here we show three options, with direct HTTP call, Azure OpenAI Node module, or LangChain.The NodeJS sample code of GPT Embedding API available here.

Option 1: direct HTTP call with axios node module

Option 2: azure-openai node module

Option 3: LangChain.js

To finalize our message classification, we need to get the embedding for every message category and store them in the HANA DB underlying the CAP application.Then, we need to add a piece of code in the application to extract the embedding for every incoming customer message and compare it with the categories’ embedding to find the closest one. Here below is our implementation. Notice that to evaluate the distance between embeddings we have used a metric called cosine similarity, with is widely used for similar tasks in the natural language processing domain.

Further resources

Wrap up

We have seen that embedding can be helpful with customer message classification in our sample among many use cases, such as text searching, answering question with custom knowledge base, clustering, anomaly detection, recommendation etc. Here conclude our blog post series of exploring the potential of GPT in SAP ecosystem, which is just the fourth of our SAP BTP technical enablement sessions for industry. We hope you have enjoyed the reading.

Check the full calendar, register to the upcoming sessions and review the already recorded sessions here!