【发布时间】:2019-10-22 00:28:57
【问题描述】:
使用以下代码通过直线向机器人生成事件。
<!DOCTYPE html>
<html>
<head>
<link href="https://cdn.botframework.com/botframework-webchat/latest/botchat.css" rel="stylesheet" />
</head>
<body>
<div>
<div id="bot" />
</div>
<script src="https://cdn.botframework.com/botframework-webchat/latest/botchat.js"></script>
<script>
var user = {
id: 'user-id',
name: 'user name'
};
var botConnection = new BotChat.DirectLine({
token: 'MYTOKENHERE',
user: user
});
BotChat.App({
user: user,
botConnection: botConnection,
bot: { id: 'bot-id', name: 'bot name' },
resize: 'detect'
}, document.getElementById("bot"));
botConnection
.postActivity({
from: user,
name: 'requestWelcomeDialog',
type: 'event',
value: ''
})
.subscribe(function (id) {
console.log('"trigger requestWelcomeDialog" sent');
});
</script>
</body>
</html>
我有代码来处理来自机器人的任何事件/消息。当我输入 hi 或任何消息时,它会起作用。但是,当我按照 MS bot 框架文档的承诺将聊天机器人加载为对话更新活动时,它不会自动进行。 有没有人可以帮忙。
【问题讨论】:
-
将解决方案标记为已接受服务于更大的 Stack Overflow 社区和任何有类似问题的人。如果您觉得我的回答足够,请“接受”它。如果没有,请告诉我我还能提供哪些帮助!
标签: javascript botframework bots direct-line-botframework