SAP Business ByDesign (ByD) enables integration with Natural Language Processing (NLP) enabled devices like Alexa using OData services to create, update, delete and read transaction and master data in ByD.
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.
This blog post provides information about how to create data in ByD using custom OData services build on business objects using OData modeler. For details about how to create custom OData services in Business ByDesign, please refer to video: SAP Business by Design – How to Create an OData Service
For details about how to Create ByD Sales Orders using Web Services please refer to blog which explains details related to sales order integration scenarios.
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 executive creating Sales Order in Business ByDesign using Alexa devise .
- Access to SAP Business ByDesign system
- An Amazon Developer account
- To Create the Alexa Skill
- To Test the Alexa Skill
- An Amazon Web Services Account
- NodeJS development platform
- Access to SAP Cloud Platform with Cloud Foundry and NodeJS (alternatively you can use any other development platform supporting NodeJS)
- An Amazon Echo (not mandatory, but pretty cool to demo)
- To Test the Alexa Skill
All the code used in this tutorial is shared on GitHub
Configure OData Service in SAP Business ByDesign
Upload the OData Service:
Open the SAP Business ByDesign work center view Application and User Management – OData Services, navigate to “Custom OData Services“, click on button “Upload” , select the custom sales order OData modeler, after successful upload the service will appear in the custom OData services list, Edit the service and Activate the service, make sure the OData service has the service URL generated.
Create the OData Service:
Open the SAP Business ByDesign work center view Application and User Management – OData Services, navigate to “Custom OData Services“, click on button “New“, enter the Service Name , click on Save and Close, Select the Work Center View, Select the Business Object and Node Name, Select the elements and sub-nodes which are required for the scenario, click on Save, click on Activate, make sure the OData service has the service URL generated.
For details about how to create custom OData services in Business ByDesign, please refer to video: SAP Business by Design – How to Create an OData Service
Test OData Service of SAP Business ByDesign
Test the custom OData service using Postman or any other application which tests CRUD (Create, Retrieve, Update and Delete) of data 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 ‘Make Purchse’, which has set of possible questions like ‘Create Order’
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 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 “MakePurchase“
- Calls OData POST service of BYD
- Construct a response in a Alexa service predefined format
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
$ cf set-env <your app name> BYD_SERVER http://<your byd server
$ cf set-env <your app name> BYD_PORT “”
$ 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 😎
- For details about how to create custom OData services in Business ByDesign, please refer to video: SAP Business by Design – How to Create an OData Service
- For details about how Alexa integration is done other ERP solutions like Business One, please refer to blog: B1 Assistant – Retire your keyboard with SAP Business One and Alexa
- For details about How to integrate Business ByDesign with Alexa, please refer to blog: Alexa meets Business ByDesign
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.