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

@speechly/js-config-api

v0.1.5

Published

A library for accessing the Speechly Config API

Downloads

4

Readme

Javascript Library for Speechly Config API

With this library you can create and deploy simple Speechly voice-search applications from within a (server-side) Javascript program.

Installation

The gRPC libraries (@grpc/grpc-js and google-protobuf) are declared as peer dependencies, meaning that they need to be installed separately in the main package.

npm install --save @grpc/grpc-js google-protobuf

Usage

You must first obtain a Speechly API token by following the instructions at https://docs.speechly.com/dev-tools/command-line-client/#adding-an-api-token.

Then, you can copy-paste the API token to the example script below. Running the script will first create a new application, and then deploy a simple example configuration. The script initiates deployment and returns immediately, please check the Speechly Dashboard to see when deployment is complete. Then, you can try out the application with the Speechly Playground. It supports utterances such as

  • show me blue jackets
  • can i see shirts by adidas in size large

The resulting application also has the default entity max_price for setting a maximum price, as well as the intent clear for re-setting the filters. These can be used as follows:

  • show me blue jackets not costing more than two hundred dollars
  • maximum price fifty dollars
  • clear all filters
  • reset
const { setupConnection, createApplication, deployApplication } = require("@speechly/js-config-api");

(async () => {
  try {
    const token = YOUR_API_TOKEN_HERE;

    // Establishes connection to the Speechly Config API.
    // The token must be a valid Speechly API token obtained from the
    // Speechly Dashboard.
    const conn = setupConnection(token);

    // Create a new application. It is enough to call this once.
    // After the application has been set up, all subsequent
    // calls to either createApplication or deployApplication
    // target the same application id.
    //
    // Here conn must be a connection object returned by setupConnection.
    // The function returns the Speechly app_id in question.
    const app_id = await createApplication(conn);

    // Define a simple example configuration that maps a list of possible
    // values for all supported entity types. Values must be given as a
    // list of Strings. The keys listed below are the ones supported.
    // None of the keys is mandatory, any subset thereof can be used.
    const co = {"category": ["jackets", "shirts"],
                "brand": ["nike", "adidas"],
                "color": ["blue", "red", "green"],
                "size": ["small", "medium", "large"]};

    // Deploy the configuration specified above.
    // Note that this only initates deployment. The function returns
    // once deployment has started. To see when deployment is complete,
    // please log on to the Speechly Dashboard.
    //
    // Here conn must be a connection object returned by setupConnectionm
    // and co a dictionary object as defined above.
    await deployApplication(conn, co);
  } catch (err) {
    console.error(err);
  }
})();

Specifying the configuration

The configuration is a simple Javascript object that maps a list of possible values (must be strings) to each entity name as shown in the code example above. There is no upper limit to the number of possible values for each entity type.

The configuration supports five entity types:

  • category: the type of the product (e.g. jackets, shirts, shoes, etc)
  • brand: product brand
  • color: product color
  • size: product size These are all optional, meaning it is possible to use a configuration that only uses a subset of the entity types.