cancel
Showing results for 
Search instead for 
Did you mean: 

Consuming ABAP web service in Conversational AI using Consume API option

praveenkumar_kadi
Active Contributor
0 Kudos

Hello Conversational AI experts,

Appreciate your valuable information on this.

to begin with, I completed below steps in pursuit of building a SAP chatbot via ABAP web service within OnPrem S/4 HANA 1909

1. Created a prototype conversational AI chatbot that connects to sample service using node.js through web hook action -> works fine

2. Created a sample http based ABAP web service/WSDL based on the RFC function module...tested in OnPrem S/4 HANA - SE80 -> works fine

3. Tested externally using SOAPUI tool -> works fine

4. Now trying to explore what are my options in connecting to above web service in conversational AI chatbot through consume API option or web hook?

5. Through web hook, it seems it can only be done through node.js request and response. correct? if yes, how do I connect to ABAP webservice built above

6. Through Consume API option, how do i do this. My web service is a http link - just to test a prototype

Thanks

Praveen

Accepted Solutions (0)

Answers (2)

Answers (2)

praveenkumar_kadi
Active Contributor
0 Kudos

Thanks Supriya. It looks like via SCP is the recommended option. While I test this, other option I'm trying to explore is:

How about having node.js sending SOAP request and getting response formatted in json format.

In my chatbot prototype, I have https link in the webhook calling Json service (eg. service.js) exposed through public server like ngrok. Instead of local service in service.js, how about sending SOAP request to my ABAP webservice and get the response converted to Json? so AI chatbot display returned response. (This is how Postman tool calls and get the response and tested successfully)

I'm thinking above below snippet in service.js file but not sure if this is an alternate option recommended. any suggestions?

var request = require('request');
let xml =
`<soap-env:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:qtre="http://Main.Service">
   <soap-env:Header/>
   <soap-env:Body>
      <n0:GetOrderStatus>
         <n0:sSearchText></qtre:sSearchText>
      </n0:GetOrderStatus>
   </soap-env:Body>
</soap-env:Envelope>`

var options = {
  url: 'http://localhost/MyService/OrderService?wsdl',
  method: 'POST',
  body: xml,
  headers: {
    'Content-Type':'text/xml;charset=utf-8',
    'Accept-Encoding': 'gzip,deflate',
    'Content-Length':xml.length,
    'SOAPAction':"http://localhost/MyService/OrderService"
  }
};

let callback = (error, response, body) => {
  if (!error && response.statusCode == 200) {
    console.log('Raw result', body);
    var xml2js = require('xml2js');
    var parser = new xml2js.Parser({explicitArray: false, trim: true});
    parser.parseString(body, (err, result) => {
      console.log('JSON result', result);
    });
  };
  console.log('E', response.statusCode, response.statusMessage);  
};
request(options, callback);
supmalak93
Participant
0 Kudos

Hi Praveen,

You need to develop one Rest API service for your ABAP program .you can do that in SAP Cloud Platform , it will make https API for your ABAP program, then you can consume that from CAI . You can't consume http based url from CAI.

You can refer below blog where I used SAP MII system which is a S/4 HANA based system for your case.

https://blogs.sap.com/2020/11/24/how-to-provision-voice-enabled-ai-based-chat-bot-to-your-sap-me-sys...

Thanks and Regards

Supriya Malakar