Skip to Content
Technical Articles

SAP Solution Manager ITSM Application Integration with SAP Conversational AI Chatbot

Introduction

Recent advances in artificial intelligence have seen a lot of improvements in NLP which has led us towards the acceptance of AI-infused assistants widely. Chatbots are ideally placed to help streamline engagement between consumers and brands with the express purpose of improving the customer service experience in the context of problem resolution.

We have picked a small use case which is used more often by the customers who are using ITSM application from Solution Manager. There were resources on how to integrate ITSM with chatbot , but the key difference here is with the usage of SAP CAI and XSJS application.

Below is the architecture flow of scenario,

Prerequisite

Solman : We have used a on-premise SOLMAN system where ITSM application exists .

Cloud Connector : Cloud connector is placed on-premise in order to expose the SOLMAN system to SAP cloud platform.

SCP : The XSJS application holds the logic of different queries that could be used in the conversation . The XSJS runs on the SCP.The application calls the standard ODATA service from the backend and carry out all filtering queries in the application , this way we could decouple the application layer which improves the performance.

SAP CAI : Transform user experience by building and deploying powerful conversational interfaces.Connect chatbots to any SAP solution, external communication channel, or back-end system.

Steps for Connecting Solman ITSM Application with SAP CAI

We have used a standard OData service for message result set for getting the tickets

“/sap/opu/odata/sap/AI_CRM_GW_MYMESSAGE_SRV/ MessageResultSet”

STEP 1: Create XSJS application in SCP

Created a XSJS application on SAP Cloud platform

STEP 2: Build a logic on XSJS application

For retrieving the tickets based on priority, we created a “PriorityticketsSet.xsjs” service. The filtering query is handled in the application on the complete set of ODATA result set.

var destination_package = "solman.services";
var destination_name = "Destination";
var custnum = $.request.body.asString();
var essai = custnum.toString().replace("\r", "").replace("\n", "").replace("\t", "");
essai = JSON.parse(essai);
var Prioritytickt = essai.Prioritytickt;

try {
	var dest = $.net.http.readDestination(destination_package, destination_name);
	var client = new $.net.http.Client();
	var req = new $.web.WebRequest($.net.http.GET, "MessageResultSet?$format=json"); //Entity Set 
	client.request(req, dest);
	var response = client.getResponse();

	$.response.contentType = "application/json";
	var result = response.body.asString();
	var jsonResult = JSON.parse(result);
	var chatbotResponse;

	if (jsonResult.d.results.length > 0) {

		if (Prioritytickt === "2") {
			chatbotResponse = "Here are the high priority tickets ";
		}
		if (Prioritytickt === "3") {
			chatbotResponse = "Here are the medium priority tickets ";
		}
		if (Prioritytickt === "4") {
			chatbotResponse = "Here are the low priority tickets ";
		}
		if (Prioritytickt === "All") {
			chatbotResponse = "List of all the tickets ";
		}

		if (Prioritytickt !== "All") {
			var ticketdetails = jsonResult.d.results.filter(function(hero) {
				return hero.Priority === Prioritytickt;
			});
			for (var i = 0; i < ticketdetails.length; i++) {

				chatbotResponse += ticketdetails[i].ObjectId;
				if (i < ticketdetails.length - 1) {
					chatbotResponse += ", ";
				}

			}
		} else {
			for (var i = 0; i < jsonResult.d.results.length; i++) {

				chatbotResponse += jsonResult.d.results[i].ObjectId;
				if (i < jsonResult.d.results.length - 1) {
					chatbotResponse += ", ";
				}

			}
		}

		var output = {
			replies: [{
				type: 'text',
				content: chatbotResponse
   					}],

			conversation: {
				memory: chatbotResponse
			}
		};
	} 
	var body = JSON.stringify(output);
	$.response.contentType = 'application/json';
	$.response.setBody(body);
	$.response.status = $.net.http.OK;

} catch (e) {
	$.response.contentType = "text/plain";
	$.response.setBody(e.message);
}

STEP 3: Create a chatbot with SAP Conversational AI bot building platform

The first step is to create a chatbot in SAP Conversational AI. To begin with, create an account in the platform (It’s absolutely free!).

3.a) Create Intent:

An intent is a box of expressions that mean the same thing but are constructed in different ways. Intents are the heart of your bot’s understanding. Each one of your intents represents an idea your bot is able to understand.

3.b) Entities: 

An entity is a Keyword that is extracted from an expression. We will create custom entities to extract the information we need. As with intents, training is very important: the more examples you add to your bot, the more accurate it gets.

3.c) Create a Skill (Bot Flow) :

A skill is a block of conversation that has a clear purpose and that your bot can execute to achieve a goal.

3.c.1) Triggers:

Triggers are conditions that determine that bot should execute the current skill or not. If the triggers conditions of the skill are validated, the bot will execute it over the skills.

3.c.2) Actions :

An action is something that your bot executes at a specific point when executing a skill. In our case we are going to call the Webhook call, by using the AP where we created in Step 2. 

The response of the webhook call from XSJS application is displayed to the chatbot.

 

For Skype Integration:

Step 1: Create an account in Microsoft Azure (for Skype integration)

To integrate your bot to Skype, you need to create an account in Microsoft Azure.

Step 2: Bot registration in Microsoft Azure

Step 3: Connect SAP Conversational AI and Azure with the Bot Connector

Step 4: Connect your bot to channels like Skype

By default, your chatbot is only connected to the Webchat channel in Microsoft Azure.

Demo of the application:

For Amazon Alexa Integration:

Note: Amazon Skill will be triggered by using an “invocation” key word. Using this invocation will start the bot and tell Alexa to go to SAP Conversational AI to handle the conversation. Then, we have to tell your bot how to properly react when the user uses the invocation. For that, we’ll create an intent and a skill.

For skill we will use existing greetings skill

Step 1: Create an Amazon Alexa developer account

If you already have an Amazon Alexa developer account, nothing more to do! Just log in.If not, go to https://developer.amazon.com/alexa/console/ask? and create one. It’s completely free!

Once you’ve created an account, don’t create a skill though the Amazon platform. We handle it for you through your bot’s Connect tab in SAP CAI.

Step 2: Authorize Amazon to connect to your SAP Conversational AI

Go to the Connect tab of your bot and click Amazon Alexa. Go to Step 6 (under Amazon Alexa on the Connect tab) and click LOGIN WITH AMAZON. Once you’ve done that, you won’t have to go back to this action.

Step 3: Choose an invocation name and generate your Alexa Skill

Under Amazon Alexa on the Connect tab, stay on Step 6 and choose a name for your Alexa skill. Feel free to personalize it.

Choose an invocation name, which will make Alexa switch to your SAP Conversational AI bot. Once you’ve chosen an invocation name, click the CREATE CHANNEL button and wait. The system will take a few seconds to reload and then the Vendor and Locales lists will be available.

Demo of the application

Conclusion

In this blog post,we have learnt on how to build a chatbot using SAP CAI for ITSM application and on how to integrate it with alexa and Skype.In a summary ,SAP CAI opens up the gateway for the endless opportunity of bringing the Enterprise grade Conversational AI.

Reference links:

https://cai.tools.sap/docs/concepts/

https://cai.tools.sap/blog/connect-sap-conversational-ai-chatbot-to-amazon-alexa/

https://blogs.sap.com/2019/01/03/build-your-first-bot-with-sap-conversational-ai/

https://blogs.sap.com/2018/06/11/s4sales-assistant-a-chabot-interface-for-the-sales-team-on-the-move-with-sap-ui5/

https://developer.amazon.com/alexa/

 

1 Comment
You must be Logged on to comment or reply to a post.
  • Hi Naga

     

    Thank you for this blog. I am trying to follow it.

    I am wondering about this part:

    var destination_package = "solman.services";
    var destination_name = "Destination";

     

    What is the destination_package and the destination_name? Is the destination name the one you have to set under “Destination” in the SAP Cloud Platform?

     

    What about the destination_package?

     

    Regards,

    Florence