Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 
In my previous blog post I wrote about some tips around SAP Conversational AI FAQ bot configuration. Here I want to describe one of those tips in detail and show step by step how we can use a search API like SAP Search API to enrich our fallback.

The following guidelines are based on FAQ bot. However, a similar approach can be used in Action bots.



There are some points in the chat flow that your bot cannot provide the desired answer like when the confidence score is lower than 5%, when the user has been clicked on “None of the above” option, or when the user had a negative feedback caught in customer-satisfaction-reply skill.

In this situation, one of the possible additional services could be providing a search result based on the user initial query. We can do this in SAP Conversational AI by calling APIs and formatting the responses. Here I will show how to use SAP Search API to provide search result from SAP open access information when the confidence score is lower than 5%.

Figure 11 Providing search result when confidence score is low, showing in the SAP Conversational AI chat preview.


As SAP Search API requires a JWT token for search query, we first need to consume an API to get the token and save it in the memory and then call another API to post our query and get the search result. At the end we just need to format the response body and show the user few search results (e.g., the first five titles and links).


How to?

Step 1: Call the API

1. Go to the Build tab

2. Click on faq skill

3. Add a new Action Group

4. Add an API service to get JWT token

a) Click on Connect External Service

b) Select Consume API Service

c) Configure it as shown below

Figure 12 Using API service to get the JWT token


d) Go to the Response tab and check the Include headers check box


5. Add a memory to save the token

a) Click on Update Conversation

b) Select Edit Memory

c) Configure it as shown below:

Figure 13 By clicking on the value box this black box will pop up. On the right side there are some scripting examples. Headers are in the property named default.


6. Add another API service to call the search

a) Again, select Consume API Service

b) Configure it as shown below

Figure 14 Using API service to post a search request.


c) Add the following as the body

Figure 15 nlp.source is containing the last message which the user has sent to the bot.


7. Add another memory to save the search result

a) Again, select Edit Memory

b) Configure it as shown below

Figure 16 Body is in the property named default.

💡Note: Based on where and when you want to show the search result you can set the conditions for this Action Group. For instance, in our case the conditions would be when confidence score is lower than 5%.


Step 2: Format the response

1. Go to the Action Group for confidence score lower than 5%

2. Add the following as the message content

Figure 17 Example of fallback search message.


💡Note: Find more about API responses here.

💡Note: To framing the answer, we are using SAP Conversational AI scripting capabilities which you can find more about it here.

💡Note: You can always add more text messages as an alternative. Then the bot can show them randomly. For this you can add another text message by clicking on the + button and then switch it to an “OR”. Examples and more fallback options can be found in this sample FAQ bot.



Calling an API inside your SAP Conversational AI chat bot is only one way to provide better service to your users. For more tips you can read my previous blog about FAQ bot, Simple and Useful FAQ Chatbot: 10 Tips to Get More Out of SAP Conversational AI FAQ Bot Step by Step....

Please feel free to provide your comment and suggestions about this tutorial.

You can find more about SAP Conversational AI in the community topic page.

And feel free to ask your questions in the Q&A tag link.


More Info


Follow Mohammadhadi Shadmehr on LinkedIn