skill-sample-nodejs-adventure-game
Build An Alexa Gamebook Skill
This Alexa sample skill is a template for a basic gamebook skill. Provided with a branching text adventure from the Twine 2 platform, Alexa will let you play a game.
If this is your first time here, you’re new to Alexa Skills Development, or you’re looking for more detailed instructions, click the Get Started button below:
Be sure to take a look at the Additional Resources at the bottom of this page!
About
Note: The rest of this readme assumes you have your developer environment ready to go and that you have some familiarity with CLI (Command Line Interface) Tools, AWS, and the ASK Developer Portal. If not, click here for a more detailed walkthrough.
Usage
Alexa, ask Text Adventure where am I?
>> You are in the main hall of a large castle. Heavy tapestries hang from the walls...
Alexa, start Text Adventure
>> You're in a small office, there is a door to your left...
Repository Contents
-
/.ask
– ASK CLI (Command Line Interface) configuration -
/instructions
– Step-by-step instructions for getting started -
/lambda/custom
– Back-end logic for the Alexa Skill hosted on AWS Lambda -
/models/en-US.json
– ASK CLI interaction model for US English -
skill.json
– Skill Manifest
Setup w/ ASK CLI
Pre-requisites
- Node.js (> v4.3)
- Register for an AWS Account
- Register for an Amazon Developer Account
- Install and setup ASK CLI
Installation
-
Clone the repository.
$ git clone https://github.com/alexa/skill-sample-gamebook/
-
Initialize the ASK CLI by navigating into the repository and running npm command:
ask init
. Follow the prompts.$ cd skill-sample-gamebook $ ask init
-
Install npm dependencies by navigating into the
lambda/custom
directory and running the npm command:npm install
$ cd lambda/custom $ npm install
Deployment
ASK CLI will create the skill and the Lambda function for you. The Lambda function will be created in us-east-1 (Northern Virginia)
by default.
-
Deploy the skill and the Lambda function in one step by running the following command:
$ ask deploy
Testing
- Log in to the Alexa Developer Console, open your skill, and from the Test tab enable the Test switch.
-
Simulate verbal interaction with your skill through the command line using the following example:
$ ask simulate -l en-US -t "start Text Adventure"
✓ Simulation created for simulation id: 4a7a9ed8-94b2-40c0-b3bd-fb63d9887fa7 ◡ Waiting for simulation response{ “status”: “SUCCESSFUL”, …
-
With the Test switch enabled, your skill can also be tested on devices associated with your developer account. Speak to Alexa through any enabled physical device, through your browser with echosim.io, or through your Amazon Mobile App and say:
start Text Adventure
Customization
-
Amend
./skill.json
Change the skill name, example phrase, icons, testing instructions, etc …
Remember that interaction models are locale-specific and must be changed for each locale (en-US, en-GB, de-DE, etc.).
See the Skill Manifest Documentation for more information. -
Amend
./lambda/custom/index.js
Modify messages, and facts from the source code to customize the skill. -
Amend
./models/*.json
Change the model definition to replace the invocation name and the sample phrase for each intent. Repeat the operation for each locale you are planning to support. -
Open the Twine 2 online editor
Twine 2 is a text adventure authoring platform. It is capable of creating quite complex standalone games using variables and plug-ins. For our purposes we use it to create a simple text-and-choice-based branching game.
Note that we are not using Twine variables. We leave this as a programming task for any enthused developers.
You can use the online editor or download and install it as a desktop app.
We aren’t going to teach you how to use Twine here, but if you import the sample game it will give you a head-start.
Later, when you are developing your own Alexa skills, remember that Twine can be very useful for designing voice interaction flows. -
Import and play the sample game
In the main right-hand menu click on Import From File.
Import the sample game [Escape the Office.html](../lambda/custom/Escape the Office.html)
Additional Resources
Community
- Our team of evangelists run online office hours every Tuesday from 1-2pm Pacific Time.
- Amazon Developer Forums – Join the conversation!
- Hackster.io – See what others are building with Alexa.
- Alexa Developers Slack Channel – Chat with other Alexa developers. This is not an official Amazon channel.
Tutorials & Guides
- Voice Design Guide – A great resource for learning conversational and voice user interface design.
- CodeAcademy: Learn Alexa – Learn how to build an Alexa Skill from within your browser with this beginner friendly tutorial on CodeAcademy!
Documentation
- Official Alexa Skills Kit Node.js SDK – The Official Node.js SDK Documentation
- Official Alexa Skills Kit Documentation – Official Alexa Skills Kit Documentation