Hello SAP community,
Have you ever wondered how amazing it would be to operate within your SAP system simply by using the power of your voice?
In this blog post, I’d like to share my experience with you regarding the integration of an SAP system with an external digital voice assistant. For this project, I utilized the Amazon Alexa digital voice assistant for voice recognition, coupled with SAP Build Process Automation to construct automations that can be triggered via Alexa.
I will provide a comprehensive, step-by-step guide from the very beginning, explaining the settings and tools you need to initiate an automation process in SAP using voice commands.
The connection between SAP and Alexa offers a large number of possibilities, ranging from launching Fiori Apps to automating extensive business processes—all initiated with a simple voice command. Feel free to experiment! Additionally, it’s worth noting that the implementation described here is not limited to Alexa as a digital voice assistant. With a few adjustments, you can adapt this approach for use with various other voice assistants or even create your own.
Before we dive into the details, let me provide you with some insights into how Alexa and SAP Build Process Automation cooperate in the following implementation:
Architecture of the connection between SAP and Alexa
When a user issues voice commands to the Alexa speaker, Alexa processes the spoken text using natural language processing. Alexa then associates the text with a predefined intent, which is further linked to a corresponding intent handler. Inside the intent handler (the backend code), we perform two essential post-requests:
The triggered automation will be loaded into the Desktop Agent and executed from there.
Now that we understand how Alexa and SAP can seamlessly collaborate, it’s time to initiate the connection.
We’ll commence within the SAP Business Technology Platform (BTP) by configuring a few settings, enabling us to begin working with SAP Build Process Automation to create the automation that we intend to activate through Alexa. To effectively utilize SAP Build Process Automation, it’s imperative not only to have the necessary permissions to access it via the cloud web interface but also to install the Desktop Agent locally on every computer where you intend to initiate automations. You can download the Desktop Agent from the following link: https://tools.hana.ondemand.com/#cloud.
Once we’ve constructed an automation, we’ll proceed to develop a skill and an intent within Amazon’s Developer Console. Here, we’ll implement the two POST methods in the backend code to trigger the automation that we created in the preceding steps.
If you haven’t already done so, the initial step involves creating an instance of SAP Build Process Automation. This instance will provide us with a key that contains essential information required for the subsequent POST requests. To create an instance, follow these steps:
By completing these steps, you will have the required instance of SAP Build Process Automation and the associated key with the essential information for your POST requests.
Create new Instance
To fully leverage the capabilities of your SAP Build Process Automation Application, it’s crucial to establish a connection between the Desktop Agent and the application. To guide you through this process, please refer to the following video tutorial:
While the user interface design may have undergone some changes, the video remains relevant and will provide you with the necessary steps to connect the Desktop Agent with your application.
Now it’s time to create your own automation. To get started, you can refer to one of the many SAP tutorials available.
When initiating a new project, I typically opt for “Automated Processes,” and within this category, I select “Business Processes.” Within Business Processes, you can seamlessly integrate automations. These automations can be built from scratch, but personally, I often use the “Screen Capture” feature. To access “Screen Capture,” add an Application to your project. When you do this, a pop-up window will appear, allowing you to enable the Screen Capture functionality. This essentially means that you can record your screen clicks, and the tool will automatically generate code based on your captures.
Feel free to test your application during the development phase using the integrated testing tool. This will help you ensure that your automation functions as expected and meets your requirements.
Now that your automation is built and you’ve confirmed its functionality through testing, it’s time to add a trigger to your process. To achieve this, follow these steps:
(Note: If you don’t see the “View” button, please double-check that you have deployed the project in which the trigger was created.)
Add a API-Trigger
At this stage, we’ve completed the implementations and configurations within SAP Build Process Automation, and it’s time to shift our focus to the Amazon Developer Console.
If you haven’t already, please sign in to the Amazon Developer Console. Once logged in, you can create your first Skill by clicking on “Create Skill” on the Developer Console’s starting page. Please fill in the required information as per the following images, making sure to adjust the configurations for hosting service, region, and primary locale to meet your specific needs.
Create Skill
Within the newly created skill, you’ll find several tabs, with “Build,” “Code,” and “Test” being essential for a functioning prototype of the connection between SAP and Alexa.
Feel free to explore the development possibilities within the Developer Console. There are many great Tutorials on YouTube to help you get started with Alexa development.
If you plan to publish the skill later, the “Distributions” and “Certifications” tabs will become relevant. However, for a working prototype, they are not necessary.
At this stage, we have a fully functional SAP Build Process Automation and at least one custom-built intent within our Alexa Skill. It’s time to establish the communication between these two components.
As illustrated in the architecture of the implementation, we require two Post-Requests to be implemented within the corresponding Intent Handler for the custom intent. You can directly copy and paste this code, then insert your own URLs, Client-ID, and other required details to make the code operational.
const DemoIntentHandler = {
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'Demo';
},
handle(handlerInput) {
var accessToken = {
method: 'POST',
url: 'UAA-URL',
headers: {'content-type': 'application/x-www-form-urlencoded'},
data: new URLSearchParams({
grant_type: 'client_credentials',
client_id: '',
client_secret: '',
audience: 'UAA-URL without "https://"'
})
};
return axios
.request(accessToken)
.then(function (response) {
console.log(response.data.access_token);
accessToken = response.data.access_token;
let data = JSON.stringify({
definitionId: 'Trigger-DefinitionId',
});
let trigger = {
method: 'post',
maxBodyLength: Infinity,
url:
'Trigger-URL',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`,
},
data: data,
};
axios.request(trigger)
return handlerInput.responseBuilder
.speak("Done")
.reprompt('Can I help you with something else?')
.getResponse();
})
.catch(function (error) {
console.error(error);
let speakRepromt = 'Can I help you with something else?';
return handlerInput.responseBuilder
.speak('Error occurred')
.reprompt(speakRepromt)
.getResponse();
});
},
};
The UAA-URL and client credentials can be found within the key of your SAP Build Process Automation Instance. As for the Trigger-DefinitionID and Trigger-URL, as mentioned earlier, you can locate them in the Monitor tab of the SAP Build Process Application.
At this point, you should have successfully implemented a functioning SAP Build Process Automation, created an Alexa Skill with custom intents, and established the connection between the two, enabling you to trigger automations by voice commands. Congratulations!
However, if you encounter occasional issues where your automations don’t work as expected, even though they typically do, consider checking the Desktop Agent. Sometimes, it might still be operating in the wrong mode (while developing, it’s usually in “Design Mode,” but for unattended automations, it should be in “Unattended Mode”). Additionally, if you encounter problems, it can often help to shut down and then restart the Agent completely to ensure it operates smoothly.
In this blog, I’ve provided you with a comprehensive, step-by-step guide on how to set up a one-way connection between SAP Build Process Automation and Alexa. I hope this post has sparked new ideas and possibilities for you.
If any questions have arisen or if you require further clarification on any aspect of this implementation, please don’t hesitate to leave a comment. I’ll do my best to answer as soon as possible.
If you like, please feel free to share your thoughts and feedback in the comments and follow my profile for similar content.