Once you have accessed the generative AI hub and deployed your orchestration service, you’re ready to solve concrete business problems using the generative AI hub. A key skill for this interaction is developing prompts, which involves creating clear and effective instructions for an LLM.
This lesson will guide you through an iterative process of developing a basic prompt within SAP AI Launchpad to address a business challenge. We will focus on utilizing the system and user roles to provide clear instructions and context, ultimately producing structured, machine-readable output. By the end of this lesson, you will be able to construct and refine prompts that yield precise, actionable results, ready for integration into your enterprise applications.
Identifying the Business Scenario
Facility Management
Our focus for this learning journey is a Facility Solutions Company, a premier provider of comprehensive facility management, maintenance, and cleaning services for both residential and commercial properties. Their mission is to ensure environments remain safe, efficient, and impeccably maintained. Their target markets include luxury residential complexes, apartments, individual homes, office buildings, retail spaces, industrial facilities, and educational institutions.
The Business Problem:
The Facility Solutions company receives thousands of emails daily from customers regarding requests, complaints, and other inquiries. They maintain internal applications to address these customer communications, requiring efficient processing and prioritization to ensure timely and accurate responses.
However, categorizing these emails currently involves a manual process: transferring data from emails to internal applications, then manually categorizing and prioritizing each task. This process is time-consuming, error-prone, and creates bottlenecks in customer service.
The company is now turning to SAP’s generative AI hub to automate and streamline this critical process. Throughout this learning journey, we will provide step-wise solutions to this problem.
Developing Prompts in SAP AI Launchpad
Developing a prompt to solve a business problem is an iterative ideation process. You start with a basic idea, test it, observe the LLM’s response, and then refine your instructions until the output meets your specific business needs.
The best practice in modern prompt engineering is the use of distinct conversational roles: system and user. These roles provide clarity to the LLM about the nature of each piece of text it receives:
- The system role is used to set the overarching rules, persona, and constraints for the LLM. It defines who the LLM is, how it should behave, and what general guidelines it must follow throughout the interaction.
- The user role provides the specific query or input for that particular turn. This is where you put the dynamic content that the LLM needs to process.
Let’s begin developing a prompt to extract urgency and sentiment from an incoming customer email. You can start with any model like Gemini models or an open source LLM, like Mistral AI, accessible via the generative AI hub. Open-source LLMs offer advantages like cost reduction, transparency, and customization, making them excellent choices for development.
Step 1: Develop a Basic Prompt for Urgency and Sentiment
We’ll start by asking the LLM to simply extract urgency and sentiment. At this stage, we’re not imposing strict formatting or value constraints.
Prompt Structure:
123456789101112131415161718192021222324252627282930[
{
"role": "system",
"content": "You are a helpful assistant. Your task is to analyze customer messages. Extract the urgency and sentiment from the provided message."
},
{
"role": "user"
"content": " Analyze the following message:
---
Subject: Urgent HVAC System Repair Needed
Dear Support Team,
I hope this message finds you well. My name is [Sender], and I am reaching out to you from [Residential Complex Name], where I have been residing for the past few years. I have always appreciated the meticulous care and attention your team provides in maintaining our facilities.
However, I am currently facing a pressing issue with the HVAC system in my apartment. Over the past few days, the system has been malfunctioning, resulting in inconsistent temperatures and, at times, complete shutdowns. Given the current weather conditions, this has become quite unbearable and is affecting my daily routine significantly.
I have attempted to troubleshoot the problem by resetting the system and checking the thermostat settings, but these efforts have not yielded any improvement. The situation seems to be beyond my control and requires professional intervention.
I kindly request that a repair team be dispatched immediately to address this urgent issue. The urgency of the matter cannot be overstated, as it is impacting not only my comfort but also my ability to carry out daily activities effectively.
Thank you for your prompt attention to this matter. I look forward to your swift response and resolution.
Best regards,
[Sender]
---
"
}
]
When you execute this prompt in SAP AI Launchpad, you may receive a lengthy, conversational response. For instance: "The urgency of this message is high. The sentiment conveyed is negative, as the customer is experiencing significant discomfort due to a malfunctioning HVAC system."
While the LLM correctly identified the urgency and sentiment, this verbose output is not directly useful for an application that needs to automatically process these values. We need to refine the prompt to produce more structured data.
Step 2: Assign Predefined Values to Urgency and Sentiment
The previous response was too lengthy. Our objective is to assign specific urgency and sentiment values that can be used as input for an internal application. This step constrains the LLM to use only predefined labels.
Prompt Structure:
123456789101112131415161718192021222324252627282930[
{
"role": "system",
"content": "You are an expert customer service analyst. Your task is to analyze customer messages and extract urgency and sentiment. For 'urgency', classify the message as one of: `low`, `medium`, `high`. For 'sentiment', classify the message as one of: `positive`, `neutral`, `negative`."
},
{
"role": "user",
"content": "Analyze the following message:
---
Subject: Urgent HVAC System Repair Needed
Dear Support Team,
I hope this message finds you well. My name is [Sender], and I am reaching out to you from [Residential Complex Name], where I have been residing for the past few years. I have always appreciated the meticulous care and attention your team provides in maintaining our facilities.
However, I am currently facing a pressing issue with the HVAC system in my apartment. Over the past few days, the system has been malfunctioning, resulting in inconsistent temperatures and, at times, complete shutdowns. Given the current weather conditions, this has become quite unbearable and is affecting my daily routine significantly.
I have attempted to troubleshoot the problem by resetting the system and checking the thermostat settings, but these efforts have not yielded any improvement. The situation seems to be beyond my control and requires professional intervention.
I kindly request that a repair team be dispatched immediately to address this urgent issue. The urgency of the matter cannot be overstated, as it is impacting not only my comfort but also my ability to carry out daily activities effectively.
Thank you for your prompt attention to this matter. I look forward to your swift response and resolution.
Best regards,
[Sender]
---
"
}
]
Now, the LLM’s response will be more constrained, perhaps "Urgency: high, Sentiment: negative." This is better, but still requires parsing from a natural language string.
Step 3: Generate JSON Output for Urgency and Sentiment
To make the output machine-readable and directly consumable by your internal applications, we will instruct the LLM to provide its response in JSON format. JSON offers a simple, language-independent, and lightweight solution for efficient data exchange, widely adopted in APIs and web services.
Prompt Structure:
1234567891011121314151617181920212223242526272829303132[
{
"role": "system",
"content": "You are an expert customer service analyst. Your task is to analyze customer messages and extract specific attributes. For 'urgency', classify the message as one of: `low`, `medium`, `high`. For 'sentiment', classify the message as one of: `positive`, `neutral`, `negative`.
Your response MUST be a valid JSON string containing ONLY the keys 'urgency' and 'sentiment'."
},
{
"role": "user",
"content": "Analyze the following message:
---
Subject: Urgent HVAC System Repair Needed
Dear Support Team,
I hope this message finds you well. My name is [Sender], and I am reaching out to you from [Residential Complex Name], where I have been residing for the past few years. I have always appreciated the meticulous care and attention your team provides in maintaining our facilities.
However, I am currently facing a pressing issue with the HVAC system in my apartment. Over the past few days, the system has been malfunctioning, resulting in inconsistent temperatures and, at times, complete shutdowns. Given the current weather conditions, this has become quite unbearable and is affecting my daily routine significantly.
I have attempted to troubleshoot the problem by resetting the system and checking the thermostat settings, but these efforts have not yielded any improvement. The situation seems to be beyond my control and requires professional intervention.
I kindly request that a repair team be dispatched immediately to address this urgent issue. The urgency of the matter cannot be overstated, as it is impacting not only my comfort but also my ability to carry out daily activities effectively.
Thank you for your prompt attention to this matter. I look forward to your swift response and resolution.
Best regards,
[Sender]
---
"
}
]
This prompt will yield a JSON output like: {"urgency": "high", "sentiment": "neutral"}. This is a significant improvement!
Step 4: Ensure Correct JSON Formatting
Even with instructions for JSON, LLMs can sometimes include extraneous characters like markdown code blocks (json ... ) or extra white space, which can break automated parsing. This step adds explicit instructions to ensure a clean, parseable JSON string.
Prompt Structure:
1234567891011121314151617181920212223242526272829303132[
{
"role": "system",
"content": "You are an expert customer service analyst. Your task is to analyze customer messages and extract specific attributes. For 'urgency', classify the message as one of: `low`, `medium`, `high`. For 'sentiment', classify the message as one of: `positive`, `neutral`, `negative`.
Your complete response MUST be a valid JSON string, ready to be parsed by an application. It should contain ONLY the keys 'urgency' and 'sentiment'. Do not include any other text, explanations, or formatting like markdown code blocks (e.g., ```json). Ensure there are no newlines or unnecessary whitespaces outside the JSON structure."
},
{
"role": "user",
"content": "Analyze the following message:
---
Subject: Urgent HVAC System Repair Needed
Dear Support Team,
I hope this message finds you well. My name is [Sender], and I am reaching out to you from [Residential Complex Name], where I have been residing for the past few years. I have always appreciated the meticulous care and attention your team provides in maintaining our facilities.
However, I am currently facing a pressing issue with the HVAC system in my apartment. Over the past few days, the system has been malfunctioning, resulting in inconsistent temperatures and, at times, complete shutdowns. Given the current weather conditions, this has become quite unbearable and is affecting my daily routine significantly.
I have attempted to troubleshoot the problem by resetting the system and checking the thermostat settings, but these efforts have not yielded any improvement. The situation seems to be beyond my control and requires professional intervention.
I kindly request that a repair team be dispatched immediately to address this urgent issue. The urgency of the matter cannot be overstated, as it is impacting not only my comfort but also my ability to carry out daily activities effectively.
Thank you for your prompt attention to this matter. I look forward to your swift response and resolution.
Best regards,
[Sender]
---
"
}
]

As illustrated in the screenshot, this prompt gives clear instructions to provide a clean JSON format without any quotes or extra white spaces, making it robust for software consumption.
Step 5: Simple Categories Based on Business Functions
Beyond urgency and sentiment, we also need to categorize messages for business needs. Initially, we’ll ask the LLM to simply assign relevant categories without providing a predefined list.
Prompt Structure:
123456789101112131415161718192021222324252627282930[
{
"role": "system",
"content": "You are an expert customer service analyst. Your task is to analyze customer messages and assign a list of matching support categories to the message."
},
{
"role": "user",
"content": "Analyze the following message:
---
Subject: Urgent HVAC System Repair Needed
Dear Support Team,
I hope this message finds you well. My name is [Sender], and I am reaching out to you from [Residential Complex Name], where I have been residing for the past few years. I have always appreciated the meticulous care and attention your team provides in maintaining our facilities.
However, I am currently facing a pressing issue with the HVAC system in my apartment. Over the past few days, the system has been malfunctioning, resulting in inconsistent temperatures and, at times, complete shutdowns. Given the current weather conditions, this has become quite unbearable and is affecting my daily routine significantly.
I have attempted to troubleshoot the problem by resetting the system and checking the thermostat settings, but these efforts have not yielded any improvement. The situation seems to be beyond my control and requires professional intervention.
I kindly request that a repair team be dispatched immediately to address this urgent issue. The urgency of the matter cannot be overstated, as it is impacting not only my comfort but also my ability to carry out daily activities effectively.
Thank you for your prompt attention to this matter. I look forward to your swift response and resolution.
Best regards,
[Sender]
---
"
}
]

Now, the LLM will assign categories. However, these categories might be free-form, potentially overlapping with other values like urgency, and not aligned with predefined internal categories.
Step 6: Assigning Values to Categories from a Predefined List
To ensure consistency and alignment with the company’s internal processing, we need the LLM to select categories from a specific, predefined list. Aligning the output to business needs is a key step in addressing a business problem effectively.
Prompt Structure:
12345678910111213141516171819202122232425262728293031[
{
"role": "system",
"content": "You are an expert customer service analyst. Your task is to analyze customer messages and assign a list of the best matching support category tags from the following predefined list:
`facility_management_issues`, `cleaning_services_scheduling`, `general_inquiries`, `specialized_cleaning_services`, `routine_maintenance_requests`, `emergency_repair_services`, `sustainability_and_environmental_practices`, `training_and_support_requests`, `quality_and_safety_concerns`, `customer_feedback_and_complaints`."
},
{
"role": "user",
"content": "Analyze the following message:
---
Subject: Urgent HVAC System Repair Needed
Dear Support Team,
I hope this message finds you well. My name is [Sender], and I am reaching out to you from [Residential Complex Name], where I have been residing for the past few years. I have always appreciated the meticulous care and attention your team provides in maintaining our facilities.
However, I am currently facing a pressing issue with the HVAC system in my apartment. Over the past few days, the system has been malfunctioning, resulting in inconsistent temperatures and, at times, complete shutdowns. Given the current weather conditions, this has become quite unbearable and is affecting my daily routine significantly.
I have attempted to troubleshoot the problem by resetting the system and checking the thermostat settings, but these efforts have not yielded any improvement. The situation seems to be beyond my control and requires professional intervention.
I kindly request that a repair team be dispatched immediately to address this urgent issue. The urgency of the matter cannot be overstated, as it is impacting not only my comfort but also my ability to carry out daily activities effectively.
Thank you for your prompt attention to this matter. I look forward to your swift response and resolution.
Best regards,
[Sender]
---
"
}
]

As shown in the screenshot, in the version 6, the LLM will now assign categories strictly from the provided list, which are streamlined for business processing.
Step 7: Generate JSON Output for Categories Values
Similar to Step 3, we need the category values in a JSON output for programmatic processing. We will also reiterate the importance of clean JSON formatting.
Prompt Structure:
123456789101112131415161718192021222324252627282930313233[
{
"role": "system",
"content": "You are an expert customer service analyst. Your task is to analyze customer messages and extract specific attributes. For 'categories', assign a list of the best matching support tags from the following predefined list:
`facility_management_issues`, `cleaning_services_scheduling`, `general_inquiries`, `specialized_cleaning_services`, `routine_maintenance_requests`, `emergency_repair_services`, `sustainability_and_environmental_practices`, `training_and_support_requests`, `quality_and_safety_concerns`, `customer_feedback_and_complaints`.
Your complete response MUST be a valid JSON string, ready to be parsed by an application. It should contain ONLY the key 'categories'. Do not include any other text, explanations, or formatting like markdown code blocks. Ensure there are no newlines or unnecessary whitespaces outside the JSON structure."
},
{
"role": "user",
"content": "Analyze the following message:
---
Subject: Urgent HVAC System Repair Needed
Dear Support Team,
I hope this message finds you well. My name is [Sender], and I am reaching out to you from [Residential Complex Name], where I have been residing for the past few years. I have always appreciated the meticulous care and attention your team provides in maintaining our facilities.
However, I am currently facing a pressing issue with the HVAC system in my apartment. Over the past few days, the system has been malfunctioning, resulting in inconsistent temperatures and, at times, complete shutdowns. Given the current weather conditions, this has become quite unbearable and is affecting my daily routine significantly.
I have attempted to troubleshoot the problem by resetting the system and checking the thermostat settings, but these efforts have not yielded any improvement. The situation seems to be beyond my control and requires professional intervention.
I kindly request that a repair team be dispatched immediately to address this urgent issue. The urgency of the matter cannot be overstated, as it is impacting not only my comfort but also my ability to carry out daily activities effectively.
Thank you for your prompt attention to this matter. I look forward to your swift response and resolution.
Best regards,
[Sender]
---
"
}
]

As shown in the screenshot, the LLM will provide the categories within a clean JSON output, ready for software consumption.
Step 8: Combining All the Steps for a Consolidated Prompt
We have taken a step-by-step approach to arrive at proper values for urgency, sentiment, and categories in JSON format. Now, we consolidate all these instructions into a single, robust prompt. This combined prompt will serve as the final version for our automated email categorization system.
Prompt Structure:
12345678910111213141516171819202122232425262728293031323334353637[
{
"role": "system",
"content": "You are an expert customer service analyst for a facility management company. Your task is to analyze incoming customer messages and extract specific attributes for automated processing.
For 'urgency', classify the message as one of: `low`, `medium`, `high`.
For 'sentiment', classify the message as one of: `positive`, `neutral`, `negative`.
For 'categories', assign a list of the best matching support tags from the following predefined list:
`facility_management_issues`, `cleaning_services_scheduling`, `general_inquiries`, `specialized_cleaning_services`, `routine_maintenance_requests`, `emergency_repair_services`, `sustainability_and_environmental_practices`, `training_and_support_requests`, `quality_and_safety_concerns`, `customer_feedback_and_complaints`.
Your complete response MUST be a valid JSON string, ready to be parsed by an application. It should contain ONLY the keys 'urgency', 'sentiment', and 'categories'. Do not include any other text, explanations, or formatting like markdown code blocks (e.g., ```json). Ensure there are no newlines or unnecessary whitespaces outside the JSON structure."
},
{
"role": "user",
"content": "Analyze the following customer message:
---
Subject: Urgent HVAC System Repair Needed
Dear Support Team,
I hope this message finds you well. My name is [Sender], and I am reaching out to you from [Residential Complex Name], where I have been residing for the past few years. I have always appreciated the meticulous care and attention your team provides in maintaining our facilities.
However, I am currently facing a pressing issue with the HVAC system in my apartment. Over the past few days, the system has been malfunctioning, resulting in inconsistent temperatures and, at times, complete shutdowns. Given the current weather conditions, this has become quite unbearable and is affecting my daily routine significantly.
I have attempted to troubleshoot the problem by resetting the system and checking the thermostat settings, but these efforts have not yielded any improvement. The situation seems to be beyond my control and requires professional intervention.
I kindly request that a repair team be dispatched immediately to address this urgent issue. The urgency of the matter cannot be overstated, as it is impacting not only my comfort but also my ability to carry out daily activities effectively.
Thank you for your prompt attention to this matter. I look forward to your swift response and resolution.
Best regards,
[Sender]
---
"
}
]

As illustrated in the screenshot, this consolidated prompt delivers the output as a clean JSON, for example:
1{"urgency": "high", "sentiment": "negative", "categories": ["emergency_repair_services", "routine_maintenance_requests", "facility_management_issues"]}This output now consistently assigns urgency, sentiment, and categories to customer messages in a format that is immediately processable by software, fulfilling the business requirement. You have successfully developed a prompt that moves towards a solution to the problem.