GithubHelp home page GithubHelp logo

svemulapalli / apiai-nodejs-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from davidniki02/apiai-nodejs-client

0.0 2.0 0.0 607 KB

Node.js SDK for Api.ai

License: Apache License 2.0

JavaScript 93.28% TypeScript 6.72%

apiai-nodejs-client's Introduction

Fork of Node.js SDK for Api.ai - with ability to work on intents

This is a fork of the official Node.js client for Api.ai - where we have added the ability to work with intents (create, udpate, list and remove). Note that this fork requires the developer token as well - it's also suitable for other Api.ai objects that work with the developer token.

Installation

  • Install Node.js
  • Install Api.ai SDK with npm:
npm install apiai

Usage

  • Create main.js file with the following code:
var apiai = require('apiai');

var app = apiai("<your client access token>", "<your developer access token>");

function ask(text, options) {
	return new Promise((resolve, reject) => {
		var defaultOptions = {
			sessionId: '<unique session id>', // use any arbitrary id - doesn't matter
		};

		let request = app.textRequest(text, Object.assign(defaultOptions, options));

		request.on('response', (response) => {
			return resolve(response);
		});

		request.on('error', (error) => {
			return reject(error);
		});

		request.end();
	})
}

function getAllIntents(options) {
	return new Promise((resolve, reject) => {
		let request = app.intentGetRequest(options);

		request.on('response', (response) => {
			return resolve(response);
		});

		request.on('error', (error) => {
			return reject(error);
		});

		request.end();
	})
}

// ask something
ask('<Your text query>')
	.then(response => {
		console.log(response);
	}).catch(error => {
		console.log(error)
	});
	
// get list of all intents
getAllIntents()
	.then(intents => {
		console.log(intents);
	}).catch(error => {
		console.log(error)
	});
  • Run following command.
node main.js
  • Your can find more examples in samples directory.

apiai-nodejs-client's People

Contributors

coreyroach avatar davidniki02 avatar defijesus avatar gugic avatar jsalwen avatar jwbrew avatar lilia-simeonova avatar oprog avatar richardgroves avatar tiff avatar xvir avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.