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

slang-grocery-assistant

v1.0.2

Published

Slang Voice Assistant for Grocery apps.

Downloads

7

Readme

Slang’s Web grocery assistant (aka SlangGroceryAssistant) is a fully trained voice assistant specialized for Web apps in the grocery domain. By integrating with this assistant, apps can help their users perform the following types of tasks through voice:

  • Search for Products.
  • Show order history.
  • Show cart.
  • checkout.

The following guide describes the steps that apps need to take in order to integrate with the assistant.

Step 1: Add the assistant to your project

Case 1: You're using npm.

Just install slang-grocery-assistant package from npm

npm install slang-grocery-assistant

or if you're using yarn:

yarn add slang-grocery-assistant

Then to bring slang into scope:

import SlangGroceryAssistant from "slang-grocery-assistant"

That's it.

Case 2: You're using script tags.

Include this in ALL the pages you want Slang Assistant to show up.

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/slang-web-sdk@2/index-iife.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/slang-grocery-assistant@1/index-iife.js"></script>

That's it.

Note: The ordering of the tags are important. The slang-web-sdk tag should come before slang-grocery-assistant tag. And likewise any code where you refer to SlangGroceryAssistant should come after both these tags.

Step 2: Add the assistant to your project

First define your actionListener

const groceryAssistantListener = {
  onGroceryItemSearch: (groceryItem) => {
    // groceryItem.name - the item the user searched for
    // search for grocery item here
  },
  onShowCart: () => {
    // show the cart
  },
  onOrderHistoryShow: () => {
    // show order history
  },
  onCheckout: () => {
    // take to checkout page
  }
};

All these functions can be async, in which case either return a promise or use async/await.

If you don't set any of these handlers, the assistant will consider the action to be unsupported and speak out the unsupported prompt if the user asks for those actions.

The action will also be considered unsupported if you set the handler and return the string UNSUPPORTED (in case of a promise, after the promise resolves).

Slang would consider the action to have failed and speak out the failure prompt in the following cases:

  • the handler returned the boolean false.
  • the handler threw an exception.
  • the handler returned a promise that got rejected.

In all other cases slang would consider the action to have succeeded, and speak out the success prompt.

NOTE: Return values will only be honoured for SPAs. For multi page applications, unsupported prompt will be spoken only in case action handler is not set for a certain action.

Then initialize slang assistant

SlangGroceryAssistant.init({
  buddyId: "<buddy_id>", // you would have gotten it from the Slang team. Required.
  apiKey: "<api_key>", // you would have gotten it from the Slang team. Required.
  groceryAssistantListener: groceryAssistantListener, // this is the listener object you defined above. Required.
  environment: "prod", // use "stage" when in development mode. Defaults to stage if omitted.
  isSpa: false, // this is a boolean flag to indicate wether it's a single page application or not. Multipage applications
                // should set this as false. Defaults to false if omitted.
});