public Map<String, String> processPrompt(String prompt) {
        Map<String, String> result = new HashMap<>();
        
        // Check content safety
        String safetyResult = ContentSafetyUtil.checkContentIsSafe(prompt);
        result.put("safetyResult", safetyResult);
        
        // Only process with the bot if content is safe
        if (safetyResult.contains("RESULT: Content is safe.")) {
            try {
                String botResponse = bot.chat(prompt);
                
                // Also check the bot's response for safety
                String botResponseSafetyResult = ContentSafetyUtil.checkContentIsSafe(botResponse);
                result.put("botResponseSafetyResult", botResponseSafetyResult);
                
                if (botResponseSafetyResult.contains("RESULT: Content is safe.")) {
                    result.put("botResponse", botResponse);
                    result.put("isSafe", "true");
                } else {
                    result.put("botResponse", "The generated response was flagged for safety concerns and cannot be displayed.");
                    result.put("isSafe", "false");
                }
            } catch (Exception e) {
                result.put("error", "Error processing prompt: " + e.getMessage());
                result.put("isSafe", "true"); // Content was safe, but processing failed
            }
        } else {
            result.put("isSafe", "false");
        }
        
        return result;
    }
Process a user prompt through content safety check and bot

@param prompt The user's prompt
@return A map containing the safety check result and bot response (if safe)
04-PracticalImplementation/samples/java/containerapp/src/main/java/com/microsoft/cognitiveservices/service/ContentSafetyService.java