npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vui-advanced-utterances

v1.1.6

Published

Advanced utterances for VUI applications. Supports hierarchical alternatives, unfolding, and duplicate detection. Uses vui-custom-values-with-synonyms npm package.

Downloads

5

Readme

vui-advanced-utterances

npm module that provides ability to add VUI utterance generation functionality to any javascript object.

Repository

This module as well as related vui modules can be found here: https://github.com/RationalAnimal

Installation

	npm install vui-advanced-utterances --save

or, if you don't want to run unit tests on it:

	npm install vui-advanced-utterances --save --production

Summary

This project provides an npm module to add VUI utterance generation functionality to any javascript object. Once this functionality is added then the utterances can be added. Then you can generate utterances directly from code for import into, for example, Amazon Alexa console when defining a skill.

While the primary purpose is to add this functionality to other VUI related objects, this is NOT necessary and is purely driven by usefulness. Most of these functions can be added to ANY object and they don't require that the target class has anything to do with VUI. However, if you wish to use custom slot types unfolding then you must use these functions with objects that understand intents and custom slot values.

Examples

Simple string

To generate a simple utterance string simply pass that string in:

var utterances = require("vui-advanced-utterances");
var app = {};
utterances.addUtterancesToApp(app);
var result = app.unfoldUtteranceString("simple string");
console.log(result);

will produce:

simple string

Named Slot

To generate an utterance string that contains a named slot in it simply pass in that string with the slot name in {}:

var utterances = require("vui-advanced-utterances");
var app = {};
utterances.addUtterancesToApp(app);
var result = app.unfoldUtteranceString("simple string containing {MySlotName} in it");
console.log(result);

will produce:

simple string containing {MySlotName} in it

Unfolded Custom Slot

To include custom slot type values in an utterance simply pass in a string with the custom type name in {+ }:

var utterances = require("vui-advanced-utterances");
var synonyms = require("vui-custom-values-with-synonyms");

var app = {};
utterances.addUtterancesToApp(app);
synonyms.addSynonymsToApp(app);
app.addCustomSlot("fruit",
	{values: [
		{
			text: "apple"
		},
		{
			text: "golden delicious",
			mapTo: "apple"
		},
		{
			text: "banana"
		}
	]}
);
var result = app.unfoldUtteranceString("simple string containing {+fruit} in it");
console.log(result);

will produce:

simple string containing apple in it
simple string containing golden delicious in it
simple string containing banana in it

Evaluated javascript

To generate an utterance string that contains value(s) obtained by evaluating javascript simply pass in the javascript to be evaluated enclosed in {= }. The javascript must evaluate to a string or an array of strings and must not contain { or }:

var utterances = require("vui-advanced-utterances");
var app = {};
utterances.addUtterancesToApp(app);
var result = app.unfoldUtteranceString("simple string containing {=new Date().toString()} in it");
console.log(result);

will produce:

simple string containing Fri Feb 03 2017 16:45:12 GMT-0500 (EST) in it

Note that if the expression inside {= } produces an array of strings, it will be treated as if you've included an options list, i.e. {option|option|option...}

Option list

To generate a list of utterance strings that differ only in inclusion of different options simply pass in that string with the options in {} separated by | :

var utterances = require("vui-advanced-utterances");
var app = {};
utterances.addUtterancesToApp(app);
var result = app.unfoldUtteranceString("simple string containing {blue pill|red pill} in it");
console.log(result);

will produce:

simple string containing blue pill in it
simple string containing red pill in it

Nested specifications

If you want to, you can include (nest) various special expressions within the others that allow it (e.g. option list):

"{option 1|{=['option 2','option 3']}|{Option4Slot}}"

will produce:

option 1
option 2
option 3
{Option4Slot}

Validate utterances

You can validate your utterances by calling

var app = {};
utterances.addUtterancesToApp(app);
synonyms.addSynonymsToApp(app);

var result = app.validateUtterances(["simple one liner", "simple string with an option list that has {my|option|list} in it"]);
console.log(result);

result = app.validateUtterances(["simple one liner", "simple string with an option list that has {my|option|list} in it", "simple one liner"]);
console.log(result);

will produce:

true
utterances contain duplicates, e.g.: simple one liner
false

Intent utterances

To generate the text suitable for uploading to Alexa development console use unfoldIntentUtteranceStrings() function, passing to it the name of the Intent and the array of utterances to be unfolded.

var utterances = require("vui-advanced-utterances");
var platforms = require("vui-platforms");
var app = {};
utterances.addUtterancesToApp(app);

var result = app.unfoldIntentUtteranceStrings("SampleIntent", ["simple one liner", "simple string with an option list that has {my|option|list} in it"], platforms.ALEXA);
console.log(result);

will produce:

SampleIntent simple one liner
SampleIntent simple string with an option list that has my in it
SampleIntent simple string with an option list that has option in it
SampleIntent simple string with an option list that has list in it