How to use the node-wit.captureTextIntent function in node-wit

To help you get started, we’ve selected a few node-wit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Donna-ai / Donna / src / plugins / wit-ai.js View on Github external
var err = new Error('Wit.ai is not setup.'+
                              'Could not find access token.');
            donna.logger.warn(err);
            return cb(err);
        }

        // Get textual form of input
        var data = input.getData();

        // Data Types are unique and each have their own
        // specific object format.
        // In this case, a 'text' data type is a simple
        // object with the field 'text'.
        var text = data.text; // Extract text format from data

        wit.captureTextIntent(accessToken, text, function (err, res) {
            // console.log("Response from Wit for text input: ", res);
            if (err) {
                cb(err)
            } else {
                var outcomes = res.outcomes;
                // Iterate thru all intents in response
                var intents = [];
                for (var i = 0, len=outcomes.length; i
github issmirnov / calhacks2014 / main.js View on Github external
function listen(phrase) {
  light(LED1, 1);
  console.log('Sending phrase: "'+ phrase +'" to Wit.AI');
  wit.captureTextIntent(ACCESS_TOKEN, phrase, function (err, res) {
      //console.log("Response from Wit for text input: ");
      if (err) {
        console.log("Wit.AI error: ", err);
      } else {
          console.log(JSON.stringify(res, null, " "));
          processWit(res);
      }
  });
  light(LED1, 1);
}
github seanbae / jarvis / routes / index.js View on Github external
router.post('/api/v1/intent', function(req, res) {
	var query = req.body.query;

	wit.captureTextIntent(ACCESS_TOKEN, query, function (err, response) {
		console.log('Response from Wit:');
		if (err) {
			console.log('Error: ', err);
			return;
		}

		if (response['outcomes'].length == 0) {
			console.log('Invalid Wit.ai response');
			return;
		}

		var result = response['outcomes'][0];

		res.send(result);
	});
});
github facebookarchive / node-app-demo / index.js View on Github external
var wit = require('node-wit');
var fs = require('fs');
var ACCESS_TOKEN = "IQ77NWUPUMNBYEUEKRTWU3VDR5YSLHTA";

console.log("Sending text & audio to Wit.AI");

wit.captureTextIntent(ACCESS_TOKEN, "Hello world", function (err, res) {
    console.log("Response from Wit for text input: ");
    if (err) console.log("Error: ", err);
    console.log(JSON.stringify(res, null, " "));
});

var stream = fs.createReadStream('sample.wav');
wit.captureSpeechIntent(ACCESS_TOKEN, stream, "audio/wav", function (err, res) {
    console.log("Response from Wit for audio stream: ");
    if (err) console.log("Error: ", err);
    console.log(JSON.stringify(res, null, " "));
});
github howdyai / botkit-middleware-witai / src / botkit-middleware-witai.js View on Github external
middleware.receive = function(bot, message, next) {
        if (message.text) {
            wit.captureTextIntent(config.token, message.text, function(err, res) {
                if (err) {
                    next(err);
                } else {
                    console.log(JSON.stringify(res));
                    message.intents = res.outcomes;
                    next();
                }
            });
        }
        else if (message.attachments) {
            message.intents = [];
            next();
        }

    };

node-wit

Wit.ai Node.js SDK

Unrecognized
Latest version published 1 year ago

Package Health Score

57 / 100
Full package analysis