Calling getAuthToken inside a Teams Bot's Task Module - microsoft-teams

I have a Teams Bot which can display a task module. This task module is a React app hosted in a separate Azure App Service in the same tenant and is accessible from a public endpoint. This React app is using the node package #microsoft/teams-js, and is calling getAuthToken() to try obtain a token from Teams for the user currently logged in.
The Bot's Teams manifest has been updated to include the following:
"webApplicationInfo": {
"id": "XXXXXX",
"resource": "api://PUBLIC-ENDPOINT-URL-OF-REACT-APP/XXXXXX"
}
where XXXXXX is the Bot's app id. The Bot's Application ID URI for the Bot's App registration also matches the webApplicationInfo.resource value, as mentioned in the documentation for enabling SSO.
When I call getAuthToken() I am receiving the error: Error: resourceDisabled.
Does anyone know what is triggering this error? I have been engaging with Azure support technicians who have been unable to provide any help. Thanks

Related

Teams Toolkit HelloWorld chat bot - Failed to send

I’ve just downloaded Teams Toolkit onto VSCode and used the plugin to create a Command Bot project. Completed all the prerequisites and configurations on my tenant (I’m the admin for our 365 business account)
Everything installs great.
I hit f5 to launch the debugger.
All prerequisite checks pass.
Chrome opens
I can [Add] my local debug bot into the web app version of teams
I go to send any message OR the helloWorld command that comes with the template app and it gives me “Failed to send message” error.
When I hit F12 to bring up the Chrome dev tools and go into the network tab to see the call that is being sent, I see and Error as the response payload: errorCode 201 errorSubCode 1 with the message “One or more of the user ids provided are not valid."
Payload:
{
"members": [
{
"id": "8:orgid:xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"role": "Admin"
},
{
"id": "28:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"role": "Admin"
}
],
"properties": {
"threadType": "chat",
"chatFilesIndexId": "2",
"uniquerosterthread": "true",
"fixedRoster": "true"
}
}
Response
{
"errorCode": 201,
"message": "One or more of the user ids provided are not valid.",
"standardizedError": {
"errorCode": 201,
"errorSubCode": 1,
"errorDescription": "One or more of the user ids provided are not valid."
}
}
I haven’t written any custom code or made any changes. Just trying to launch the bot straight from Toolkit creation.
I've also tested the ngrok session that is connected to make sure that communication back to me is working fine. I see logging when I try to hit the ngrok url so I feel this is a failure at the point of Teams trying to send to their API.
I’ve followed all the steps in the documentation regarding setup. I would appreciate any help anyone would have on this.
Thank you
This is probably caused by incorrectly bot identity used in Teams channel registration in Bot Framework. Not quite sure what happen when calling the bot framework service to do the bot registration herre.
You can check if your App ID and password is correctly in Bot Framework registration:
The bot credentials in .fx configs:
The app password can be decrypted from local.userdata
To resolve this, could you please try one of the following solutions:
Create a new Command Bot and run F5 again.
Or, you can delete the local.userdata and state.local.json files in your current project. And then re-run F5, the toolkit should create a new AAD app for your bot registration in this case.

Add Google Chat App to a space using REST API

I have a Google Chat App (running an App Script) that needs to add itself to a Google Space.
According to the documentation Docs
a chat app can add itself to a space. (I've already joined the Developer Preview Program).
The problem is that the API's response is always 403 with message 'Caller must be a human user with a Google Workspace account with access to Google Chat.'.
Why the caller has to be a human user if the documentation clearly says that a chat app can add itself to a space?
Currently, my app makes a request to the following endpoint:
POST https://chat.googleapis.com/v1/spaces/XXXXX/members
with the following body:
{ "member": { "name": "users/app", "domainId": "company.it", "type": "BOT" } }
The access token is retrieved using a Service Account (the same as the chat app)

In virtual assitent ,IBotFrameworkHttpAdapter.Adapter.Processasync menthod render the error :"Error invoking the skill id: error code 401."

We are trying to create virtual assistant bot microsoft teams. When we are trying to send request to skill bot from root bot using SkillClient.PostActivityAsync method, while debugging request hits botcontroller of skill bot. But it return 401 unauthorized error. If we try same in local using bot framework emulator (without using app id and password) it is working as expected. And how we can resolve this unauthorized error?
"When we use root bot with the different simple skill bot, it is working. but when we use app having client app (for tabs and Messaging extensions built using react) and additional authorization required for it. at that time it is throwing the above error"
Thanks!

Azure Bot messaging endpoint does not get teamMemberRemoved event when the Bot App is removed from Teams

I created an Azure Bot and set the Messaging Endpoint to my web-app, which is not hosted on Azure.
I created a deploy package zip as a Teams App to be deployed on Teams and use my bot.
My messaging endpoint gets the ConversationUpdate events with membersAdded type when the customer adds my bot to Teams, and when users are added. The events are sent to the Messaging Endpoint configured in my bot.
When the customer deletes the App from Teams I do not get any event to the messaging endpoint.
According to https://techcommunity.microsoft.com/t5/microsoft-teams/which-event-fired-when-someone-uninstall-your-app-in-microsoft/m-p/1610299 I expected to get an event with type teamMemberRemoved to the bot messaging endpoint.
I need to know the Teams App was removed so I can clean up resources on my end, and indicate in my UI to the customer that the bot is no longer configured for his Teams team.
I tried adding and removing the App from my Teams account a few times but never got the expected event to the messaging endpoint.
How can I know that my App was uninstalled on a Teams team?
If you just want to know when the App is getting added or remove you can use OnInstallationUpdateAsync, here you will get the type installationUpdate and action as remove when it gets uninstalled.
I tried with onConversationUpdateAsync as well and got the request as . Please confirm once if you are handling it property,

How to check credentials against botframework api

I'd like to check that my bot credentials (appId + appSecret) are ok to connect to https://api.botframework.com/bot/v1.0/messages.
I can't send a real message because i have no conversation running so I tried to post the following json message :
{ "type": "Ping"} but the response i got was
{
"error": {
"message": "Expression evaluation failed. Object reference not set to an instance of an object.",
"code": "ServiceError"
}
}
Is there any way to check if my access to the api is ok?
If you've registered your bot, you can visit the Bot Framework page, click on the My Bots menu, and select your registered bot. On your bot page, scroll down to the bottom left and there's a test box.
Also, you can use the emulator. It has a place in the upper right corner to replace the default credentials with your bot credentials. Then change the URL to where you have your bot deployed. Tip: remember to append 'api/messages' to the URL.
Download the BotFrameworkEmulator to test connectivity to your bot. It works on windows and OSX if you have mono installed. You can change the default settings that the emulator uses by typing '/settings' after running it. You will be prompted to enter your appId, appSecret and url endpoint for sending and receiving messages to/from your bot.
You can also use the directline rest api to initiate conversations and send messages to your bot

Resources