在BotBuilder中记录传入的请求 [英] Logging incoming requests in BotBuilder
问题描述
尝试记录来自Facebook的所有传入请求,以便我可以检查对象,我回到使用内置的NLP Facebook进行某些操作。
Trying to log all incoming requests from Facebook so I can inspect the object I get back to do some stuff with the built in NLP Facebooks implemented.
然而, ,似乎找不到任何地方告诉我,我可以在 console.log
传入请求。
I, however, can't seem to find anywhere where it tells me I can console.log
incoming requests.
server.post('/ api / messages',connector.listen());
方法我试图传递一个 console.log
,但没有任何反应。
in the server.post('/api/messages', connector.listen());
method I'm trying to pass in a console.log
but nothing happens.
const express = require('express');
const builder = require('botbuilder');
const server = express();
const connector = new builder.ChatConnector({
appId: process.env.MICROSOFT_APP_ID,
appPassword: process.env.MICROSOFT_APP_PASSWORD,
});
server.post('/api/messages', connector.listen());
server.listen(process.env.PORT || 5000, () => {
console.log('Running on port 5000');
});
推荐答案
您可能希望使用中间件访问传入/传出邮件。
You might want to use middleware to access to the incoming/outgoing messages.
查看使用BotBuilder Node SDK进行中间件和日志记录示例
捕获用户输入 p>
Capturing User Input
botbuilder: function (session, next) {
console.log(session.message.text);
next();
}
将bot输出捕获到用户
send: function (event, next) {
console.log(event.text);
next();
}
特别是,因为你想检查来自 Facebook
,您可能必须登录 sourceEvent
属性,这是渠道发送其本机信息的地方。
In particular, since you want to check things coming from Facebook
, you might have to log the sourceEvent
property, which is where channels send their native information.
这篇关于在BotBuilder中记录传入的请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!