Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
eaksiri
Explorer

Introduction


AI Chatbot is one of the most popular topics we are talking about nowadays. I think it’s because we tend to use fewer people to do jobs and use more machines.

SAP has just released a new product called SAP Conversational AI, so I just want to play around with it.

This blog is written based on what I have learned through the journey. And I intend to do everything with zero codings. So not only developers will understand it, but also integration consultants or functional consultants can benefit it too.

 

Assumptions


You should have basic knowledge of SAP Conversational AI and SAP Cloud Integration.

There’s a lot of people who have written very good blogs explaining those kinds of stuff in this community. You can check it out!

 

Table of Contents



  • The purpose of the bot

  • Process flows

  • Part: SAP Cloud Integration

    • Integration flow: Employee Information

    • Integration flow: Employee Phone Information



  • Part: SAP Conversational AI

    • Create a new bot

    • Intent: Basic employee information

    • Intent: Phone number

    • Let's build a bot

    • Test your bot



  • Conclusion


 

The purpose of the bot


We are going to build a bot to respond to 2 types of questions.

  • Basic employee information (for example, first name, last name, current position, and working location)

  • Employee’s phone number


 

Process flows





  • A user asks about an employee information

  • SAP CAI selects the intent @ASK-employeeinfo based on the above context

  • The integration flow Employee Information on SAP CPI is triggered via the webhook

  • The SuccessFactors OData EmpJob is then called to return the employee information in the XML format

  • SAP CPI converts it into the JSON format and sends it back to SAP CAI

  • After that, a user asks about his/her phone number

  • SAP CAI selects the intent @ASK-phone based on the above context

  • The integration flow Employee Phone Information on SAP CPI is triggered via the webhook

  • The SuccessFactors OData PerPhone is then called to return the employee information in the XML format

  • SAP CPI converts it into the JSON format and sends it back to SAP CAI


 

Part: SAP Cloud Integration


The integration flows Employee Information and Employee Phone Information will be built to serve the requirements.

 

Integration flow: Employee Information


 
Overview


 
Configurations

Set the allowed header for employeeid.


 

Set the called address to /empinfo.


 

Configure a SuccessFactors OData connection to retrieve employee information from the entity EmpJob. Also, we set the dynamic parameter ${header.employeeid} from the above step.


 

Then you can choose whatever information you want to send back to SAP CAI. In the below example, I choose “First name”, “Last name”, “Position name”, and “Working location”.

Note: if preferred, you can use a Groovy script to do it.


 

Set the output from the above step to the message header API_Response.


 

Construct the target output for SAP CAI. We put the output text in the field content.


 

Alright, your integration flow is ready to be deployed.


 

Integration flow: Employee Phone Information


 
Overview


 
Configurations

The steps are more or less the same as the integration flow Employee Information. So you can refer to the explanations in that flow.

The following captured screenshots are for references.

 








 

Part: SAP Conversational AI


 

Create a new BOT


Click on a new BOT.


 

Select Perform Actions with no predefined skills.


 

Name your bot. Mine is sf-employee-information.


 

Regarding the data policy, select Type of data as Non-personal and End users as Non-vulnerable.


 

Choose your bot visibility as you wish. And then it’s ready to create a bot.


 

Here we go. After creating, your bot is ready to be configured.


 

Intent: Basic employee information


Now, let create the first one to respond to the employee information. Click CREATE.


 

We will create the intent called ask-employeeinfo. Put the description of what you intend to do.


 

The newly created intent is @ASK-employeeinfo.


 

Next, we will create a custom entity (basically it’s a keyword to determine the intent).

Please note that SAP has provided many predefined entities (so-called gold entities) such as #location, #datetime, #number, etc. The list of gold entities can be found on https://help.sap.com/viewer/a4522a393d2b4643812b7caadfe90c18/latest/en-US/161cfefadfea4fbd9912cc3831.... These keywords are ready to be used on your bot.

To create a new custom entity, switch to the tab Entities. And then click on CREATE AN ENTITY.


 

We name the entity employee-id as Free entity.

The aim is to detect the keywords, such as “employee ID” or “ID”, as the entity #employee-id. And then let its machine learning to automatically extract the actual employee ID to the entity #number.


 

Let’s go back to the intent @ASK-employeeinfo. Now we are going to add the expressions (expected conversions that we will get).


 

You can add as many expressions as you like.


 

After that, we highlight the keyword “employee id” to match with the entity #EMPLOYEE-ID


 

Do it for all of your expressions.


 

You can perform testing if the correct intent is executed based on the sentence you type.

On the right-hand side, click on the TEST menu. The testing window will be expanded.

Then you can try to put some sentences in there. If it’s correct, it should detect the keyword “employee id” as the entity #EMPLOYEE-ID and the ID will automatically be extracted as #NUMBER.


 

Intent: Phone number


Create an intent called ask-phone.


 

We are supposing to be inquired with a phone number. So let put the expected questions, as expressions, that we may get.


 

Please note that there’s no need to create additional custom as we don’t want to extract any value from the context.

Anyway, it’s a good idea to perform testing every time you create a new intent. So you can make sure that the right intent is picked up.


 

Let’s build a robot!


On the Build tab, create a new skill called respond.

Note: technically, both skill types—BUSINESS & FLOATING—have the same behavior. You can select either one of them that suits you the most.


 

Click on the newly created skill respond.


 

There are 2 conditions that the skill will be triggered.

  • The intent @ASK-employeeinfo is found

  • The intent @ASK-phone is found



 

We should also check if there’s enough information prior to executing the action. Therefore the value of either employee ID or location should exist.

On the right-hand side in the black block, this is the data structure that the system keeps its data.

For example, if you want to get the employee ID, then you can get it from this variable {{memory.employeeid.raw}}.


 

You can also put a reply in case that the required information is not met.


In the tab Actions, the webhook will be configured to trigger the integration flow that we developed in the earlier step

The first one is for the intent @ASK-employeeinfo. If found, then let trigger the integration flow Employee Information.


 

Another one is for the intent @ASK-phone. If found, then let trigger the integration flow Employee Phone Information.


 

Finally, we should reset the conversation after the phone has been asked. The memory that is contained with the employee id will be wiped out.

Why? Because it’s just in case that a user asks for a phone number before the specific employee is inquired. The error message will be issued out.



 

Test your bot


On the bottom-right, click on CHAT WITH YOUR BOT.

You can inquire with the employee information first. And then ask for a phone number.


 

You can also try to ask for a phone number first. The error message will be popped up.


 

Conclusion


I know that the above solution is far from perfect and there’s a lot of room for improvement. For example, the error handling should be covered in case there’s no employee ID found or shorten some configuration steps by putting some coding. As well, the developed chatbot can be integrated with other messaging platforms.

Anyway, I hope that this blog is a good starting point though.
10 Comments
Labels in this area