@chitchatjs/alexa
v0.3.13
Published
A Javascript framework to build Alexa Skills expriences easily.
Downloads
96
Readme
@chitchatjs/alexa
🤖 JavaScript framework for building voice user interfaces for Alexa Skills. | 📄 Read the documentation
| Package | NPM | Build | | -------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | | @chitchatjs/cli | | | | @chitchatjs/alexa | | | | @chitchatjs/core | | |
Get in touch
Prerequisites
Chitchat requires the following dependencies:
Installation
npm i @chitchatjs/alexa --save
Writing a simple skill
To get started, simply write this in your index.ts
import { ax } from "@chitchatjs/alexa";
let state = ax.start().block(ax.say("Hello world")).build();
// create our skill using the state above
let skill = ax.skill().addState(state).build();
exports = ax.dialogManager(skill).exports();
Output:
U: open <skill-name>
A: Hello world
Let's add a dialog turn to ask user their name:
let state = ax
.start()
.block(
ax
.compound()
.add(ax.whenLaunch().then(ax.ask("Hello, what is your name?").build()).build())
.add(
ax
.whenUserSays(["my name is {name}"])
.withSlotType("name", builtins.SlotType.FirstName)
.then(ax.say("Welcome, {name}! It's nice to talk to you."))
.build()
)
.build()
)
.build();
Output:
U: open <skill name>
A: Hello, what is your name?
U: my name is kevindra
A: Welcome, kevindra! It's nice to talk to you.
Build and deploy using ChitchatJS CLI:
> tsc
> cjs build
> cjs deploy
That's it!
Deploy to your stack using code
Wrap this in your stack module and deploy as code:
const handler = ax.dialogManager(skill).handler();
AWS Lambda
import { Function, Runtime, AssetCode, Code } from "@aws-cdk/aws-lambda";
// ...
this.lambdaFunction = new Function(this, props.functionName, {
functionName: props.functionName,
handler: "handler.handler",
runtime: Runtime.NODEJS_10_X,
code: new AssetCode(`./src`), // points to your skill module
memorySize: 512,
timeout: Duration.seconds(10),
});
Express JS
import * as express from "express";
import skill from "./src/skill";
const app = express();
const port = 3000;
app.get("/", skill.express());
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});
Packages
Sample Skills
Plugins
- @chitchatjs/plugin-ax-common
- @chitchatjs/plugin-ax-session
- @chitchatjs/plugin-ax-display
- @chitchatjs/plugin-ax-card
Check the official documentation of available building blocks and much more here - https://chitchat.js.org/