BotBuilder-MicrosoftTeams-dotnet
BotBuilder-MicrosoftTeams-dotnet copied to clipboard
[Bug]"Getting started" code causes an error in Startup.cs.
Describe the bug When "Getting started" code add to Startup.cs and run BOT, an error occurs. Error message is the following : "Object reference not set to an instance of an object."
Repro steps is the following:
- Create EchoBot with Bot template V4. (C#, Visual Studio 2017)
- Install the EchoBot to Microsoft Teams.
- Add the "Getting started" code add to services.AddBot<MyFirstBotBot> in Startup.cs.
- Add the "Getting started" code add to OnTurnAsync in the ***bot.cs.
- Set breakpoint to the following code in Startup.cs. logger.LogError($"Exception caught : {exception}");
- Run EchoBot project.
- Chat to Bot using Microsoft Teams. 8.Error causes and the code does stop at the breakpoint.
SDK Version Microsoft.Bot.Builder 4.3.2 Microsoft.Bot.Builder.Integration.AspNet.Core 4.3.2 Microsoft.Bot.Builder.Teams 4.0.0-beta1 Microsoft.Bot.Configuration 4.3.2 Microsoft.Bot.Connector 4.3.2 Microsoft.Bot.Schema 4.3.2
.Net Version .Net Core 2.1
Expected behavior The errors are caught in options.OnTurnError in Startup.cs.
Screenshots
Additional context Hosts endpoints using ngrok.
Can you try the TeamsEchoBot sample in this repo?
In my environment, a Microsoft.Bot.Builder dependency error occurred and the project could not be run. https://github.com/OfficeDev/BotBuilder-MicrosoftTeams-dotnet/tree/master/CSharp/Samples/Microsoft.Bot.Builder.Teams.TeamEchoBot
What is the error you hit while running sample?
After that, I deleted the solution folder and re-copy new solutions and resolved the issue. Now TeamEchoBot project dose normally compiling. However, When TeamEchoBot run display 404 page in web browser. When I connect to the http://localhost:65307/api/message then display 405 page in web browser. I worked the following steps:
- open Microsoft.Bot.Builder.Teams.sln with Visual Studio 2017.
- Rebuild the solution.
- Click to the Microsoft.Bot.Builder.Teams.TeamEchoBot project in solution explorer.
- Press [F5] key
Is correct my run work for TeamEchoBot project?
I am guessing you are doing GET when trying to display the page in web browser. Ignore the 404. And try hitting the bot from Microsoft Teams. Also before you run the sample, make sure you added your BotAppId and Password to appSettings.json
Did this work for you?
Having same issue. Trying to add Teams middleware to an existing working bot. Steps:
- Add Nuget
- Add the "Getting started" code in Startup.cs.
Now when I hit my first line in my bot (CreateContextAsync), it fails with "Object reference not set to an instance of an object"
public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken))
{
var dialogContext = await this.dialogs.CreateContextAsync(turnContext, cancellationToken);
I'm using blobstorage instead of MemoryStorage, but otherwise can't see any other changes from my bot compared to the examples, so what could be wrong here?
var storageContainer = string.IsNullOrWhiteSpace(blobStorageConfig.Container) ? DefaultBotContainer : blobStorageConfig.Container;
IStorage dataStore = new Microsoft.Bot.Builder.Azure.AzureBlobStorage(blobStorageConfig.ConnectionString, storageContainer);
var conversationState = new TeamSpecificConversationState(dataStore);
options.State.Add(conversationState);
@tnsholding What are the package versions you are using?