Skip to content
Node.js SDK for Voicehub API (Alexa Skills & Google Actions)
Branch: master
Clone or download

README.md

Voicehub Logo

Voicehub Node.js SDK

Node.js SDK for using Voicehub in Alexa Skills & Google Actions

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('some_internal_post_id')
	.get();

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

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

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

Manage 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 you Voicehub. 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:

You can’t perform that action at this time.