Skip to Content
Product Information

Alexa Meets SAP Business ByDesign

SAP Business ByDesign (ByD) enables integration with Natural Language Processing (NLP) enabled devices like Alexa using OData services.

In today’s world where technology continues to make our work bit easier and more flexible. We look at new cutting edge technologies and ask ourselves, how can SAP Business ByDesign (ByD)  interact with voice based smart device? That’s what we have done with Alexa meets ByD, we’re excited to share the blog which explains in detail how to integrate Alexa with ByD and fulfill real world business scenarios. This blog also showcases how ByD is open for any Natural Language Processing (NLP) based integration using ByD APIs. This is not a core feature of SAP Business ByDesign, it is a showcase that demonstrate the openness of ByD integration and possible integration of ByD with Alexa.

 

 

The Architecture

Alexa (Amazon Echo’s persona) has several capabilities (Skills). Those are divided between Native (time, weather, traffic, news…) or Custom Skill (Uber, Spotify, Business ByDesign, Business One…)

To activate the custom skill, we use Invocation Names. Those are nothing more than the name of the skill we want to call. For example: “Alexa, ask ByD for Sales Volumes of Last Quarter” or “Alexa, ask Uber for a ride” or “Alexa, open Spotify”. Once it hears your command, it will identify the skill to be triggered and call a specific Web Service that can be hosted on a Private Cloud or on AWS. Like this:

 

In our case, working the with ByD Digital Assistant Skill the architecture is:

For more information about Alexa Skill take a look at Alexa’s documentation

 

ByD digital assistant show cases the integration openness and business application of ByD OData services.

Basic building blocks include:

  • ByD OData standard and custom services
  • Alexa Skill: which calls the custom web service
  • Custom Web Service: which calls the ByD OData services

 

Example Business Scenario: Sales manager starting the day with preparation at breakfast Lets assume a sales manager starting the day with preparation for sales meeting at breakfast and would like to get details about whats the net sales of last quarter and would like to know top 3 accounts of last three months so that sales manager can take informed sales decisions based on the real time sales analytical data in ByD. Sales manager has access to Alexa device and would like to to realize the above business scenario.

 

Prerequisites

All the code used in this tutorial is shared on GitHub

 

Configure OData Service in SAP Business ByDesign 

SAP Business ByDesign provides 3 types of OData services:

  • OData for Reports to access pre-processed and formatted analytical data,
  • OData for Data Sources is designed to extract analytical raw data,
  • OData for Business Objects designed for interactive read and write access to ByD

For detailed steps to exploring about OData services of Analytical reports in ByD  please refer to blog OData for SAP Business ByDesign Analytics

 

To realize the business scenario user could use the option of building OData for Reports to access pre-processed and formatted sales analytical data from sales volume analytical report.

 

Steps to get OData URL for Sales Order Volume report.

Open the SAP Business ByDesign work center view Business AnalyticsDesign Reports, search for ‘Sales Order Volume’ report and click on “Build OData Queries“.

 

Based on the business use-case select the relevant Characteristics and Key Figures.

In the above business use-case use wants the answer for the query “what’s my net sales value of the last three months

For the above query user has to select the Keyfigure ‘Net Value’ in the Attributes section of Build OData Queries.

Note down the technical name of the Keyfigure ‘KCITV_NET_AMT_RC’ (Net Value).

Select the desired format as JSON. Click on ‘Generate Data Query’ and OData URL is filled in section ‘OData Query’ .

 

Sample OData query format could look like ‘https://<your system hostname>/sap/byd/odata/<shortened name of work center>_analytics.svc/RP<report ID>QueryResults?$<characterstics and key figures to be selected>&$<filter condition>&$format=json’

Example OData URL to read the Net Sales of Last Quarter of year 2018 is :

https://<your system hostname>/sap/byd/odata/ana_businessanalytics_analytics.svc/RPCRMSLOIB_Q0001QueryResults?$select=KCITV_NET_AMT_RC&$filter=(PARA_CRMSLOIB_REP_01 ge datetime’2018-10-01T00:00:00′ and PARA_CRMSLOIB_REP_01 le datetime’2018-12-31T00:00:00′ ) and ( PARA_CRMSLOIB_REP_02 eq ‘E0005’ or PARA_CRMSLOIB_REP_02 eq ‘E0102’ or PARA_CRMSLOIB_REP_02 eq ‘E0103’ or PARA_CRMSLOIB_REP_02 eq ‘E0203’ or PARA_CRMSLOIB_REP_02 eq ‘E0210’ or PARA_CRMSLOIB_REP_02 eq ‘E1003’ or PARA_CRMSLOIB_REP_02 eq ‘E7007’) &$format=json

Note: for Sales Volume report the report parameter ‘Employee Responsible’ is required to get the relevant data, for demo purpose we selected all employees in the system. user can decide to select only the sales manager in the system. the report parameter filter value for ‘Employee Responsible’ depends on the use-case.

 

In the above business use-case use wants the answer for the query “list my top three accounts of the last three months

For the above query user has to select the Characterstic ‘Account ID‘ in the Attributes section of Build OData Queries. Note down the technical name of the Keyfigure ‘CIPY_BUYER_PTY’ (Net Value). Select the desired format as JSON. Click on ‘Generate Data Query’ and OData URL is filled in section ‘OData Query’ .

 

Sample OData query format could look like ‘https://<your system hostname>/sap/byd/odata/<shortened name of work center>_analytics.svc/RP<report ID>QueryResults?$<characterstics and key figures to be selected>&$<filter condition>&$format=json’

Example OData URL to read the top three accounts of the last three months Last Quarter of year 2018 is :

https://<your system hostname>/sap/byd/odata/ana_businessanalytics_analytics.svc/RPCRMSLOIB_Q0001QueryResults?$select=C1IPY_BUYER_PTYsORG_NAME,KCITV_NET_AMT_RC&$filter=(PARA_CRMSLOIB_REP_01 ge datetime’2018-08-01T00:00:00′ and PARA_CRMSLOIB_REP_01 le datetime’2018-10-31T00:00:00′ ) and ( PARA_CRMSLOIB_REP_02 eq ‘E0005’ or PARA_CRMSLOIB_REP_02 eq ‘E0102’ or PARA_CRMSLOIB_REP_02 eq ‘E0103’ or PARA_CRMSLOIB_REP_02 eq ‘E0203’ or PARA_CRMSLOIB_REP_02 eq ‘E0210’ or PARA_CRMSLOIB_REP_02 eq ‘E1003’ or PARA_CRMSLOIB_REP_02 eq ‘E7007’) &$format=json

 

Note: user can view the filters in the report by launching the Report: Sales Order Volume.  Click on the option ‘Configure’ and select ‘Show Technical ID’ and user can add the filters using the Technical ID ( example ‘Time Frame’ filters technical ID is ‘PARA_CRMSLOIB_REP_01’ )

 

Test OData Service of SAP Business ByDesign 

Test the Example OData URL that are generated earlier and compare the results with Sales Order Volume report results in ByD.

 

 

 

 

Build Alexa Skill

Create a new Alexa Skill following these steps. When asked for a Model choose Custom.

Next part we need to customize and build the skill.

On the Skill menu, choose the option JSON Editor. Replace its content with the model on our GitHub

Click Save then Build your model

Detailed Steps to build Alexa Skill:

Build the skill in Amazon Developer account

Goto Skill Builder , Create Skill

 

Enter the Skill Invocation Name

Invocation name is the key word used to launch the application, example ‘bee why dee’ ( user could enter any desired name )

 

Enter the Intent name

Intent is the key word which will unuquly identify possible set of questions. Each intent corresponds to a question to fulfill specific functionality.

Exmaple intent is ‘NetSales’, which has set of possible questions like ‘what’s my net sales value of the last three months

 

Enter the another Intent name

Exmaple intent is ‘TopAccounts’, which has set of possible questions like ‘list my top three accounts of the last three months

 

Enter the Endpoint

The Endpoint will receive POST requests when a user interacts with your Alexa Skill. The request body contains parameters that your service can use to perform logic and generate a JSON-formatted response. Learn more about AWS Lambda endpoints here. You can host your own HTTPS web service endpoint as long as the service meets the requirements described here.

Service Endpoint Type decides how you will host your skill’s service endpoint, one option is AWS Lambda ARN: Host your endpoint using AWS Lambda, a service-less compute service, other option is HTTPS: Host your endpoint using HTTPS web-service that you manage,

Note : Service endpoint is the URL of the web-application which takes the JSON request and returns back web-service response which will be rendered and processed by Alexa device at run-time.

 

Build Web-Service

Build web-service and deploy the service, the web-service endpoint URL is used in Alexa skill endpoint configuration.

 

Web service acts like a middle-ware application, which performs the following task:

  • Processes the JSON web-service request, which is in predefined format from Alexa service
  • Identify the Alexa Skill intent
  • Based on the intent construct the ByD OData service request body
  • Fills the ByD OData service request header information including Authorization details
  • Calls the ByD OData service
  • Parses the ByD OData service response
  • Construct Alexa service response, based on ByD OData response

 

For sample showcase purpose we have built a web-application using NodeJS.

 

Steps to develop web-application using NodeJS.

  • Download NodeJS installer and install the operating system specific installer.
  • Set the environment variables PATH with the folder of NodeJS
  • Download the code from the tutorial that is shared on GitHub

Note: it’s a showcase only purpose and for productive use please use the proper authorization and user management.

  • POST service call to web-service

  • Calls onIntent function

  • Calls specific intent like “NetSales” or “TopAccounts”

  • Calls OData service of BYD

  • Construct a response in a Alexa service predefined format

 

Deploy Web-Service

 

Deploy the web-service in any web-server, after successful deployment the web-service endpoint URL is used in Alexa skill endpoint configuration.

 

For demo purpose we have used SAP Cloud Platform(SCP) to deploy the web-application. Once the successful deployment is done the service is up and running.

 

Note: to use deploy the application using Cloud Foundry Command Line Interface, please install Cloud Foundry Command Line Interface (cf CLI), for  detailed steps please refer to Installing the cf CLI

 

Now you also can deploy the Alexa skill locally or cloud foundry as standalone NodeJS app. Follow the steps below:

Step 1: Deploy the standalone ByD Digital Assistant locally or on a cloud platform with node run-time.

  • To deploy on SAP Cloud Platform Cloud Foundry, run the command below:

$ cd ./Alexa-Meets-ByD-Sales-Info

$ cf push –random-route

  • Note: the web-application is successfully deployed
Then set the Environment Variables accordingly

$ cf set-env <your app name> BYD_SERVER http://<your byd server>

$ cf set-env <your app name> BYD_PORT “”
$ cf set-env <your app name> BYD_AUTH <[Base64 Encoded] user:password>
For Example:
$ cf set-env BydDigitalAssistant BYD_SERVER https://my123456.sapbydesign.com
$ cf set-env BydDigitalAssistant BYD_PORT “”
$ cf set-env BydDigitalAssistant BYD_AUTH ABCDEFGHIJKLMNOPQRSTUVWZYZ123456789==
Note : Set the BYD_SERVER to appropriate ByD URL
Note : Set the BYD_PORT to blank , since there is no PORT value in the URL of BYD
Note : Generate the Base64 Encoded using external application like Postman
Note: user can decide to use UserName and Password authentication , in that case user has to adapt the Authorization (request header of OData POST service call) web-application coding accordingly

$ cf restart ByDAssistant

If you are new to SAP Cloud Platform Cloud Foundry, please refer to this YouTube video: Deploy a NodeJS App to SAP Cloud Platform Cloud Foundry

  • To deploy locally, run the command below:

$ cd ./Alexa-Meets-ByD-Sales-Info

$ npm install

$ npm start

Step 2: Update the end point of alexa skill with HTTPS instead of AWS Lambda ARN in the configuration section of your Alexa skill.

 

Link the function to your Alexa Skill and Test. 

Whatever option you choose before, at the end you should have an endpoint for your function. I.e., an ARN if you are using Amazon Lambda, or an URL if you pushed the app to SAP Cloud Platform.

Back to the Amazon Developer Console (the same as step 2). Choose the right the menu Endpoint and set the right option for your case.

Choose the type of Endpoint for you case and set the address. More about endpoints here

Save your settings and build your model again!

Your ByD Assistant is ready to work! You can use the Test Console (open your skill in Alexa Skills Kit Developer Console and use the Test option using Alexa Simulator), for mote details please refer to video Alexa Skills Kit Developer Console: Test or use the Echo Simulator or with a real Amazon Echo by enabling the Skill on your Alexa app. Which is much cooler 😎

 

 

Reference Blogs:

 

Next Blog (Complex scenario)

Lets assume a sales representative who would like to address the sales orders that are delayed since yesterday, would like to know how many orders are delayed, which customers are affected and call the affected customer and inform about the delay and would like the phone call activity to be recorded in ByD. Sales representative has access to Alexa device and would like to to realize the business scenario.

Be the first to leave a comment
You must be Logged on to comment or reply to a post.