@chitchatjs/alexa
TypeScript icon, indicating that this package has built-in type declarations

0.3.13 • Public • Published

@chitchatjs/alexa

🤖 JavaScript framework for building voice user interfaces for Alexa Skills. | 📄 Read the documentation

Package NPM Build
@chitchatjs/cli npm version Build Status
@chitchatjs/alexa npm version Build Status
@chitchatjs/core npm version Build Status

Get in touch

gitter

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

  1. chitchat.js core library
  2. chitchat.js alexa library
  3. chitchat.js cli

Sample Skills

  1. Hello bot
  2. Dog Matcher
  3. High log game
  4. Coffee shop
  5. Workout Buddy

Plugins

  1. @chitchatjs/plugin-ax-common
  2. @chitchatjs/plugin-ax-session
  3. @chitchatjs/plugin-ax-display
  4. @chitchatjs/plugin-ax-card

Check the official documentation of available building blocks and much more here - https://chitchat.js.org/

Package Sidebar

Install

npm i @chitchatjs/alexa

Weekly Downloads

1

Version

0.3.13

License

ISC

Unpacked Size

144 kB

Total Files

67

Last publish

Collaborators

  • kevindra