Я создал бот в чате Microsoft с Луисом и герою, но бот работает только на localhost.
Я уже выполнил шаги, описанные в: https://docs.microsoft.com/en-us/azure/bot-service/bot-service-troubleshoot-authentication-problems?view=azure-bot-service-4.0
Каждый шаг успешен идаже если я тестирую его на локальном хосте с моим Bot-Id и Bot-Password, приложение работает.
Но если я пытаюсь использовать своего бота в веб-чате из Azure или внедрить его в Microsoft Teams, оно нене работает.
Это адрес приложения heroku: https://movie -booking-bot.herokuapp.com /
У кого-нибудь есть идеи, почему ононе работает?Что-то не так с моим кодом или мне не хватает некоторых конфигураций?
Постановка проблемы:
Бот отвечает только на localhost.Я не получаю никаких сообщений, если я тестирую бота в веб-чате или в командах.
Заранее благодарю за помощь.
Следующие журналы я получаю от heroku, когда яотправляю сообщение в веб-чате:
2019-06-29T20:12:14.084375+00:00 heroku[router]: at=info method=POST path="/api /messages" host=movie-booking-bot.herokuapp.com request_id=4b72f187-1e7f-480b-bb77-3f68ea0842e4 fwd="13.94.244.42" dyno=web.1 connect=0ms service=3ms status=202 bytes=117 protocol=https
2019-06-29T20:12:16.293731+00:00 heroku[router]: at=info method=POST path="/api/messages" host=movie-booking-bot.herokuapp.com request_id=b2634bfe-855e-49d6-855a-93a2ce746ecb fwd="13.94.244.42" dyno=web.1 connect=1ms service=2ms status=202 bytes=117 protocol=https
2019-06-29T20:12:16.325668+00:00 heroku[router]: at=info method=POST path="/api/messages" host=movie-booking-bot.herokuapp.com request_id=550e1f4b-0cf8-4224-971e-bf007be659bc fwd="13.94.244.42" dyno=web.1 connect=1ms service=4ms status=202 bytes=117 protocol=https
2019-06-29T20:12:16.326065+00:00 app[web.1]: The Bot State API is deprecated. Please refer to https://aka.ms/I6swrh for details on how to replace with your own storage.
2019-06-29T20:12:16.487948+00:00 app[web.1]: Error: GET to 'https://state.botframework.com/v3/botstate/webchat/conversations/GHZx9biLjXS1vmTW2BqFUS-h/users/DUnoSSshPmV' failed: [405] Method Not Allowed
2019-06-29T20:12:16.487952+00:00 app[web.1]: at Request._callback (/app/node_modules/botbuilder/lib/bots/ChatConnector.js:675:46)
2019-06-29T20:12:16.487954+00:00 app[web.1]: at Request.self.callback (/app/node_modules/request/request.js:185:22)
2019-06-29T20:12:16.487956+00:00 app[web.1]: at Request.emit (events.js:198:13)
2019-06-29T20:12:16.487958+00:00 app[web.1]: at Request.EventEmitter.emit (domain.js:448:20)
2019-06-29T20:12:16.487960+00:00 app[web.1]: at Request.<anonymous> (/app/node_modules/request/request.js:1161:10)
2019-06-29T20:12:16.487961+00:00 app[web.1]: at Request.emit (events.js:198:13)
2019-06-29T20:12:16.487963+00:00 app[web.1]: at Request.EventEmitter.emit (domain.js:448:20)
2019-06-29T20:12:16.487964+00:00 app[web.1]: at IncomingMessage.<anonymous> (/app/node_modules/request/request.js:1083:12)
2019-06-29T20:12:16.487966+00:00 app[web.1]: at Object.onceWrapper (events.js:286:20)
2019-06-29T20:12:16.487967+00:00 app[web.1]: at IncomingMessage.emit (events.js:203:15)
var builder = require('botbuilder');
var restify = require('restify');
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function() {
console.log('%s listening to %s', server.name, server.url);
});
var connector = new builder.ChatConnector({
appId: 'ID',
appPassword: 'PASSWORD'
});
server.post('/api/messages', connector.listen());
var bot = new builder.UniversalBot(connector);
var LuisAPPId= "ID";
var LuisAPIKey ="Password";
var LuisAPIHostName ="westus.api.cognitive.microsoft.com";
const LuiSModelURL ='https://' + LuisAPIHostName + '/luis/v2.0/apps/' +LuisAPPId +'?subscription-key=' + LuisAPIKey;
var recognizer = new builder.LuisRecognizer(LuiSModelURL);
var intents = new builder.IntentDialog({
recognizers: [recognizer]
});
bot.dialog('/', intents);
intents.matches('Greet', (session, args, next) => {
session.send("Hello I`am your digital cinema assitents. I can inform you about movies or book direct one or several tickets for you.");
});
var movies = [
"spider-man",
"rampage",
"the avengers",
"jurassic world"
];
intents.matches('ShowNowPlaying', (session, args, next) => {
session.send("Hey this is our programm of movies which are played :)\n\n" + movies.join("\n\n"));
});
intents.matches('BookTicket', [(session, args, next) => {
console.log(JSON.stringify(args));
var movieEntity = args.entities.filter(e => e.type == 'Movies');
var NumOfTicketsEntity = args.entities.filter(e => e.type == 'builtin.number');
if(movieEntity.length > 0)
{
session.userData.movie = movieEntity[0].resolution.values[0];
}
else {
delete session.userData.movie;
}
if(NumOfTicketsEntity.length > 0) {
session.userData.NumOfTickets = NumOfTicketsEntity[0].resolution.value;
} else {
delete session.userData.NumOfTickets;
}
if(!session.userData.movie) {
session.beginDialog('askMovie');
}
else{
next();
}
}, (session, args, next) => {
if(!session.userData.NumOfTickets) {
session.beginDialog('askNumOfTickets');
}
else{
next();
}
}, (session, args, next) => {
session.send("Sure, I have booked you " + session.userData.NumOfTickets + " tickets for " + session.userData.movie + ". Have Fun")
}]);
bot.dialog('askMovie', [(session, args, next) => {
builder.Prompts.choice(session, 'What movie would you like to watch?', movies);
}, (session, results) => {
session.userData.movie = results.response.entity;
session.endDialogWithResult(results);
}]);
bot.dialog('askNumOfTickets', [(session, args, next) => {
builder.Prompts.number(session, 'Great! How many tickets do you would like to have?');
}, (session, results) => {
session.userData.NumOfTickets = results.response;
session.endDialogWithResult(results);
}])