Closed alucard001 closed 6 years ago
args
parameter from the first waterfall step in your `'my_LUIS_intent', what does it print?I don't recall offhand, but I seem to recall that in the Azure Bot Service LUIS template, the LuisModelUrl
is constructed in something like this:
var LuisModelUrl = 'https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/' + process.env.appId
+ '?subscription-key=' + process.env.subscriptionKey + '&timezoneOffset=0&verbose=true&q=';
Are your environmental variables/process.env
setup properly?
Thanks. I finally make it to work. My storage argument is using Azure storage, which I should use MemoryBotStorage
instead.
And also thanks Steven providing LUIS 2.0 API, I just found myself copying LUIS 1.0 code.
Here is the full sample code:
/*-----------------------------------------------------------------------------
A simple echo bot for the Microsoft Bot Framework.
-----------------------------------------------------------------------------*/
require('dotenv').config();
var restify = require('restify');
var builder = require('botbuilder');
var botbuilder_azure = require("botbuilder-azure");
// Setup Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
console.log('%s listening to %s', server.name, server.url);
});
// Create chat connector for communicating with the Bot Framework Service
var connector = new builder.ChatConnector({
appId: process.env.MicrosoftAppId,
appPassword: process.env.MicrosoftAppPassword,
openIdMetadata: process.env.BotOpenIdMetadata || ''
});
// Listen for messages from users
server.post('/api/messages', connector.listen());
/*----------------------------------------------------------------------------------------
* Bot Storage: This is a great spot to register the private state storage for your bot.
* We provide adapters for Azure Table, CosmosDb, SQL Azure, or you can implement your own!
* For samples and documentation, see: https://github.com/Microsoft/BotBuilder-Azure
* ---------------------------------------------------------------------------------------- */
// Azure storage
// var tableName = 'botdata';
// var azureTableClient = new botbuilder_azure.AzureTableClient(tableName, process.env['AzureWebJobsStorage']);
// var tableStorage = new botbuilder_azure.AzureBotStorage({
// gzipData: false
// }, azureTableClient);
// Create your bot with a function to receive messages from the user
var bot = new builder.UniversalBot(connector);
// bot.set('storage', tableStorage);
bot.set('storage', new builder.MemoryBotStorage());
// bot.use({
// receive: function(event, next){
// next();
// },
// botbuilder: function(session, next){
// next();
// },
// send: function(event, next){
// next();
// }
// });
// Make sure you add code to validate these fields
var luisAppId = process.env.LuisAppId;
var luisAPIKey = process.env.LuisAPIKey;
var luisAPIHostName = process.env.LuisAPIHostName || 'westus.api.cognitive.microsoft.com';
const LuisModelUrl = 'https://' + luisAPIHostName + '/luis/v2.0/apps/' + luisAppId + '?subscription-key=' + luisAPIKey + '&verbose=true';
// Main dialog with LUIS
var recognizer = new builder.LuisRecognizer(LuisModelUrl);
var intents = new builder.IntentDialog({ recognizers: [recognizer] })
intents
.matches('my_luis_intent', function (session, args, next) {
console.log(session);
console.log(args);
console.log(next);
})
.onDefault((session) => {
let text = session.message.text;
session.send([
`Sorry, I did not understand: ${text}`,
`抱歉,我不太明白什麼是: ${text}`
]);
});
bot.dialog('/', intents);
Bot Info
Issue Description
Hi all. I have 2 questions:
myintent
in chat box, theintents
returned isnull
, therefore all messages goes toonDefault
part of the code. Are there any way to manually trigger, or by modifying the code so that thematches
goes tomy_LUIS_intent
?Thank you very much in advance for all helping.
Code Example