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.
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member439824
Contributor
Hello,

On our latest blogs we’ve explained the basics of SAP Conversational AI and how to have a “chat” with your HR system using Slack to open leave requests and to check available leaves.

This time, we are going to follow how David, our Sales representative, uses Google Assistant to register and access information about customers whom he’s going to meet soon by using his voice.
This is how David interacts with his CRM, SAP Cloud for Customer.




Natively, SAP Conversational AI supports many communication channels, such as Slack, Facebook Messenger, Line, Salesforce, SAP Jam, SAP Customer Engagement Center, and so on.

In order to use other channels, you can call the SAP Conversational AI through APIs. In this blog, we will show how to integrate your chatbot with digital assistants such as Google Assistant.

For this purpose, you can call SAP Conversational AI programmatically through its Runtime API, which is basically  Natural Language Processing as a service. It allows you to send a request to SAP Conversational AI through an URL, and get a response which includes the detected language, intent, entities, sentiment, and so on.

So let’s have a look at how David, our sales representative, uses Google Assistant to access and creates information about customers whom he’s going to meet.



 

Let’s say David starts by saying  "Please create a new visit report for my customer visit at bluebeat in White field Bangalore.".

When he speaks to his phone, Google Assistant will first take care of translating his spoken words into written sentences, or in other words, apply its “Speech to Text” capabilities.

These sentences are processed within Google Dialogflow and sent onto SAP Conversational AI in a JSON format :




 

Here is the beginning of the JSON file on the screenshot above. You can see "queryText" with the user input as one sentence.


{
"responseId": "e14b40b9-8133-4633-b62d-a50c0847ad42",
"queryResult": {
"queryText": "Please create a new visit report for my customer visit at bluebeat in White field Bangalore.",
"parameters": {
"duration": "",
"location": {
"street-address": "White field"
},
"date": "",
"number": "",
"time": "",
"time-period": "",
"date-period": ""
},
"allRequiredParamsPresent": true,
} }


In order to use the runtime API of SAP Conversational AI, you need a bot trained with samples of the sentences which are going to be sent by users, and these sentences have to be separated in intents. When you know the intents that you want to recognize, the URL of your bot and your authentication token, you can start sending requests.

Our JSON QueryText from Google Assistant goes through a Python App hosted on SAP Cloud Platform, where the POST request sent to the Runtime API is prepared.
This is how the request is prepared in Python.
You can see here the URL of the bot as "host" and "request_path", then the userInput variable is sent as payload, and authentification to SAP Conversational AI is done in the Header.


def getRecastResults(userInput=None):
payload = {
'text': userInput,
'language': 'en'
}
resp = requests.post(CONF.get('RECAST_BOT', 'host') + CONF.get('RECAST_BOT', 'request_path'),
data=payload,
headers=getRecastHTTPAuthHeader())
return resp.json()['results']

If you want to know more about hosting applications on the SAP Cloud Platform. have a look at this tutorial.

This is the answer SAP Conversational AI's Runtime API sends :


{
"results": {
"uuid": "7f2fbe32-d48c-4247-9f3e-2b218886925a",
"intents": [
{
"slug": "ask-create-visit-report",
"confidence": 0.99,
"description": "Intent for creating visit report."
}
],
"entities": {
"number": [
{
"scalar": 1,
"raw": "a",
"confidence": 0.99
}
],
"company": [
{
"value": "bluebeat",
"raw": "bluebeat",
"confidence": 0.99
}
],
"address": [
{
"value": "whitefield bangalore",
"raw": "White field Bangalore",
"confidence": 0.93
}
]
},
"language": "en",
"processing_language": "en",
"version": "2.12.1-9a00bd4",
"timestamp": "2019-02-12T04:29:58.924948+00:00",
"status": 200,
"source": "Please create a new visit report for my customer visit at bluebeat in White field Bangalore.",
"act": "command",
"type": null,
"sentiment": "neutral"
},
"message": "Requests rendered with success"
}

The status of 200 indicates that the request was processed correctly.

The answer contains the detected intent "ask-create-visit-report", the confidence of 99%, the sentiment "neutral"and the language "en". The bot also understands entities, such as number, company and address. These entities can be passed onto SAP Cloud for Customer as data points.

And with this, on one side you can fetch the necessary information from the back-end CRM system, and on the other side you can create an appropriate conversational flow.This is how you can integrate your back-end system to any external Conversational User Interface.

Here is a screenshot of how the same request looks when using Postman.




 

We make use of the intent detection API of SAP Conversational AI to make sure that the request is understood.
These are some of the intents our bot is able to detect.




 

Based on the user intent "ask-create-visit-report", the Python app sends a request to the SAP Cloud for Customer system’s API, to create a visit report there.

SAP Cloud for Customer will then return a JSON response containing the requested data back to the Python app.

This response is forwarded to Google Dialogflow, and then to Google Assistant.




All this flow is done within a second, while David is talking with Google Assistant.
And it is repeated for each interaction with the bot, until the conversation is completed.




 

Once David creates the customer visit on his phone, this is what he sees when opening SAP Cloud for Customer.
You can see the customer account on the left with one planned visit, and the customer location on the map.




 

Learn more about the APIs of SAP Cloud for Customer. here and here !
And don’t forget to check https://api.sap.com/ to learn more about the different APIs SAP is offering for all our applications.

SAP Internal Sales Cloud chatbot video link

SAP Internal Sales Cloud chatbot info

If you have any further questions don’t hesitate to contact us!

 

Maxime Simon
Jorge Mendes
Special thanks to Joni Liu, who did the full implementation of the chatbot presented here.
4 Comments