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!
Showing results for 
Search instead for 
Did you mean: 
Active Contributor
Hello All,


Welcome to another blog, this blog is about another coolest project of mine i was working from couple of days, "Google Assistant Integration with SAP S/4HANA". Google Assistant is another voice assistant system by Google which most of the people use.


But How this integration make sense?

Think about situation where you want to know some system insight may be you want to know your ticket status or order status and for this either you have to login to the system or have to ask someone who is in front of system. Now instead of doing all this you open your mobile and say 'OK Google' Tell me my ticket Status or Tell me my order status. How simple isn't it.

Now many people might've have started thinking that SAP Conversational AI would be used for designing the bot and then it would be integrated with Google Assistant but the trick is here that  is no standard channel or connector available in SAP CAI like Alexa or Facebook messenger to directly integrate with Google Assistant.


So how we will build this Integration?

As there is no standard direct integration possible from SAP CAI to Google Assistant, we have look for the option, and the option i am talking about here is Google DialogFlow. Dialogflow is a Google-owned developer of human–computer interaction technologies based on natural language conversations. It is similar to SAP CAI and it does have standard Prebuilt integration with Google Assistant.

Let's have a look at the technical architecture, After looking at architecture i believe most of the developer would be able to connect the dot.


If you look at architecture then one thing is clear in this picture that we are going to build or design the chat bot in SAP CAI which is integrated with SAP S/4HANA. Now if you are having experience in building chat bot in any platform you might have also experienced with Fallback intent or Fallback skill. it helps you to handle unexpected utterances, or when a customer says something that doesn't map to any intents in your skill. So Practically we are not going to build any intent in Dialogflow so whenever user ask anything it is going to fulfillment from fallback and it make a Web-hook call which  is noting but a node.js application running on SAP Cloud Platform. This node.js application is having two important features first one is it take the user input from google assistant and it pass to SAP CAI through SAP CAI SDK and get the response from CAI. Second one is just another hack think about you are not comfortable in talking or chatting in English then you speak your own regional language Yes it has translator capabilities it translate your language in English and Pass it to CAI and then it get the response in English from CAI and before passing to Dialogflow it translate to your regional language, cool isn't it.

Lets break this whole integration into smaller pieces, so that it would be more simpler.


1. CDS and Odata service creation for querying order status. (In this example Purchase Requisition and Purchase order Status will be queried). Check this blog.

2. Exposing the odata service through cloud connector and creating proxy api using SAP Api management. Check this blog.

3. Designing the skill of chatbot in SAP Cai. Check this amazing tutorial

4. Creating  node.js app which will be interacting with S/4HANA and provide json response the way SAP CAI  understand. Check out my github repository.

5. Deploying the node.js app we created in last step into SAP Cloud Platform CF account.

6. Use the deployed application URL with proper path as webhook of skill in SAP CAI.

7. Test the bot using SAP CAI.

for 5, 6, 7 check my previous blog.

8. Build Node.js Based connector or Web hook application and Deploy to SAP Cloud Platform Cloud Foundry
const express = require('express')
const bodyParser = require('body-parser')
const translate = require('@k3rn31p4nic/google-translate-api')
var sapcai = require('sapcai');
const app = express()
const port = process.env.PORT || 3000
// const port = 3000

app.use(bodyParser.json())'/sapcai',(req,res) => {
const response = res;
const msg = req.body.queryResult.queryText;
const sessionID = req.body.session.substr(36,115);
var build = new<SAP CAI Token>, 'en')
var detectlang , transtext, cairesponse;
//google translate code start.
translate(msg, { to: 'en' }).then(res => {

detectlang = res.from.language.iso;
transtext = res.text;
build.dialog({ type: 'text', content: transtext}, { conversationId: sessionID })
.then(res => {
cairesponse = res.messages[0].content;

translate(cairesponse, { to: detectlang }).then(res => {
response.send({fulfillmentText: res.text})

}).catch(err => {

}).catch(err => {
.catch(err => console.error('Something went wrong', err))

app.listen(port, () => {
console.log('Server is running on port '+port)

9. Create a Google Action project

Create new project

Select project type Conversational

Now Set a invocation name and save, Here i have given Ms. Sarah (So when i will say talk to Ms. Sarah. It will start the action)

Then Click on Action and click on Add your first action button

Now click on build it will navigate you to Dialogflow Screen



10. Configure and Create the agent


A. Create an agent Name it anything

here i have given Sarah

Now Create a new Intent Called End Conversation And add the training Data (Thank you, Thanks, Thank you google) And Add also response as 'You are welcome' and set this intent as end of the conversation. So whenever people will say thank you it will trigger this intent and it will end the conversation.



  B. Setting Welcome message in Default Welcome Intent, so when some one start your agent in google Assistant, it will trigger this.

C. Enabling Web hook for fallback intent

Click on Fallback Intent

Enable the Web hook for Fallback intent

D. Set the Web hook URL as fulfillment for Fallback intent( which we have built in Step 8

Go to Fulfillment

Set the URL of deployed node.js based connector

All Done, you can test it now.


Here i have attached a video of this Integration testing, hope everyone would like it.

Please don't forget to comment like and Share.Your Valuable comment and suggestion really help me to write more interesting content.





Labels in this area