【发布时间】:2019-04-03 20:47:53
【问题描述】:
我正在尝试将 Watson 连接到 Google Actions,我的函数在 firebase 中,当我只测试与 Watson 的连接时,它可以工作。但是当我尝试在 Google 控制台中对其进行测试时,它会关闭项目。
这是我在 Firebase Cloud Functions 中的代码:
const {actionssdk} = require('actions-on-google');
const functions = require('firebase-functions');
const app = actionssdk({debug: true});
var AssistantV1 = require('watson-developer-cloud/assistant/v1');
app.intent('actions.intent.MAIN', (conv) => {
conv.ask('Olá, como posso lhe ajudar?');
});
app.intent('actions.intent.TEXT', (conv, input) => {
var AssistantV1 = require('watson-developer-cloud/assistant/v1');
var assistant = new AssistantV1({
username: '###############',
password: '###############',
url:'###############',
version: '2018-07-10'
});
assistant.message(
{
workspace_id: '###############',
input: { text: result },
headers: {'Custom-Header': 'custom',
'Accept-Language': 'custom'
}
},
function(response) {
conv.ask(response.output.text[0]);
}
);
});
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);`
【问题讨论】:
标签: node.js actions-on-google ibm-watson