conversation-with-discovery
总结:
你可以在
workspace
,对发现的呼吁是
动作变量
call_discovery
"action":{"call_discovery: ""}
基本上,对名称有一个意图
out_of_scope
if
将
发生
{
"context": {
"callDiscovery": true
},
"output": {
"text": {
"values": [
"Wait for the response, I'll check out."
],
"selection_policy": "sequential"
}
}
}
上下文变量(示例:
"callDiscovery": true
)
updateMessage
内部
conversation-simple
例子:
function updateMessage(input, response) {
var callDiscovery ;
if (!response.output) {
response.output = {};
//THE CONTEXT VARIABLE callDiscovery
} else if (response.context.callDiscovery === true){
//CREATE ONE NEW FUNCTION WITH YOUR CODE
getMyBody(url, callback, response); //response parameter for send the message
}
}
在你的功能中
getMyBody
id, text, url, etc
]),您需要向用户发送消息,例如:
url2 = 'fakeURL'
var request = require("request");
var myJSON = require("JSON");
var body1;
function getMyBody(url, callback, response) {
request(
{
url: url,
auth: {'user': 'fakeUsername','pass': 'fakePassword'},
json: true
},
function (error, response, body) {
if (error || response.statusCode !== 200) {
return callback(error || {statusCode: response.statusCode});
}
else{
callback(null, JSON.parse(JSON.stringify(body.results)));
}
});
}
getMyBody(url2, function test8(err, body) {
body1 = body[0];
console.log(body1);
var sendMessage = ("I've find this results: "+ body1.text + "And you can see the url: "+ body1.url)// you said body1.text and body1.url
response.output.text[0] = sendMessage;
return res.json(response);
});
}
response
参数为用户发送消息,然后,您需要在函数中设置调用发现的参数,并在函数中添加以下代码。