I've created bot (Bot Framework v3) which uses LUIS, QnAMaker, Dialogflow services. It works perfectly when I run it locally in the Bot Emulator, but when I deploy it on Azure my bot stops working. On the surface he just replies Sorry, my bot code has an issue and in the Settings-Web Chat blade of the application there is a 500 InternalServerError.
I tried to debug with ngrok, and I got an exception Operation returned an invalid status code 'MethodNotAllowed' with Microsoft.Bot.Connector.ErrorResponse message Bot should use its own storage in my MessageController in method await Conversation.SendAsync(activity, () => new RootDialog().DefaultIfException());
Also, the first message that was intended to be sent by the bot which is processed in ConversationUpdate is successfully sent to a user without any error.
I'm using Azure Table Storage, and I've also tried InMemory storage. There is also some work with a local database in my bot.
I also have a web app bot that was created a few months ago, and I tried to deploy this bot and it works fine. So, I suppose maybe I missed something in this new web app bot configurations or there is some other issue I'm not aware of. I've already checked all my app service keys many times.
Any help will be appreciated!
So, I found a solution. You must be sure that you have these lines of code in your Global.asax file
builder.Register(c => store)
.Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore)
.AsSelf()
.SingleInstance();
builder.Register(c => new CachingBotDataStore(store,
CachingBotDataStoreConsistencyPolicy
.ETagBasedConsistency))
.As<IBotDataStore<BotData>>()
.AsSelf()
.InstancePerLifetimeScope();
and use either Azure Table Storage or CosmosDb.
I just hadn't use CachingBotDataStore and its absence caused the error.
Related
I'm new to Azure. I had published a bot (developed locally) to Azure, e.g. named MyBot. It was shown as web service. Then I had created a bot channel registration on Azure e.g. named MyRegistration. As instructed, I wrote down the AppID and client secrete value from MyRegistration. In My Registration->settings, I put https://MyBot.azurewebsites.net/api/messages to the messaging endpoint. In MyBot->Configureation->Application settings, I added "MicrosoftAppId" and "MicrosoftAppPassword" and their values. I turned on "Web sockets" in MyBot->Configureation->General settings. I saved all the changes.
When I run "Test in Web Chat" in MyRegistration, nothing happened. In MyRegistration->Channels, there was "Issues" saying "There was an error sending this message to your bot: HTTP status code InternalServerError".
Can anybody help to point to what the reasons of failure were? Thank you very much.
Not sure the root reason, but I deployed my bot and go through this process but everything works perfectly for me. This is my steps below:
Deploy my bot service to Azure as a web app.
Create a Bot Channels registration, config my bot-message endpoint and Note Microsoft App ID:
Create a new secret, and note its value by clicking "Manage" Link:
Go to app service, and config App ID and App Password
Back to bot channel and have a web test. everything works as excepted:
I created a QnAMaker bot through the website https://www.qnamaker.ai, which then took me through the steps creating the bot in Azure.
When I click on the Test in Web Chat section of the bot in Azure, before I've even typed anything, an error message arrives in Channels > Web Chat > Issues that states: "There was an error sending this message to your bot: HTTP status code Unauthorized"
I have download the code of the bot locally, and running it with npm, using ngrok and the Bot Emulator, I have successfully managed to connect to the bot and it works.
I haven't touched the AppID or Password in the Bot's settings in Azure, and these are the same credentials I used for the local bot that works.
Could someone please help?
Thanks
I solved this by removing the bot entirely and creating a brand new one. I think the issue with some sort of mix up with the AppID and AppPassword, even though they were both correct in the settings
I’m using Azure Enterprise subscription and created a chat bot using same. But currently, I’m having trouble chatting using it. The bot is created using Visual studio using Bot framework and published to Azure. https://pihitsupportbot001.azurewebsites.net/ is my messaging end-point URL. I made bot channel registration for the same application and used the bot api endpoint with api/messages as end-point for it. Updated web config file with generated app ID and password and published. But when I try testing with web chat in Azure it is throwing ‘couldn’t send retry’. What would be the reason?
Jobin,
I was able to connect the bot emulator from my local pc to your endpoint, https://pihitsupportbot001.azurewebsites.net/api/message without, obviously, your appid and app password. I sent a 'hello' and received a sign-in card response. So, the bot appears to be working fine. Maybe the app service was still restarting after you edited the web.config?
Also, It's very hard to help diagnose these kinds of problems with limited information.
The error was due to the reason In global.asax I didn't have any state specified to store the conversation history. Earlier Microsoft had been providing a default state service for bots built using either the Node.js or .NET SDK’s. The state service is used to store and retrieve user and conversation data within the context of a conversation. But in fact in local while running using emulator or even in IIS, it doesn't need to have it. below is the documentation.
Bot State Service will soon be retired on March 31st, 2018
var store = new TableBotDataStore(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);
Conversation.UpdateContainer(
builder =>
{
builder.Register(c => store)
.Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore)
.AsSelf()
.SingleInstance();
builder.Register(c => new CachingBotDataStore(store,
CachingBotDataStoreConsistencyPolicy
.ETagBasedConsistency))
.As<IBotDataStore<BotData>>()
.AsSelf()
.InstancePerLifetimeScope();
});
PROBLEM: When I try to test my bot using the web chat in the MS Azure GUI, it gives me the error
There was an error sending this message to your bot: HTTP status code Forbidden
I've done the following:
Created a bot using the Microsoft Bot Framework, LUIS, and NodeJS
Created resource for the bot in MS azure
Successfully tested the bot locally using the bot emulator (without using the bot ID and password)
Set up continuous deployment so all updates made to my repo are reflected in the Azure bot service
Defined all environment variables in the application settings tab of the azure bot service (bot id and password are correct and included)
Included web.config, iisnode.yml, and publish.js files
Heeelp. I've googled this, tried alternative solutions mentioned for similar problems, but no luck.
NEVERMIND! I had stopped the application weeks ago, that's why it gave the forbidden error. I didn't realize until I tried to make a GET request in Postman to the bot endpoint.
So I have an issue to make the communication possible between Slack and BotFramework. I deploied once a bot on Slack to test the deployment and everything was working fine. I worked on another bot and when I try to deploy it there is no message reaching the bot on Azure.
Since I can not see errors on Azure or from Slack, I think my issue does not come from my code. What seems very strange is that I did not get any message from Slack telling me that the messages can not reach the bot and yet I can not see message reaching Azure.
I use this to install the bot on Slack https://learn.microsoft.com/en-us/azure/bot-service/bot-service-channel-connect-slack except that I did not suscribe to events which was working fine with my initial deployment.
I tried with a sample bot, I got the same issue. So I must be missing something about the configuration.
My bot is working fine with cortana and directline.
First thing I'd try is to find out if the problem is on the Slack side or the Bot Service side.
To test out the Bot Service side:
Have you tried running in the test chat?
Or tried debugging the bot service on your local machine?
If it helps, I've written up a little tutorial on how to debug a bot service.
Hope that helps!
Tim