Code Monkey home page Code Monkey logo

Comments (4)

himsoni85 avatar himsoni85 commented on September 15, 2024

I have the same issue. If you browse the BOT's Web App URL (https://xxxxxxxxxxxxxx.azurewebsites.net/api/messages), you will get a 404 error. This is most likely the cause of the issue. Standard troubleshooting requires redeploying the bot. I am still trying to figure how to do that since we deployed this bot through the template. I do not want to redeploy the whole template again.

from microsoft-teams-faqplusplus-app.

GeorgianaMihaela avatar GeorgianaMihaela commented on September 15, 2024

It is expected that a browse to the /api/messages to return 404 because the endpoint accepts only POST requests. See this SO thread for detailed explanation: https://stackoverflow.com/questions/50480422/c-sharp-bot-framework-resource-not-found-error

Also, you could test the same thing for a working bot: take the messaging endpoint from the Azure portal and paste it into a browser window.
You will have the same outcome: 404.

Example: working bot:

image

and the not found page:

image

from microsoft-teams-faqplusplus-app.

GeorgianaMihaela avatar GeorgianaMihaela commented on September 15, 2024

Hi @DanPerfect

For teams:

The bot is responding in teams if the tenantId of your Teams is the same as the one in your Azure subscription.

The code checks the turnContext tenant id to be equal to the id which is present in the appsettings.json and the web.config:

public override Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken))
{
if (!this.IsActivityFromExpectedTenant(turnContext))
{
this.telemetryClient.TrackTrace($"Unexpected tenant id {turnContext.Activity.Conversation.TenantId}", SeverityLevel.Warning);
return Task.CompletedTask;
}

https://github.com/OfficeDev/microsoft-teams-faqplusplus-app/blob/master/Source/Microsoft.Teams.Apps.FAQPlusPlus/Bots/FaqPlusPlusBot.cs
You could comment out the above if statement and redeploy the bot in Azure using these steps
https://social.technet.microsoft.com/wiki/contents/articles/52864.visual-studio-2019-publishing-bot-application-to-azure.aspx

For the test in webchat:

This bot is designed to work in teams, because it does some checks on the conversation type:
protected override async Task OnMessageActivityAsync(
ITurnContext turnContext,
CancellationToken cancellationToken)
{
try
{
var message = turnContext.Activity;

            this.telemetryClient.TrackTrace($"Received message activity");
            this.telemetryClient.TrackTrace($"from: {message.From?.Id}, conversation: {message.Conversation.Id}, replyToId: {message.ReplyToId}");

            await this.SendTypingIndicatorAsync(turnContext);

            switch (message.Conversation.ConversationType)
            {
                case "personal":
                    await this.OnMessageActivityInPersonalChatAsync(message, turnContext, cancellationToken);
                    break;

                case "channel":
                    await this.OnMessageActivityInChannelAsync(message, turnContext, cancellationToken);
                    break;

                default:
                    this.telemetryClient.TrackTrace($"Received unexpected conversationType {message.Conversation.ConversationType}", SeverityLevel.Warning);
                    break;
            }
        }

When testing in webchat, this returns null
message.Conversation.ConversationType --> null.
Thus, the above switch goes to the default branch.

See here the conversationtype example (personal and channel): https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/bots/bots-notifications#schema-example-bot-added-to-team

To troubleshoot, you may download the bot code from here https://github.com/OfficeDev/microsoft-teams-faqplusplus-app
Run it locally and add a breakpoint in the OnTurnAsync method, main bot class
Test it using the emulator.
Please see this link on how to debug https://docs.microsoft.com/en-us/azure/bot-service/bot-service-debug-bot?view=azure-bot-service-4.0#debug-a-c-bot-using-breakpoints-in-visual-studio

Start by commenting the tenant id validation, if you do not have teams and azure in the same tenant.
The bot should work in teams. I did not manage to make it work into the chat, because of the above switch going to the default branch.

Hope this helps.

from microsoft-teams-faqplusplus-app.

DanMcGuinness avatar DanMcGuinness commented on September 15, 2024

I blew away the bot and started again. This time I'm getting replies. :)

from microsoft-teams-faqplusplus-app.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.