我正在尝试使用dialogflow构建一个Slack-bot。我将bot集成到slack上,但是将其安装到工作区后,来自slack的消息就不会进入dialogflow了。我的对话流程实现不起作用。 在测试期间效果很好。 Slack认为此应用没有api.ai应用。我的实现代码为:
'use strict';
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
process.env.DEBUG = 'dialogflow:debug';
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request,response) => {
const agent = new WebhookClient({ request, response });
//const agentPath = agent.entitiesClient.projectAgentPath("master-bot-53dee");
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
function welcome(agent) {
agent.add(`Welcome to my agent!`);
}
function fallback(agent) { }
function slack_rename(agent) {
const query = agent.query;
let channel = agent.parameters.channel;
let rename = agent.parameters.rename;
let rname = agent.parameters.any;
let a = query.split(" ");
let i = 0;
agent.add(`changing the name of the channel ${channel} to ${rname}`);
}
function slack_archive(agent){
let channel = agent.parameters.channel;
let archive = agent.parameters.archive;
agent.add(`so you want to ${archive} ${channel}`);
}
function slack_private(agent) {
let priv = agent.parameters.private;
let pub = agent.parameters.public;
let channel = agent.parameters.channel;
agent.add(`so you want to convert ${channel} from ${pub} to ${priv}`);
}
let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('Default Fallback Intent', fallback);
intentMap.set('slack-rename', slack_rename);
intentMap.set('slack-archive', slack_archive);
intentMap.set('slack_private', slack_private);
agent.handleRequest(intentMap);
});
expected result is :
user:Hi
Bot: Hi I can do the following stuff for you.
(list of tasks come in)
actual result is:
no reply from bot .