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: 
Community Administrator
Community Administrator
For awhile now I've explored possibilities with the Amazon Echo and SAP HANA, and over time I've received a lot of requests on how to do that or how to do that. Therefore I decided to put together a little blog here to describe the "how" of some of the demos I have done and how you can do it using SAP HANA for free inside the SAP HANA Cloud Platform trial system.

I've been a fan of the device since it came out and have done dozen of demos, dozens of skills and explored many ways of working with the device.

I also realized that with some time, patience and a little research everything you need to complete your own SAP HANA based Amazon Echo demo is already online in our Tutorial Catalog.

I actually started vacation yesterday so any comments or questions may be slightly delayed but since I decided I would share a personal favorite in terms of projects I thought that as the year starts to come to a close perhaps you may want to find the time for a new project as well and why not give you a helping hand - even if you only have access to the simulator and not the device itself.

The following project details efforts to implement an SAP HANA XS application that interacts with an Amazon Echo via OData services. The purpose behind the original application was as a virtual assistant during the SAP TechEd event in 2015 followed by several modifications to the base for additional projects. The following should outline the basics necessary for the creation of the application, data tables and OData services. Followed by the linking and interaction needed within the Alexa Skill.

The following will outline what is necessary to repeat this process:

  • Create your MDC instance

  • Create your first XS application.

  • Enable your XSODATA service

  • Posting to your HANA application

Now to get going with the steps and where to find the help!

  1. The first step necessary for the project will be to Sign up for an free trial account on SAP HANA Cloud Platform

  2. Once you have signed into the system you can follow the steps in the following tutorial to create your first MDC instance.

  3. Once the instance is created you can follow the steps in this series to create your first application and enable your XSODATAservice.

  4. Once you have your data tables created and your services enabled you can follow the steps in this tutorial on how to “submit” data to your tables via the service as well.

  5. For the purposes of interacting with the Amazon Echo I created two tables, the first table is the primary table containing the data for the Echo responses while the second table is there to enable a feedback mechanism for visualizing the requests via a web page in real time.
    The table for data responses is as follows.
    @Catalog.tableType : #COLUMN
    Entity Details {
    key ID: Integer;
    TITLE: LString;
    CATEGORY: SString;

    The table for the logging those requests is as follows.
    @Catalog.tableType : #COLUMN
    Entity Details {
    key ID: Integer;
    CATEGORY: SString;

    Be sure to also include the necessary hdbsequence the posting of data. This is also explained in the other tutorials.

  6. To make things a bit easier and since this was purely a demo I also enabled an anonymous connection on my services package for the posting and requesting of data via the individual services. To do so can be found via the following how to guide.

  7. Now that the general data tables and services are in place. You can also follow these tutorials to create a UI interface to be able to enter new entries that later your Alexa Skill set would be able to use. 

  8. Now that you have a basic interface as well as your data tables and services, the next step would be to interface it with an Alexa Skill which you can use the following tutorials to understand better how to do that.

  9. In the Alexa Skill I added the following function in order to “post” to the created services. 
    var setHANALog = function(itemName){ 
    var body = JSON.stringify({ "ID" : 1, "CATEGORY" : itemName })
    var request = new https.request( {
    hostname: host, path: "/packagename/services/echo.xsOData/newlog",
    method: "POST",
    headers: {
    "Content-Type": "application/json; charset=utf-8",
    'Accept': '*/*' }
    request.on('response', function (response) {
    console.log('STATUS: ' + response.statusCode);
    console.log('HEADERS: ' + JSON.stringify(response.headers));
    response.on('data', function (chunk) {
    console.log('BODY: ' + chunk);

  10. I also added a function for accessing the entries.
    var getResponseFromHANA = function(itemName, callback){
    var options = {
    method : 'GET',
    host : host,
    path : "/packagename/echo.xsOData/InputParams(LV_CATEGORY=%27"+itemName+"%27)/Results?$format=json",
    'Authorization': authStrIoT,
    'Content-Type': 'application/json;charset=utf-8',
    'Accept': '*/*'

    https.get(options, function(res){
    var body = '';

    res.on('data', function(data){
    body += data;

    res.on('end', function(){
    var result = JSON.parse(body);
    var items = result.d.results;

    }).on('error', function(e){
    console.log('Error: ' + e);

  11. Remember to also include the additional parameters being used in both functions. For example my server is hanatrial and my account is d045495trial
    var host = 'iotmmsmdc<ACCOUNT>.<SERVER>';
    var authStrIoT = 'basic_authorization("SYSTEM", "<PASSWORD OF YOUR MDC INSTANCE>")';

  12. With that in place it was a matter of testing. From AWS you have the ability to enter your utterance and test the result.

  13. Or you can access the logs to view your console log outputs or other outputs. 

  14. The final step was to visualize in real time the requests as they were coming in. 

  15. To accomplish that it was a quick HTML page created using some basic JavaScript and HTML with a automatic reload of the data. Very similar to how this tutorial describes it.

I figure the whole process should take you anywhere from 45 to 90 minutes and will highly depend on your experience with SAP HANA XS applications and your experience with Javascript - that being mainly because I used the Node.js version of the Alexa Skill Kit.

Using this baseline demo I've been able to create close to a dozen different demos and have even been able to integrate and interact with other data within the system, it's really just a matter of determining how best to interact with the device and how to grab data from the system. Some of the more advanced stuff uses XSJS libraries for more complicated interactions.

Enjoy working with this and I hope it can help you on your way to making some interesting demos as well!