I am working on creating bot for Microsoft teams in C#. I have a sample code (basic echo bot) that works fine in emulator. I created an app in teams app studio and entered my API end points in Bot section. I download the package and upload it as custom package in teams.
Now, when I add this app and try communicate with Bot, I get unauthorize error in API (using ngrok). I guess what’s going on here is that I don’t have the access token i.e. when someone install it, teams should give you access token, right?
What I don’t know is how teams will give me the access token and where in the process that access token will be used?
So basically, when someone clicks on “Add” button in teams app store, how the access token are passed.
#update
Note:-I have done the app registration as well.
So i did bot channel registration in Azure and added my ngrok end points. I copied the "MicrosoftAppId" and "MicrosoftAppPassword" in appsettings file. It is working fine in emulator as well as "test on web chat" in Azure bot management portal. I also connected it to Teams channel from portal itself. when i navigate to teams from the channel link, my bot is working as expected.
After that i opened app studio and entered all the details. In Bot section, i selected existing bot id and entered my MicrosoftAppId from azure and it worked.
what I still don't understand is, when someone install the app, teams should be sending some information to my end point, right?
Without access to your code it is hard/impossible to determine the cause of your issue.
I suggest instead you take a fresh start by using one of the Teams bot examples that are shared :
57.teams-conversation-bot
if you do require authentication in your bot:
Authentication flow for bots - Teams | Microsoft Docs
46.teams-auth
52.teams-messaging-extensions-search-auth-config
pleanty other teams examples as well in that repo:
50.teams-messaging-extensions-search
51.teams-messaging-extensions-action
53.teams-messaging-extensions-action-preview
54.teams-task-module
55.teams-link-unfurling
56.teams-file-upload
57.teams-conversation-bot
58.teams-start-new-thread-in-channel
Related
I have created one action bot (which can create ticket, tell me the description of the ticket). I have published that bot in azure. After that I have created one FAQ bot using QnA Maker, Knowledge Base and LUIS. Now I have published this FAQ bot as a Skill. Now I want to merge this to bot. For that I have added the FAQ bot skill to the Action Bot. And in Skill Configuration I have given the parent bot (Action Bot) url as "skill host endpoint url". Ex: "https://api-demobotresource.azurewebsites.net" this is my Action Bot url , and "https://FAQ-Demo.azurewebsites.net/api/messages" this is my Skill endpoint url. So I have given skill host endpoint url as "https://api-demobotresource.azurewebsites.net/api/skills". After publishing the merged bot in azure when I try to check it in web-chat, the Skill bot is not working properly. It is throwing 401 error.
I have taken the help of this article https://microsoft.github.io/botframework-solutions/help/known-issues/ . Still I am facing the same issue.
Please help. Thanks in Advance.
The listed Error: 401 is getting triggered due to Authentication Failure and this can be due to the following 2 reasons:
Invalid Microsoft App ID & Password
Incorrect “https” settings
As part of the solution, we need to enable the “https” settings along with inserting correct Microsoft App ID & Passwords.
If the above solution is already tried but ends in the same error, then we can try Deleting all the existing files every time we are updating or modifying our BOT Code. These steps would help in redeploying the Web APIs.
I cannot publish my dialogs in Bot Composer Framework version 2.1.1. We have created a new different Resource group and app services, since we have Production site and this one is for testing site. I have checked all the credentials of the bot and it is correct. (Microsoft AppId, keys etc.)
"TypeError - Cannot read property 'AzureSubscriptionId' of undefined"
UPDATE: Microsoft supported me, and it looks like there's something wrong with my ARM access token and they reset it. it works fine now.
UPDATE: Microsoft supported me, and it looks like there's something wrong with my ARM access token and they reset it. it works fine now.
When you are trying to publish your bot framework to Azure we need to configure the settings as below:
When we generate APP ID and Password make sure that we are using yourbotframework.azurewebsite.net/api/message and post that you need to create Microsoft Id & Password and to be used in your code.
To get the URI
For more information please refer this Microsoft Documentation:- Publish a bot to Azure from Composer
The last few days, I checked dozens of samples, docs, blog posts, youtube videos (courses, that I couldn't fine) and I can say I'm still confused and I still without a Teams bot.
Every example I've checked is different in approach, and now I'm pretty sure there are many others like me.
Frequently problems: required input/parameters like service Url, conversation Id, etc. 1. You can't find a explanation for them. 2. You can't find a place where it's explained how to get them.
What I want to achieve
I want a bot on Teams, with a API, with 2 parameters: user email, message. The bot has to send the message to the specified user. That's it.
I'm looking how to:
Create/Setup the Application
Create the actual Bot
Install the application to Teams
I used to create a Teams conversation bot. Hope my experience will help you.
First, download sample provided by microsoft. I uses c# to create this bot, so I copy the '57.teams-conversation-bot' folder and opened it with vs studio. In this sample, I need to modify the configuration in appsettings.json. I need to enter the appid and apppassword.
So the next step is creating an Azure ad application in Azure portal. But if you never create Bot Framework registration resource before, you can create the azure ad application when you create a Bot Framework.By the way, You can leave 'Messaging endpoint' empty now. Please note, when you creating Azure ad application, you can choose to set this application as a multitenant app if your account creating the app is in a different tenant with your teams account.
Now I have a bot framework and an Azure ad app, I can modify appsettings.json, enter the appId and app password. I can get appId in app overview page and get app password when creating client secrets in Certificates & secrets tag.
Now, I need to debug my sample with web chat in the azure portal(Enter the bot framework created just now, you can see Tag 'Test in web chat' in the left panel). So I need to use ngrok to make the bot visit my code in local environment. Running the sample by pressing F5 in vs studio. Opening ngrok.exe and running the command ngrok http -host-header=rewrite 3978. Then I can get a https url, copy that and paste in the 'Messaging endpoint'. Don't forget to add '/api/messages'.
Now sending 'hello' to the bot and you will get default result. When you get the picture below, it means you have made a correct configuration.
Next step is to add this bot to Teams client. First, I add the Teams Channel in the bot I created in the azure portal.
Then I need to modify the manifest file. Replacing the "YOUR-MICROSOFT-APP-ID" with appId creating just now. And creating manifest.zip file which contains the three file in folder TeamsAppManifest.
Next step is uploading the zip file to Teams client. Click the 'Apps' in the lower-left corner and click the 'Upload the custom app' in the bottom of the left panel, then click add. Ok, now I get a team conversation bot.
There -are- a ton of approaches, partly because Teams development is still relatively new, partly because the Bot Framework (the set of tools for buildings Bots in the Microsoft world, both for Teams and otherwise) has also undergone some major changes. That's aside from the various language options (dotnet, node, python, etc.).
What's looking to be a good place to get started though, is the new Teams Toolkit, a plugin for Visual Studio and Visual Studio Code, for building a new Teams project (Tab, Bot, etc.). Have a look here for a link. It's very new though, so some rough edges, but it's aiming to be very comprehensive to get up and running quickly (does a lot of Azure registrations behind the scenes, for example). Check out the latest monthly Teams Developer call, from earlier this week, for a visual run-through: https://www.youtube.com/playlist?list=PLWZJrkeLOrbbTKzV1sQOFAXd_s0BHJDiL (this week's call isn't up yet, but it should be very soon).
I downloaded the QnAmaker sample from here and trying to make it working from bot emulator.
I gave the correct Microsoft App Id and App Password. I even tried with a newly regenerated password. But getting the same error.
Did anyone face this issue? What should I try next to get this resolved?
My app settings
My ngrok settings
I removed ngrok settings from emulator settings.Removed MsApp Id and Ms App Password and then started emulator and the bot is responding. But I need to connect to my QnaMaker on azure and get response based on my knowledge base.
I tried via Web chat from azure portal and it did not responded.
Here is the error message I found in Application insights
Failed to acquire token for client credentials. (AADSTS700016:
Application with identifier 'fXXXXXXXXXXXXXXXXXXXXX2' was not found in
the directory 'botframework.com'. This can happen if the application
has not been installed by the administrator of the tenant or consented
to by any user in the tenant. You may have sent your authentication
request to the wrong tenant. Trace ID:
9XXXXX-46a3-4XX-b8XXX7-c1XXXXX00
"This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant"
How can I ensure that I am sending the request to correct tenant ? Where can I verify this?
Try removing the values for MicrosoftAppId and MicrosoftAppPassword from your appsettings.json file then run the bot and attempt to connect it via the emulator again.
When you connect to a bot in the emulator, AND the appsettings.json (always) or .bot file (only for the development endpoint) has values set for the MicrosoftAppId and MicrosoftAppPassword then you will need to enter these details into the provided fields on the connection screen, see my image below:
If your values in your appsettings.json for MicrosoftAppId and MicrosoftAppPassword are empty i.e. "" then you will not have to enter them at the connection screen and your bot will still work when you are debugging locally, even though your live bot has these set. The exception is when you're using ngrok to debug a production channel using your local code, then you will have to provide the MicrosoftAppId and MicrosoftAppPassword when connecting even though they may not be set locally.
If you want to see the response inside emulator then remove the app id and password from app settings.json file(it has worked for me) and add QnA kb keys in the app settings file. And if you want to test on web chat then add app id and password in the app settings file with QnA kb keys and publish it. Once your bot is published you will be able to test on web chat and change the messaging endpoint to your published url.
By the way if you are using v4 botframework, you will not require ngrok.
I think I might know what caused this - where did you get the Application ID and Application Password from? They need to be from a newly created "Bot" app in the Azure portal. If you don't have the right app+key combo, you can happily communicate with your bot through the emulator, for instance, but it won't be able to connect to other services (e.g. QnAMaker, MS Teams).
In the Azure portal, the "Web App Bot" template will create a Bot app AND a web hosting application in Azure, but there's also an option to create a "Bot Channels Registation" if you're using an existing sample application you've downloaded and are running on your local machine.
This "Bot Channels" option is basically just a placeholder of sorts in Azure, where all the key registration in Azure for the bot is done, but you can host the bot itself anywhere you like (for instance on your local machine, in which case you provide the ngrok address as the endpoint, something like: https://250a1f39.ngrok.io/api/messages (make sure you have the "/api/messages" on there).
On the Settings screen for the bot in the Azure portal, where you capture/update the endpoint, is the "Microsoft App Id" you need. There's also a link to "manage", which should take you to where you can get the password, but the link is currently broken (I think MS is working on fixing it), so to get the password you need a few more steps:
Go to the main Azure home page / main resources listing (small menu icon on top left in Azure)
Go to Azure Active Directory (yes, even in your own personal Azure subscription you would do this - there's still an Azure AD provisioned behind the scenes)
Go to "App Registrations" on the left menu
Go to "Applications from personal account" near the top of the page (NOT on the main top menu, a bit down)
In there you will find your new bot - open it up
Go to "Certificates and secrets"
Click the button to create a "New client secret"
Choose an expiry option and optionally give it a description.
Click Add and once it's added - that's the app password you need
I've been playing around, and created simple console app in C# that reads my gmail inbox, searches for email from the gym, and if I've scheduled group training and got the response email, creates google reminder. When I ran the app in local all works fine.
But I want to deploy it to Azure and created WebJob, and that is where the problems start. Locally I get pop-up window where I give app permission, but I cannot to that in WebJob. Than I created a service account, but I cannot enable domain-wide authority to the service account because I do not have G Suite, I use regular gmail. What are my options here? I've been reading and OAuth 2.0 Three legged implementation seems like the way to go?
If you are trying to have this app just for your gmail inbox then you can get a refresh token (locally for your app) and just hardcode that in your app.
If you want to make this app for other users then you'll have to do a lot more work and apply for app verification and implement 3 legged auth.