Skip to content

Instantly share code, notes, and snippets.

@melissamcewen
Last active September 21, 2016 20:37
Show Gist options
  • Save melissamcewen/ba3107c22df73f7da817efa4690ff0bb to your computer and use it in GitHub Desktop.
Save melissamcewen/ba3107c22df73f7da817efa4690ff0bb to your computer and use it in GitHub Desktop.
Wit.ai figuring out slotting
findRestaurant({context,entities}) {
return new Promise(function(resolve, reject) {
var cuisine = firstEntityValue(entities, 'cuisine');
var neighborhood = firstEntityValue(entities, 'neighborhood');
console.log('cuisine:' + cuisine);
console.log('neighborhood:' + neighborhood);
if (cuisine && neighborhood) {
console.log('both cuisine and neighborhood present');
} else if (neighborhood) {
context.neighborhood = neighborhood;
} else {
context.cuisine = cuisine;
}
console.log(JSON.stringify(context));
//call the API here
return resolve(context);
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment