我有一个简单的机器人,可以根据用户提示获取新闻文章。整个流程使用模拟器在本地运行良好,但在部署到服务器后,机器人在遇到 builder.Prompts.text 块时会失败。下面是我的代码,你会看到一个“询问文章计数”提示,这是它停止流动的地方。
- 在 BOT 框架页面上进行测试时显示已接受 Bot
- Bot 通过 WebChat 和 Slack 接收消息
Bot 在交互后还显示每个频道的 0 个问题
var bot = new builder.UniversalBot(connector); var intents = new builder.IntentDialog(); bot.dialog('/', intents); var HHCC = require('./hhcc.js'); intents.matches(/^news/i, [ function(session) { console.log("Intent Given!"); session.beginDialog('/news'); }, function(session, results) { session.send('Enjoy reading!'); } ]); bot.dialog('/news', [ function(session) { console.log("Asking article count"); builder.Prompts.text(session, 'How many articles would you like to see?'); }, function(session, results) { session.sendTyping(); session.conversationData.count = results.response; HHCC.getNews(session.conversationData.count, session, function(newsArticles) { newsArticles.forEach(function(newsCard) { session.send(newsCard); }); session.conversationData.news = newsArticles; console.log(newsArticles); session.endDialog(); }); } ]); server.post('/api/messages', connector.listen());
我检查了所有日志,似乎找不到任何线索,因为它的失败非常安静。