Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @voicehub/voicehub with all npm packages installed. Try it out:

var voicehub = require("@voicehub/voicehub")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@voicehub/voicehub v1.0.1

Voicehub Node.js SDK

Voicehub Logo

Voicehub Node.js SDK

What is Voicehub?

Voicehub is a content management and analytics platform for voice based apps. In its core, Voicehub lets you manage the content your voice apps sends out to your users, and combines it with extensive analytical features.

This SDK for Node.js environments lets you easily integrate Voicehub into the logic of your voice apps, which includes both Alexa Skills and Google Actions. You can use it for example in conjunction with with alexa-skills-kit and dialogflow-fulfillment-nodejs.

Examples

If you wish to see an example integration, check out our example Alexa Skill or Google Action:

Install

Voicehub is available on npm:

npm install --save @voicehub/voicehub

Require Voicehub at the top of your code and provide your App ID and API Key:

const voicehub = require('@voicehub/voicehub')('APP_ID', 'API_KEY');

Basic Usage Quick Start

The following gives you a brief overview over the capabilities of this SDK. See the full reference for all methods.

Retrieve Content

You can dynamically retrieve speech content managed on Voicehub:

/* Get a Post by its internal _id */
const post = await voicehub
    .post('post_id')
    .get();

/* Get a Post by Name */
const post = await voicehub
    .state('state_name')
    .intent('intent_name')
    .post('post_name')
    /* optionally with dynamic parameter injection */
    .withParameters({
        firstName: 'John',
    })
    .get();

/* Access a Posts Content */
const speechContent = post.myPostFieldName;

/* Access localized Content */
voicehub.setLocale('en-US');
const speechContent = post.myPostFieldName;

Filter & Manage Content

Voicehub provides functionality to schedule and tag posts. You can easily define schedules for your content on Voicehub and assign tags to it, and use this information in your voice application:

/* Get all special offers which are scheduled for today */
const posts = await voicehub
    .state('state_name')
    .intent('intent_name')
    .posts({
        scheduled: new Date(),
        tag: ['special_offer'],
    });

Manage User Data

Voicehub provides a persistent key-value store for your user data. Manage the users of your Skill or Action:

/* Create a user */
const user = await voicehub
    .user(handlerInput) // or agent object
    .findOrCreate();

/* Store information about user */
user.faveFood = 'Pizza';
user.age = 21;

/* or set whole object: */
user.set({
    faveFood: 'Pizza',
    age: 21,
});

await user.save();

/* Access user information */
console.log(user.age); // 21

Analytics

Voicehub provides you detailed analytics about the performance of your Skill or Action. Enable analytics by integrating it accordingly:

Alexa Skills
exports.handler = skillBuilder
    .addRequestHandlers(
        // your intent handlers ...
    )
    .addResponseInterceptors((req, res) => {
        voicehub.interactionInterceptor(req, res);
    })
    .lambda();
Google Actions (Dialogflow)
exports.myAction = functions.https.onRequest((request, response) => {
    const agent = new WebhookClient({ request, response });
    // Implement the analytics logger
    voicehub.actionInterceptor(agent);
    // the rest of your code ...
}

Full SDK Reference

Please find all methods in our SDK Reference.


Links:

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free