Last active
October 10, 2017 18:08
-
-
Save horeaporutiu/a0f2bbc54a6a60d207ca0607e0dbd0a6 to your computer and use it in GitHub Desktop.
Trigger our 'translate' intent and call external API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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