Skip to content

Instantly share code, notes, and snippets.

@horeaporutiu
Last active October 10, 2017 18:08
Show Gist options
  • Save horeaporutiu/a0f2bbc54a6a60d207ca0607e0dbd0a6 to your computer and use it in GitHub Desktop.
Save horeaporutiu/a0f2bbc54a6a60d207ca0607e0dbd0a6 to your computer and use it in GitHub Desktop.
Trigger our 'translate' intent and call external API
var context = {};
conversation.message({
workspace_id: "your workspace id",
input: {"text": "translate this phrase."},
context: context
}, function(err, response) {
if (err)
console.log("error:", err);
else {
console.log(response)
if (response.intents.length > 0 && response.intents[0].intent === "translate") {
translate(response.input.text).then(function(translatedResopnse) {
response.output.text = translatedResopnse
console.log(JSON.stringify(response,null,2))
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment