使用NodeJS和Microsoft Bot框架构建机器人-在对话框内部,我有一个函数,无法从getDetails函数发送session.send(“”),但可以启动新对话框。当我启动这个新对话框时,我也无法发送任何消息。我尝试将会话传递给该函数,但此方法也不起作用:代码(这在对话框内并运行,等等)
function (session, results, next) {
if (results.response) {
var place = results.response;
getDetails(session, place, function (err, geoData) {
if (err) {
console.log(err);
} else {
var formattedString = place.streetAddress + " " + geoData[0].extra.neighborhood + " " + place.postalCode;
console.log(formattedString);
connectSQL(formattedString, function(returnValue) {
session.send("hello-connectSQL");
session.beginDialog("sendLocation");
});
}
})
}
}
]);
bot.dialog("sendLocation", [
function(session, args){
console.log("hello"); //This successfully outputs to console.
session.send("message"); //Doesn't send.
}
])
编辑:getDetails代码:
async function getDetails(session, place, callback) {
await geocoder.reverse( {
lat:place.geo.latitude,
lon:place.geo.longitude
})
.then(res => {
geoData = res;
callback(null, geoData);
})
.catch(err => {
console.log(err);
callback(err);
})
}
谢谢!