Skip to Content
Technical Articles
Author's profile photo Eaksiri Sontisirikul

How to build SAP Conversational AI integration with SuccessFactors via SAP Cloud Platform Integration

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/161cfefadfea4fbd9912cc38317ded57.html. 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.

Assigned Tags

      10 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Paul PINARD
      Paul PINARD

      Thanks for writing this great article!

      Author's profile photo amit tiwari
      amit tiwari

      Thanks for writing this innovative blog.

      Author's profile photo Prashanth Jadagade Ramappagowda
      Prashanth Jadagade Ramappagowda

      It is really interesting. Thank you for sharing.

      Author's profile photo suresh kumar
      suresh kumar

      Its interesting Article. Thanks for Sharing

      Author's profile photo AMIT GUPTA
      AMIT GUPTA

      Hello Eaksiri,

      How does SSO works here? Can you let me know. How will you hit CPI subaccount which is behind IAS from Conversational AI?  

      Amit

      Author's profile photo Eaksiri Sontisirikul
      Eaksiri Sontisirikul
      Blog Post Author

      Hi Amit,

      For the testing purpose, I didn't set up the SSO. Instead, I used basic authentication (user/password).

      Anyway, for the real-world scenario, you can use OAuth2 authentication between SAP CAI and SCPI.

      Author's profile photo Vinit Waghmare
      Vinit Waghmare

      Thank you for sharing. It is really fascinating.

      Author's profile photo Loren Newman
      Loren Newman

      Really good document but a lot of steps not shown in blog. Do you perhaps have a step by step guide for each process?

      Author's profile photo Yasser SABER
      Yasser SABER

      Great as usual,

      is there away to communicate directly between the CAI and SF without SAP Cloud Integration part?

      Author's profile photo Vianey Vargas
      Vianey Vargas

      Hello Eaksiri,

      I have one question.. when trying to map the response into the API_Response, I am assuming you imported a xsd file into the iFlow with that name and one element? it is just that I tried that method with a file named API_Response.xsd with the following structure:

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
          <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>
          <xs:element name="API_Response">
          </xs:element>
      </xs:schema>

      But cannot map multiple values into same element:

      And following.. when I try to create the content modifier I cannot input Default value and have another column indicating to put in Source value:

      I must be doing something wrong.. could you guide me please? 🙂