Create Sales Orders and Analyse Sales Volume of SAP Business By Design using Alexa
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 device .
- 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
Step 1: Configure OData Service in SAP Business ByDesign
Option 1: Upload the OData Service (reuse the template OData service : Preferred option)
Steps to upload the OData service into SAP Business ByDesign mentioned below:
- 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. Note: make sure the OData service has the service URL generated.
Option 2: Create the OData Service (create OData service : Expert option)
- 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.
Step 2: Build Alexa Skill
Option 1: Upload the Alexa Skill JSON file (reuse the skill file : Preferred option)
- 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
Option 2: Create the the Alexa Skill (create skill from scratch : Expert option)
- Detailed Steps to build Alexa Skill:
- Build the skill in Amazon Developer account
- Goto Skill Builder , Create Skill
4. 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 )
5. 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’
6. 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.
Step 3: 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
- Open the file bydDigitalAssistant.js in editor like visual studio code
- Enter the URL of the SAP Business ByDesign system
- Enter the User credentials of the SAP Business ByDesign system
Step 4: 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 on a Sap Cloud Platform(SCP) with node run-time or the standalone ByD Digital Assistant locally .
- To deploy on SAP Cloud Platform Cloud Foundry, run the command below: (Preferred option)
$ cd ./Alexa-Meets-ByD-Sales-Info (navigate to root folder of the project )
$ cf push –random-route
Note: the web-application is successfully deployed
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: (Expert option)
$ 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.
Step 5: 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 😎
Scenario 1: results of Sales Volume analytical report.
Question 1: what is my net sales of the last three months
Question 2: list my top three accounts of last three months
Scenario 2: Creation of Sales Orders in SAP Business ByDesign
Question 1:buy me Compressor
Question 2: OK, how many do you need ( enter the answer as one )
Scenario 3: Interactive data extraction from results of Sales Volume analytical report.
Question 1:show me sales numbers (response from system is: “Got it! What quarter?” )
Question 2:last (response from system is :”What year do you need?”)
Question 3:last year (response from system is “The sales for the fourth quarter of 2019 is is 11255.7 US Dollar”
- 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.