Using Amazon Alexa to Perform Voice Activated CI/CD Build and Deployments
Are you interested in learning how to apply Amazon Alexa Skills to common development tasks?
This course explains and demonstrates how to automate the process of building, testing, and deploying a Java project to the cloud using Amazon Alexa Skills with Continuous Integration and Continuous Delivery (CI/CD).
This content will help you gain an understanding of core CI/CD concepts. We start by covering aspects of CI/CD process automation using tools provided by AWS, Jenkins, Blue Ocean and Maven. We then gain the skills needed to automate the process of building, testing, and deploying a Java project to the cloud using Amazon Alexa Skills. We learn how to do this by integrating the Alexa Skills Kit (ASK) with AWS services like Lambda and Elastic Beanstalk.
- Recognize and explain core concepts of Continuous Integration and Continuous Delivery (CI/CD)
- Recognize and work with Jenkins Pipeline and Blue Ocean
- Extend Amazon Alexa by developing a custom Alexa Skill using the Alexa Skills Kit (ASK)
- Integrate Alexa with other AWS services like Lambda and Elastic Beanstalk
Software Developers, Build and Release Engineers, Alexa Enthusiasts.
To get the most from this content we recommend you have an understanding of the following areas
- Basic knowledge of the principles of software engineering and development
- Basic knowledge of Amazon Web Services (AWS) and an AWS account
- Basic knowledge of Continuous Integration/Continuous Delivery (CI/CD)
- Basic knowledge of the Alexa Voice Service (AVS)
We welcome all feedback on content please reach out to us at email@example.com with any questions or comments.
Alexa, named after the ancient library of Alexandria, is Amazon's AI-powered voice assistant that runs in a cloud. The echo device is used to communicate with Alexa, Alexa is also known as the Alexa Voice Service. So how does she work? The echo device listens for the wake word. For example, Alexa, echo, computer, or Amazon, which employs deep learning technology running on the device, to recognize the wake word the user has chosen. Once the wake word is detected, what you say is recorded and sent to the Alexa Voice Service, which uses speech-to-text and natural language understanding, NLU, to identify your intent. Based on the intent, the correct skill is chosen. In this case, the DevOps Pal skill. Based on your intent, the skill acts accordingly, kicking off our Jenkins pipeline, and then sends a response back to the user, using text to speech synthesis, which converts the response to something that is natural sounding to you. Let's walk through the voice-user interface for the DevOps Pal skill. If you're familiar with full stack web development, this is like a front end for the skill. I've navigated here to the Alexa developer portal. And now let's look more closely at my DevOps pal skill. So let's click on the name.
So this is the configuration console for DevOps Pal. So let's look at the components that comprise an Alexa skill. First is the invocation name, which you can think of as your app name, and it's how users launch your skill. So here, the invocation name for my skill is DevOps Pal. Now, there are some requirements shown here around an invocation name. So for example, the name should be two or more words and can contain only lowercase alphabetic characters, etc. Now, let's look at intents. Intents are phrases that a user says to talk to or interact with your skill. The most important one here is deploy code intent. And there are several built in intents, like help, stop, cancel, fall back, etc., provided by Amazon. To deploy code intent is a custom intent that I've created. And so I've gone through and listed all of the different ways that a user may invoke my skill. So for example, a user may say, run my Jenkins pipeline or, run my Jenkins jobs or, deploy the code, deploy code, or deploy. And down here, we have slots. Now slots are like parameters that you pass to your skill. In this case, I'm not passing any parameters, but in the future, the skill could be updated to take the job name, and in that case, I would pass that in as a slot. And notice here we are on the build tab. There's also a test tab. So this allows you to test your skill via a simulator. So in order to test, you do not actually need an Echo device, although I would recommend it, you can use the simulator to test. So in this case, I would say, open DevOps Pal.
Welcome to DevOps Pal. I can launch your Jenkins pipeline. Start by saying, deploy my code.
And then I would say, deploy my code.
Your code is being deployed. You can check the status via your Jenkins Blue Ocean pipeline page.
- [Instructor] Now, notice here on the left side, we see the JSON input that goes through the back end portion of the skill for fulfillment. Now, the most important piece of this, notice down here, on line 54, we're giving it the intent name, in this case, deploy code intent. And then notice on the right-hand side, we see the JSON response from the back-end portion of the skill. In this case, it's saying, your code is being deployed, you can check your status through your Jenkins Blue Ocean pipeline page. Now that we've seen the front-end portion of our skill, let's take a look at the back-end portion of our skill. So I've navigated to the AWS Lambda console and opened the Alexa CI/CD function. The source code for this can be found in GitHub. So let's walk through the Lambda code. I authored this in Python, and this Lambda serves as the back-end business logic for the skill. So if you're familiar with full stack web development, this is like the back-end portion of the skill. Notice the Lambda is triggered through Alexa, shown here, the Alexa skills kit. So let's scroll down and look at the code. So first, let's navigate down to line 147. So here, on line 147, this is the main handler for the function or the entry point. So let's walk through the code flow when the user evokes the deploy code intent by saying, deploy my code. So that will go down to line 169 because we are invoking an intent. So it will pass in more information about the event and the context to the on intent function. So now let's look at the on intent function. That's found on line 114; here it is, the on intent function on line 114. Notice, here on line 124, it's checking the user's intent. So if it is deployed code intent, then it's going to call this deploy code intent function. So let's go there, and that's on line 71. So here we have the deploy code intent, and notice here, on line 77, this is the speech output. So this is what Alexa says to the user. Now, on line 80, I'm creating an HTTP connection by passing in a domain name and a port for the Jenkins API that I'm going to call to trigger the build.
For the Jenkins API, basic authentication is required. So here, on line 81, I'm base 64 encoding the username and password, and then I'm adding it to the header, here on line 82. And then down on line 84, I'm making a post, and sending in the Jenkins build URL, for the Alexa CI/CD job, and getting back a response here, on line 85. So the Lambda uses the Jenkins API to invoke the build, and we can then go to the Blue Ocean interface and watch the progress of the build. Alexa for business allows developers to use the Alexa Skills Kit to publish private skills for workplace empowerment. Private skills don't appear in the public Alexa skills store, they don't go through a certification process, and are only available to select organizations. Let's walk through setting up an Alexa for business skill and enabling select locations. The first step is to go to your Alexa developer portal and open your skill. So we're looking at the DevOps Pal skill. Now, once your skill is published, you can enable it for organizations you select. So in order to do that, navigate to the distribution tab. And everything here is read-only because the skill is live. Click on availability, and notice, there's an Alexa for business organization section.
So in order to give an organization access to your private skill, you enter the organization's ARN here. So let's close this. If you notice, right now, DevOps Pal is enabled for one organization. At any point, I could go in and revoke access. So now, as the organization that has access to this skill, let's navigate to the Alexa for business page. So here, I'm on the AWS management console, and I'm going to open Alexa for business. So this is the dashboard, and notice that there's an option called skills. Now you see that this organization has one skill enabled, and it's DevOps Pal. So all private skills that are available to the organization will appear on the private skills tab, right now there's only one, and then also, the organization can enable skills from the Alexa skills store. So any enabled skill appears here, on the enabled skills tab. Now that we've learned more about Alexa, let's look at connecting Alexa to the CI/CD pipeline.
Kesha Williams (pronounced KEY-SHA) is an award-winning software engineering manager with over 20 years’ experience. She's passionate about emerging technologies, speaking, teaching, and mentoring. She's trained thousands of software engineers in the US, Europe, and Asia while teaching at the university level. She routinely leads innovation teams in proving out emerging technologies and shares her learnings at technical conferences around the globe. She recently won the Ada Lovelace Award in Computer Engineering from Look Far and the Think Different Innovation Award from Chick-fil-A for her work with Artificial Intelligence (AI). She was recently featured in Amazon's "Alexa Women of Voice" campaign and named an Alexa Champion. In her spare time, she leads the Georgia chapter of Technovation, writes news for InfoQ, authors video courses, and mentors women in tech.
To learn more about me, visit my website at http://www.kesha.tech