AWS for Industries
Use your voice with Amazon Alexa to query data in the OSDU platform
Introduction
The Open Subsurface Data Universe (OSDU) is a standards-based data platform for the Energy industry, designed to reduce silos and put data at the center of the subsurface community. It defines a standard set of APIs and a standard set of data models towards accessing and representing data in the platform.
OSDU on AWS is a secure, reliable, cost-effective, and performant implementation of the OSDU standard. With OSDU on AWS, companies can focus on the truly differentiating parts of their business, and leave the undifferentiated heavy lifting of subsurface data management to AWS. This blog is a part of a multi-blog series focused on OSDU on AWS. Check out these blog posts to learn about authentication or searching for data in your OSDU on AWS instance.
Alexa is Amazon’s cloud-based voice service available on hundreds of millions of devices from Amazon and third-party device manufacturers. With Alexa, you can build natural voice experiences that offer customers a more intuitive way to interact with technology.
This post details how you can interact with OSDU on AWS using your voice and an Alexa-compatible device. You will soon be able to ask your Alexa-compatible phone or Echo dot questions like:
– What was my total production in the Permian last month?
– What are my best performing wells?
– How many wells were spudded in 2019?
Overview of Solution
In this post, we will use our voice to query data in OSDU on AWS. To do this, we will build an Alexa skill. Skills are like apps that help you perform voice commands on your Alexa-compatible device. Our skill will translate voice commands to text commands and pass them to an AWS Lambda function that we will define. This Lambda function will make the necessary API calls to the OSDU data platform to get results. Finally, Alexa will read out the results returned by the Lambda function. In our solution, we will use the AWS Secrets Manager to store and retrieve our OSDU platform credentials.
Prerequisites
To build and deploy the solution, you will need:
-
- An Alexa-compatible device, like the Alexa app installed on your phone or an Amazon Echo Dot.
- An Alexa Developer Account. Visit https://developer.amazon.com to get started.
- An OSDU on AWS deployment, preloaded with data. Ask your OSDU on AWS administrator for (1) deployment end-points/URL (2) Amazon Cognito “client ID” for your user pool (3) credentials to access the OSDU platform.
- Familiarity with the OSDU APIs, Alexa custom skills, and the AWS Management Console.
Solution
To build-out our solution, we will first log onto the Alexa Developer Console and program the Alexa skill [Section 1]. We will then deploy an AWS CloudFormation template to create our Lambda function, configure the Secrets Manager, and set up necessary AWS Identity and Access Management (IAM) roles [Section 2].
Section 1: Create the Alexa Skill
-
- Log into the Alexa Developer Console.
- Select ‘Create Skill.’
- Fill in the following parameters:
- Skill Name: OSDU-Alexa-App
- Default language: English
- Choose a model to add to your skill: Custom
- Choose a method to host your skill’s backend resources: Provision your own
- Select ‘Create Skill’ at the top of the page.
- On the next page, select the ‘Hello World Skill’ and select ‘Choose’ at top of the page.
- Once the resources finish provisioning, you will be directed to a main Alexa Developer Console page (shown below). On the left hand navigation pane, click on ‘Interaction Model,’ then ‘Intents,’ and select ‘JSON Editor’ from the left-hand navigation panel.
- Delete the contents of the JSON Editor and replace with the contents of the Alexa Skill JSON file. This will create the necessary intents, utterances, and slots needed to pass information into the lambda. Once finished, click ‘Save model.’
- Select ‘Endpoint’ in the left-hand navigation panel.
- Copy ‘Your Skill ID’ from the Endpoint page.
- Leave this page open. You will need to come back to it in step 16 (in Section 2).
Section 2: Deploy the CloudFormation Template
- Open the AWS Console on a new tab, and navigate to the CloudFormation main page.
- Select ‘Create Stack,’ and select ‘With new resources (standard).’
- Select ‘Template is ready’ and upload the Cloud Formation Template. Click ‘Next.’
- Specify the following stack details:
- Enter any stack name
- Pass in the necessary parameters that are associated with your OSDU on AWS deployment
- AppId: ‘Your Skill ID’ from the Alexa Developer Console in step 8
- Client ID: ID for your user pool’s application client
- Email: Username/email you will use to execute API calls to the OSDU platform
- Password: Password you will use to execute the API calls to the OSDU platform
- OSDU Platform URL: Primary endpoint that services the different OSDU APIs
- Click ‘Next.’ Under configure stack options, add in any tags you may want to use, and any other optional settings.
- Review the stack, confirming that the template will create new IAM roles. Select ‘Launch Stack.’
- Wait for the cloud formation to finish deploying. In the ‘Output’ section of the stack, copy the Lambda ARN in the output section of the CloudFormation template.
- Go back to the Alexa Developer Console and paste the Lambda ARN from step 15 into the ‘Default Region’ box. Then click ‘Save Endpoints.’
- Finally, select ‘Invocation’ on the left-hand navigation panel, and then ‘build model’ to create and deploy the Alexa skill.
So how does it work?
When the user asks Alexa a question, she converts the voice command into an intent and passes it to our Lambda function. Based on the intent, the Lambda function makes the appropriate OSDU API calls and returns the results back to Alexa.
Testing your Alexa Skill
You can test your Alexa skill with any Alexa-enabled device (such as an Amazon Echo Dot) that has been registered with the same email address you used on your Alexa developer account. If you set up your device with an account other than your developer account, reset the device and then re-register it with your developer account. Another testing option is to use the Alexa app on your mobile device.
To invoke the skill, use the wake word with your invocation name. Say, “Alexa, Open Subsurface Data Universe.” You can then ask it questions like, “How many wells are in the System?” or “How many wells were spudded in 1980?”.
Customizing Functionality
The sample code and Alexa app shows some of the functionality available through using Alexa to query the OSDU energy data platform. To expand the ability of this function to support questions/querying, simply change the methods in the Lambda function to fit the given use-case, and update the intents accordingly.
Cleanup
To avoid incurring future charges, delete the resources by deleting the CloudFormation template and the Alexa Skill.
Conclusion
This blog post details how you can use your voice to query for data in the OSDU platform. As OSDU evolves as a standard platform for energy workflows, the ability to leverage natural language search to interact with data will allow users to develop streamlined subsurface workflows focusing their time on value-add tasks, and not searching for data.