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: 
toushif
Participant
2,376

Introduction:


SAP Conversational AI is an end-to-end chatbot platform combined with a digital assistant designed  for the enterprise. Train, build, connect and monitor intelligent chatbots in one unique interface to automate tasks and workflows.

Using SAP Conversational AI, you can integrate chatbots into one unique interface – the Digital Assistant. Instead of having to use disparate, solution-based chatbots, employees get a simpler experience. Employees can create a leave request, check LOA approval status, enter a new lead, or check the travel expense policy etc. at the same place.

In this blog post, the main aim is to help design a simple chatbot using SAP CAI that can be used to check leave of absence approval status from SuccessFactors and display the output result into mobile devices by integrating the bot to Telegram app.

Design/Development Steps: 


To start designing the solution, some basic knowledge of SAP Conversational AI is required along with SAP Cloud Platform Integrations. Let's break the design part into three simpler steps called:

  1. SAP Cloud Platform Integration Development

  2. Building SAP CAI Bot and Training

  3. Integrating the bot to Telegram app


Step 1. SAP Cloud Platform Integration Development:


This particular section describes the development steps involved to retrieve Employee Time Off data from SuccessFactors using a API call and formatting the API response into JSON format to make it an acceptable input structure for the bot.


  • Integration flow: Overview:








  • Integration flow: Configurations:




The iflow needs to be configured to accept input as employeeId as we are going to retrieve employee time off data per employee. To achieve that, please navigate to Runtime Configuration of the interface and set the allowed headed field as 'employeeId'. Choose HTTP Session Reuse as 'On Integration Flow'.


Configure sender Adapter 'HTTPS' like:

Set the Address to be called as '/employeeTimeInfo/*' like this:


Next. call the API 'EmployeeTime' to fetch employee time off data by filtering with the 'employeeId' like:


The next step, Log API response script will create an attachment log after every message processing or the execution of the iflow.

Now, write the API response in a content modifier step for further use inside the iflow:


In next step, the groovy script formats the raw API response to an acceptable structure for the bot and sets the formatted data to a header and that formatted data again used to prepare JSON input like this:

Code Snippet to format the data:


Groovy Code Snippet to format the data



Now deploy the iflow to generate an endpoint like this :



Step 2. Building SAP CAI Bot and Training:




  • Login to the SAP CAI account and create your chatbot.





Please follow these steps to create your bot:




  1. Click on  “+New bot”.

  2. Select Perform Actions tile with no predefined skills.

  3. Enter a name for your bot something like hrbot.

  4. Choose “Type of data” as Non-personal and “End users” as Non-vulnerable.

  5. You can select the visibility of bot of your choice.


Now, your bot is created and ready to be configured.


  • Create Intent: 




Now, let's create intent for the hrbot and to do that please navigate to Intents tab under Train and click on "+CREATE". Please input a name for the intent and a description. Find below the created intent for the bot:





  • Create Entity:




Now, let's create an entity and to do that click on "+CREATE" in Entities tab under Train and name the entity as employee and choose the entity to be a Free entity because we want machine learning algorithm to detect all the possible values such as "employee", "employee ID" or "ID" to help detect the actual employee id to the entity #number.

P.S: SAP Conversational AI provides many predefined entities (gold entities) such as #location#datetime#number, etc. These keywords are already there to be used by the bot.


Now, We will go back to the intent @ASK-loastatus to add some expressions.


  • Add Expressions:




Please add expression as much you can to the intent, relevant to the entity and SAP CAI recommends adding at least 50 expressions to improve the datasets for proper training of the bot.


Now, we will highlight the keyword "employee", "Id" and "employee id" to match with the entity #EMPLOYEE and do this all the expressions like this:


You can test if the correct intent is being executed based on the sentence you type.

On the right-hand side, click on the TEST console. A pop up window will open for testing.

Type some sentences there. If it’s correct, it should detect the keyword "employee", "Id" and "employee id" as the entity #EMPLOYEE and the ID will automatically be extracted as #NUMBER.





  • Add Skill to Chatbot:




On the build tab, create a new skill called 'fetchloastatus'.


You can either choose skill type as Business or Floating because the technical purpose of both these skill type is same.

Now, click on the created skill add a firing condition of the skill means add a condition for which you want this skill to respond. To do that, go to the Triggers tab as shown add the condition:


Please have a look for other enough additional information prior to executing the action. Therefore, the value of employee ID should exist.

Now, go the Requirements tab, to add the requirement. On the right side, a box with code snippet will appear that shows the data structure.


You can get the employee ID from this variable {{memory.employeeId.raw}}.

You can also add a reply in case the required information is not received while asking the information from bot.


Now, configure the webhook to call the integration flow developed before to fetch the LOA approval status. If all requirements are met, then the iflow will get triggered.


Add the iflow endpoint and choose authentication as basic authentication(for testing purpose). You may use any other authentication mechanism available.


Finally, we should reset the memory after every call. To do that,


 

Step 3. Integrating the bot to Telegram app: 


Now, go to connect tab and on Users channels, select Telegram.

Then, if you have telegram account on your phone search for BotFather on your app otherwise create an account and search.


Then, ask the BotFather to create new bot.


Next, Ask BotFather for the token using following command.


Now, Paste your token and click CONNECT to create the channel and chat with your bot directly on your Mobile:


Reply on Mobile:


 

Conclusion:


Thanks for checking out this blog. This solution design is a prototype to do lot more with the SAP CAI chatbot and there are lots of improvement scope in this design. Please let me know your views in the comment section. 🙂

 
9 Comments
Paul_P
Product and Topic Expert
Product and Topic Expert
Thanks for the great blog, very informative!
toushif
Participant
0 Kudos
Thanks Paul
xavierlegarrec
Product and Topic Expert
Product and Topic Expert
Great post, I didn't know this was possible ! would we be able to access anything built with MDF objects in SuccessFactors ?
toushif
Participant
Thanks Xavier, yes we can access anything built with MDF objects.
NabarunKundu
Explorer
0 Kudos
It's a great blog Toushif. I found it very informative. Keep up the good work. 👍
toushif
Participant
0 Kudos
Thank you 🙂
s_balu
Explorer
Really great, we can use it for multiple scenarios in similar way. Thank you for the post.
toushif
Participant
0 Kudos

Thank you 🙂

udayreddy147
Explorer
0 Kudos

Hello toushif , Thank you for the really good blog, In my case i just want to get the data from SF and want to view on chat bot but not getting a valid response

 

Regards,

Uday.

Labels in this area