Skip to Content

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;
        TIMESTAMP: SDate;
        TITLE: LString;
        CATEGORY: SString;

    The table for the logging those requests is as follows.

    @Catalog.tableType : #COLUMN
    Entity Details {
        key ID: Integer;
        TIMESTAMP: SDate;
        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!

To report this post you need to login first.


You must be Logged on to comment or reply to a post.

  1. Sergio Guerrero

    such an awesome post!

    on step 8, was there any cost associated with developing against the Alexa API?

    Thank you again for sharing this great blog.

      1. Sergio Guerrero

        yes, I wanted to know about how much it would cost for your demo, but i also saw on the AWS site, there is cost after a few million voice requests… it makes sense.. thanks again

  2. Santosh Singh

    Hi Craig,

    I am trying to build an Alexa skill using Python which gets the data from an OData service exposed through OData provisioning service. The problem I am running to is how do I authenticate in Python to the HANA trial account. I tried passing basic_authorization in the header but seems like that does not work. Any ideas here.


  3. Gagan Pareek

    Craig Cmehil

    Can you share the libraries that you imported in your Alexa code to make it work?


    I am getting error message.

      "errorMessage": "Handler 'handler' missing on module 'index'"
      1. Diana Fernanda Vazquez Romo

        Hey Craig,


        I am working on a similar skill that requests data from xsjs service rather than an XSOData as you do here.

        I have a httprequest call in my index.js file that is very similar to yours. I have the Headers as you do including the Authorization one. And I think the http request URL that I provide is correct as the Amazon Alexa skill test did not raise an endpoint error or anything. However, what does happen, is that my return data text is blank.

        So instead of having the data that I inputted in my table I have a blank. Do you know what could be happening? Maybe you can refer me to some other blogs that work with xsjs service?


        Edit: It is also worth mentioning that my xsjs returns a json object. One idea is that I have not correctly set up the anonymus connection? When I remove the Authorization header, the outcome is the same, a blank return data. 




        1. Craig Cmehil Post author

          I’ve found the same thing hence my use of the stored procedure and xsodata. I’ve not had the time, even though it is on my list to trying and determine why the XSJS is not happening ….

  4. Raghavendra AY

    Hi Craig,

    Great Blog .

    I followed the steps mentioned in the blog, i was able to POST and GET data through  POSTMAN.

    However from AWS Lambda, i get Address not found Error.I have set host and Path name as below,

    I’m trying to POST  directly to the tables via XSO Data without creating a UI5 Interface.

    var host = ‘’;
    var authStrIoT = ‘basic_authorization(“USERID”, “PASSWORD”)’;

    Path: Package/myecho.xsodata/DATA

    Any pointers would be helpful.



    1. Craig Cmehil Post author

      Does it work in POSTMAN when you are not logged in? Like Incognito mode or before even logging into the Cloud Platform system?

  5. Raghavendra AY

    Hi Craig,

    I logged into HCP started database server, logged out from HCP account completely and ran POSTMAN request,i was able to Get the data .




  6. Consultant HCL


    Hi Craig,

    This is an excellent blog! I would like to have some idea from you for the below integration which I am planning

    We have an audio/video smart device that has an inbuilt Wi-Fi chip and runs on Android 6.0. We also have HXE (Hana Express) running on AWS cloud. We want to live stream the audio/video data/signals into our AWS HXE tables and then see it in SAPUI5 application in real-time.

    Is this possible and what functions/configurations/hardware we can use to build this? I just need a very high level guidelines from you.


  7. J P

    Hi Craig,

    thank you for your post.

    I have problems with the HTTPS Post csrf token authorization. I make a https post via node.js in an amazon lambda function triggered by an alexa skill I created. The post request itself is valid and works. But the problem is: I always get a 403 error as a response because the header in the response shows for x-csrf-token: “required” although a valid token is set in the request header with “X-CSRF-Token”: token.

    I also created a question in the sap community (

    Do you know a possible solution?

    This would be very nice. Thank you for your answer!



          1. Jo Pa

            Okay. I am sorry for the late answer.

            Yes, I followed your instructions in the tutorial with regard to the XS Admin role settings. Or do you mean an important detail which is only neccessary for csrf token validation?


              1. Jo Pa

                In my .xsaccess file I defined this:

                “cors”: [{
                “enabled” : true,
                “allowMethods”: [“GET”,”POST”,”DELETE”,”PUT”]

                You mean this?


                  1. Jo Pa

                    Thanks for your comment. Can I find XS Admin within SAP HANA Web-based Development Workbench of the SAP Cloud Platform in Security, Catalog, Traces or Editor?



Leave a Reply