Alexa Skill Tutorial: How To Write Your First Voice-assistant App

Đã đăng vào - Cập Nhật Lần Cuối vào

Alexa, an artificial intelligent virtual assistant, can perform numerous tasks if an individual asks it to. Alexa’s skill is comparable to a web based application that individuals can interact with. This application has a back end and a front end. The latter is the hardware which facilitates communication (through speech, as opposed to typing) between users and the application. The developers of Alexa incorporate their developer console in building code for its voice interface, instead of CSS and HTML on an interconnection server.

Setting Alexa Skills

The front end mainly consists of the setup. However, Alexa requires backend code to efficiently respond to requests. While any HTTPS interconnection service can host a back end, code writing and hosting takes place on a framework or SDK (Software Development Kit) during the earlier stages. SDK Alexa skills kit from Amazon is available for both Java and JavaScript. AWS Lambda focuses on C#, and then there is Flask-Ask which is a Python micro framework. The advantage of AWS Lambda is that developers can host their skills free of charge.

In order to effectively use Alexa, users will need to go through various steps as seen in this comprehensive article.

Step 1: Create an Alexa skills template

Using a template gives users the convenience of modifying it to ensure it responds to anything they want it to do. While there are various templates you can use, the team-lookup skill remains among the most prevalent. It makes it possible for users to make simple requests, such as finding a friend’s twitter handle.

Users can also customize it to accommodate more corporate requests. These skills are exclusive to gadgets connected to the user’s Amazon account, which means they can build a private home Alexa phone directory. Better still; users can develop a departmental directory exclusive to the gadgets connected to the corporate account.

Step 2: Creating AWS & developer accounts

Users should create AWS (Amazon Web Services) and ADC (Amazon Developer Console) accounts. While these are free, users should indicate credit card information for the existing account. For non JavaScript developers, they will need to download and install Node.js from its website. It is important to make sure the installation has the Node package manager which comes in handy when creating complex skills.

Are you looking for a professional and experienced developer? Choose one from a reputable freelancing site.

Step 3: Get the Alexa skills template code

Proceed to the GitHub repository on Amazon and download team-lookup code. Individuals who do not have Git on their systems can download it from GitHub. Those who already have Git can download team-lookup code here.

After downloading, users will need to manually unzip the team-lookup code. The file contains critical subdirectories which are src, speech-assets, and a step by step manual to assist in creating the skill. The front end code is in the speech-assets folder. It contains the interaction-model.json file which enables users to understand how to communicate with Alexa when making requests. Users should feed this code into the developer console. The back end code is in the src folder. This plays the role of managing user requests. Users should sync it with the AWS Lambda afterwards.

Step 4: Launch the Alexa skill in the developer console

Login to ADC (Amazon Developer Console). From the navigation option, click Alexa and select “Get started for Alexa Skills Kit.” Then click on “Add a New Skill” which is on the top right side of the page. This prompts the launch of a new skill.

For the language option, select British English, German, or American English. For the Custom Interaction Model, maintain Skill Type as the default. Users will then need to define an invocation Name.

The chosen Name shall appear in the Amazon’s skill directory upon publication. It will also show in the individual’s Alexa apps. Basically, an Invocation Name defines what users say to prompt the skill. It is important to choose an easy invocation name in order to make it convenient for the users. While invocation words should contain two words, they shouldn’t have any Alexa’s launch commands, such as tell or ask. Going through this guideline can help individuals develop an ideal invocation Name.

Finally, click to save, and then choose between using the recently launched graphical skill developer Beta and the old version. The former is good as it comes with a code editor, while using the latter is a little tedious.

Step 5: Developing Alexa skill’s voice-interface variables

Use a text editor to access the interaction-model. json file. This reveals the JSON file, complete with over 300 tiers that describe slots, intents and adequate values. In order to make the JSON file user-friendly, users can customize the intents, slots, and adequate values according to their level of skill.

This procedure changes when users choose to use a template. It is advisable to create it according to its initial format. Again, ensure it runs appropriately before modifying the code. Below is a guide on how to create team look-up skill to discover Alexa evangelists.

  • Delete the default text by clicking Code Editor.

  • Copy the contents of the interaction-model.json. Drag and drop, or paste them in the code editor.

  • Click to apply the changes, then save. Click on Build model option. This takes close to two minutes to happen.

  • Click Dashboard link. This reveals 5 custom and 7 inbuilt intents, and 4 custom and 2 inbuilt slots.

Step 6: Link the Lambda back end for the Alexa skill

Click the configuration button. This should close the Skill Developer Beta and open the configuration page based on their skill as stipulated on the developer console. Users should now create the back end, and link it to their skill descriptions. It is important to keep AWS and ADC open on different tabs. From the user’s console page, they should be able to view a specific geographical area; for instance, N. Virginia. That is the data center which hosts Alexa skill.

From the Lambda service, click on “Create Function” and choose alexa-skill-kit-sdk-factskill. To avoid difficulties maneuvering through the Lambda prompt development interface, click on the blank square to reveal a drop down list. Select Alexa skills set, and click next. Users will need to type a name to define the back end logic’s title based on their skill. The default should be the displayed Node.js. Users do not necessarily have to incorporate their skill name within their function name. However, it can come in handy to help them code numerous skills easily.

Users will then proceed to the Lambda function code area where a default code is. Remove it and insert the function code found in the team lookup template. Insert the index.js code in the Lambda function code box. Users should leave Edit code Inline to be the code entry choice. This code requires permission in order to perform functions.

Assuming users are building their inaugural Alexa skill, they should create an Alexa function. To do this, find the Lambda function handler and select index.handler. On the role option, select “Create a Custom Role” A new pop up window prompts users to build the new IAM (Identity & Access Management) role.

Select lambda_basic_execution as the IAM defaults. Policy name should be Create a new role policy. Click allow. This should revert to the last page. Choose lamba_basic_execution and an already existing function. Click next to reveal all the Lambda functions. Scroll down and click on “Create Function.” Copy the Amazon Resource Number beginning from arn:aws all through to the function’s name. Omit the ARS. Revert to ADC. Click radio option from Global fields at the endpoint & service endpoint type. Paste the number on the default group, include the geographical option, and post the ARN code on the subsequent text box. Click save.

Step 7: Testing the Alexa Skill

Test to see that any Alexa gadget linked on the existing Amazon account is displaying the directory skill. Speak the word “open”, and follow it with the skill’s name.

To carry out a voice test without Alexa hardware, use interconnection powered third party testing equipment. The user’s Alexa account should have a link to the service.

Step 8: Tailor make the Alexa skill

Users should strive to maintain the default configurations of the Alexa skill. However, sometimes they may want to incorporate their data and modify various Alexa response phrases.

Step 9: Publish the Alexa skill

Users may choose to publish their skill, or not. For those who choose to, they can access publishing guidelines from the information page. It is important to note that broadcast skills should contain long and short skill descriptions, large and small images, and sample utterances.

Finally

Many individuals today adopt Alexa skills due to the convenience and ease of use.

Do you have any more points to share? Leave us a comment on the comment section.

 

Đã đăng 18 tháng 11, 2017

LucyKarinsky

Software Developer

Lucy is the Development & Programming Correspondent for Freelancer.com. She is currently based in Sydney.

Bài báo kế tiếp

What’s In Store For The Next Java