Skip to content

ecrmnn/wit-keywords

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wit-keywords

Mass push values to keyword based entities on Wit.ai

Travis npm version npm downloads npm license

Installation

npm install wit-keywords --save

Usage

Push an array of actors to the actor entity

const keywords = require('wit-keywords');

new keywords(process.env.WIT_TOKEN)
  .entity('actor')
  .push([
    'Leonardo DiCaprio',
    'Steve Carell',
    'Alec Baldwin',
    'Micheal Cera'
  ])
  .then(response => console.log(response))
  .catch(err => console.log(err));

//=> [{
//=>   value: 'Leonardo DiCaprio',
//=>   status: 'added'
//=> }, {}, {}, {}]

Trigger a function after each pushed item

const keywords = require('wit-keywords');

new keywords(process.env.WIT_TOKEN)
 .entity('actor')
 .after(actor => {
   // Do something
 })
 .push([
   'Leonardo DiCaprio',
   'Steve Carell',
   'Alec Baldwin',
   'Micheal Cera'
 ]);

Trigger a function after each pushed item

const keywords = require('wit-keywords');

new keywords(process.env.WIT_TOKEN)
  .entity('actor')
  .after(actor => {
    // Do something
  })
  .push([
    'Leonardo DiCaprio',
    'Steve Carell',
    'Alec Baldwin',
    'Micheal Cera'
  ]);

Set custom number of parallel requests (concurrency)

const keywords = require('wit-keywords');

new keywords(process.env.WIT_TOKEN)
  .concurrency(4) // Default = 3
  .entity('actor')
  .after(actor => {
    // Do something
  })
  .push([
    'Leonardo DiCaprio',
    'Steve Carell',
    'Alec Baldwin',
    'Micheal Cera'
  ]);

License

MIT © Daniel Eckermann

Releases

No releases published

Packages

No packages published