我正在学习node.js和BotFramework-WebChat的阶段 .
我有一个简单的Dialogflow项目,我已经安装了BotFramework-Webchat ..
在bot初始化之后,我需要触发Dialogflow的“WELCOME”事件吗?
我找到了Microsoft / BotFramework-WebChat的样本/反向通道
我以为我可以用它开始学习它 .
但由于我对Node.js的限制,我不知道如何向Dialogflow发送消息事件触发以触发其WELCOME事件 .
可以帮我吗?
=== /home/BotFramework-WebChat-master/samples/backchannel/index.html ===
const botConnection = new BotChat.DirectLine({
domain: params['domain'],
secret: params['s'],
token: params['t'],
webSocket: params['webSocket'] && params['webSocket'] === 'true' // defaults to true
});
BotChat.App({
bot: bot,
botConnection: botConnection,
// locale: 'es-es', // override locale to Spanish
user: user
}, document.getElementById('BotChatGoesHere'));
botConnection
.postActivity({
from: user,
name: 'requestWelcomeDialog',
type: 'event',
value: ''
})
.subscribe(function (id) {
console.log('"trigger requestWelcomeDialog" sent');
});
botConnection.activity$
.filter(function (activity) {
return activity.type === 'event' && activity.name === 'requestWelcomeDialog';
})
.subscribe(function (activity) {
console.log('"activity" received with value: ' + activity.value);
});