Gabriel (10) [Avatar] Offline
#1
Hello,
I'm following the instructions on chapter 3 and I can't make the chatbot work. I took the code fragment available on GitHub (https://github.com/GanadiniAkshay/HealthBot-Manning/blob/master/index.js) and replaced the endpoint.

But I get an error when the I type some text and hit Enter:

/hi - Session.sendBatch() sending 1 message(s)
The Bot State API is deprecated.  Please refer to https://aka.ms/I6swrh for details on how to replace with your own storage.


The book does not mention anything about this. I just created the bot and I guess I'm using the latest version of the API. What does "Bot State API is deprecated" mean?

Please, update the example to fix the issue.
Akshay Kulkarni (3) [Avatar] Offline
#2
Thanks for buying the MEAP. I am the author of this book and am sorry for the inconvenience. The problem is that Microsoft Bot Framework initially managed state automatically (I discuss more about state in a later chapter) but they deprecated this on March 15. The next version of MEAP will have the fixed code.

For now to make your code work, do the following

Add this before your bot definition: var inMemoryStorage = new builder.MemoryBotStorage();

Change your bot definition as:

var bot = new builder.UniversalBot(connector, function (session) {
session.send("Sorry, couldn't understand what you said");
}).set('storage', inMemoryStorage);
Gabriel (10) [Avatar] Offline
#3
Hi Akshay,
thank you for your quick reply!
I verified that the API (LUIS) is working fine from the dashboard: when I type a few utterances and I get the correct answer.

But the bot is not working. I applied the changes you mention and I get always this answer: "Sorry, couldn't understand what you said". I attach a couple of screenshots and also the code fragment with the endpoint to my application as deployed on LUIS.

var inMemoryStorage = new builder.MemoryBotStorage(); 
var bot = new builder.UniversalBot(connector, function (session) { 
    session.send("Sorry, couldn't understand what you said"); 
}).set('storage', inMemoryStorage);

var model = 'https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/033248f5-7e33-4bf5-8362-fdd5777194ba?subscription-key=e3d670dea8e048938e6b540258397880';


This is the full endpoint as displayed on the dashboard:

https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/033248f5-7e33-4bf5-8362-fdd5777194ba?subscription-key=e3d670dea8e048938e6b540258397880&staging=true&verbose=true&timezoneOffset=0&q=

Maybe the service cannot be invoked remotely when the app is created in the free tier or I need to enable something on the dashboard?

Akshay Kulkarni (3) [Avatar] Offline
#4
Make sure you add this after the bot definition:

bot.recognizer(new builder.LuisRecognizer(model));


Also can you try changing '/Hi' to 'Hi' and see if that works for you
Gabriel (10) [Avatar] Offline
#5
Thanks again! Here I paste the script (I omit the final actions definitions for brevity). But I still get the same response from the bot: "Sorry, couldn't understand what you said"

const restify = require('restify');
const builder = require('botbuilder');

var server = restify.createServer();
server.listen(process.env.PORT || process.env.port || 8000, function(){
console.log("Bot running on port %d", process.env.PORT || process.env.port || 8000);
}); 

var connector = new builder.ChatConnector({  
	appId: '', // empty string for now 
	appPassword: '' // empty string for now 
});

server.post('/api/messages', connector.listen()); 

var inMemoryStorage = new builder.MemoryBotStorage(); 
var bot = new builder.UniversalBot(connector, function (session) { 
    session.send("Sorry, couldn't understand what you said"); 
}).set('storage', inMemoryStorage);

var model = 'https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/033248f5-7e33-4bf5-8362-fdd5777194ba?subscription-key=e3d670dea8e048938e6b540258397880';
bot.recognizer(new builder.LuisRecognizer(model));

bot.dialog('hi', function(session,args){
	session.send("hi");
}).triggerAction({
    matches: 'Hi',
});

bot.dialog('Get Nutrition',function(session,args){
    session.send("It’s very nutritious");
}).triggerAction({
    matches:'Get Nutrition'
});

. . .

Gabriel (10) [Avatar] Offline
#6
I just replaced my endpoint with the one that appears in the book and the bot works fine. But it's not working when it uses the endpoint to the LUIS app I created myself.

So I suspect that the issue is related to the deployment of the service on the dashboard. Have you tried to create a new application using the free tier?

This endpoint works with the bot (book example): (https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/0906c5db-1a50-48cb-8988-676f354551d0?subscription-key=d3d4b77102dc4b07895c864325cb6820).

This endpoint does not work with the bot (created by me): https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/033248f5-7e33-4bf5-8362-fdd5777194ba?subscription-key=e3d670dea8e048938e6b540258397880
Gabriel (10) [Avatar] Offline
#7
I just replaced my endpoint with the one that appears in the book and the bot works fine. But it's not working when it uses the endpoint to the LUIS app I created myself.

So I suspect that the issue is related to the deployment of the service on the dashboard. Have you tried to create a new application using the free tier?

This endpoint works with the bot (book example): (https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/0906c5db-1a50-48cb-8988-676f354551d0?subscription-key=d3d4b77102dc4b07895c864325cb6820).

This endpoint does not work with the bot (created by me): https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/033248f5-7e33-4bf5-8362-fdd5777194ba?subscription-key=e3d670dea8e048938e6b540258397880