BotBuilder-Samples | Here you will find task | Bot library
kandi X-RAY | BotBuilder-Samples Summary
kandi X-RAY | BotBuilder-Samples Summary
This branch contains samples for the released version of the Microsoft Bot Framework V4 SDK for .NET, JS and Python. If you need samples for the Bot Framework V3 SDK, go here.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Display a message to the user
- Creates and handles all of the choices .
- Send a conversation to the end of the conversation
- Produces an alert attachment to the user .
- Create a new card command .
- Send Turn error message
- Response to create a new page
- Creates an adaptive creative .
- Read config file .
- send the end error
BotBuilder-Samples Key Features
BotBuilder-Samples Examples and Code Snippets
Community Discussions
Trending Discussions on BotBuilder-Samples
QUESTION
I'm trying to track the sms delivery status of the messages I send using the bot framework. I'm using Twilio, and sending proactive messages. Right now I'm trying to do so with twilio status callbacks
This is similar to this question, I tried that approach but I couldn't get it to work. I've added my url on the TwiML app and it is not firing. I have double and triple checked, and I suspect this url is somehow ignored or not going through with my current set up. I don't get any callbacks on the proactive message nor on the replies the bot sends to the user. However the flow works fine and I can reply and get proper responses from the bot. Edit: calling this "approach 1"
approach 2: I've also tried this doing some light modifications on Twilio adapter, to be able to add my callback just before create message. (I changed it so it uses a customized client wrapper that adds my callback url when creating the twilio resource) This does work, partially: when I reply a message from my bot, I get the status callbacks. But as the proactive message is sent using the default adapter, I don't get a callback on the initial message.
approach 3: Finally, I also tried using the TwilioAdapter when sending the proactive message but for some reason as soon as I send an activity, the TurnContext is disposed, so I can't save the state or do any subsequent actions. This leads me to believe twilio adapter is not intended to be used this way (can't be used on proactive messages), but I'm willing to explore this path if necessary.
Here is the modified Twilio Adapter:
...ANSWER
Answered 2022-Mar-09 at 16:51I found a fix for this problem, around approach 3, by changing the overload I use for ContinueConversation. Replace this :
QUESTION
Located in the BotBuilder-Samples GitHub repo: https://github.com/microsoft/BotBuilder-Samples
There is a sample app: 54.teams-task-module. This app demonstrates a task/fetch action with a Url to a Custom Form which is rendered by a Razor Page.
In the Bot, the OnTeamsTaskModuleFetchAsync
method is overridden to return a TaskModuleResponse
which tells the system to fetch the URL passed back to Teams in the response.
ANSWER
Answered 2022-Jan-27 at 08:28To be clear on this, authentication -is- possible, but only for web pages (Adaptive Cards don't need it). This auth would rely on the standard SSO Teams offers for Task Modules as well as Tabs. See here for intro guidance: https://docs.microsoft.com/en-us/microsoftteams/platform/tabs/how-to/authentication/auth-aad-sso?tabs=dotnet, especially:
The SSO API also works in task modules that embed web content.
So really your question kind of becomes "how do I do SSO for web content in Teams". Here's a great video, which includes a link to text (blog) version of the content: https://devblogs.microsoft.com/microsoft365dev/lets-decode-single-sign-on-sso-in-microsoft-teams-tabs/. Here's a working sample, with both Node and DotNet backend options: https://adoption.microsoft.com/sample-solution-gallery/pnp-sp-dev-teams-sample-tab-sso. Note that the samples and docs generally focus on doing an OnBehalfOf (OBO) operation to call Graph, but the principle remains the same - you get a JWT token that you can pass back to your backend, which you can then validate. You can also, from the token, get user info for the logged in user.
QUESTION
I have a c# Teams bot that uses multiple Generic Oauth2 providers. As an example I have used this sample https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/csharp_dotnetcore/46.teams-auth
Also I have added Generic OAuth2 to Bot Registration in Azure. Everything works fine with single Oauth provider.
User after logout process must be able to authenticate to another oauth2 provider. But I'm faced with problem that OauthPrompt caches previous credentials, and I don't know how to clear this cache and properly sign out user
I've already tried different approaches to sign out user:
- Using UserTokenClient
ANSWER
Answered 2022-Feb-21 at 08:17Found a problem. Bot was registered as a Singleton in services (services.AddSingleton <..>), аnd OauthPrompt dialog was added in waterfall step and didn't disposed. I have created different OauthPrompts for each Generic OAuth and added to dialog throught dialog constructor. And based user prompt choosed the right OauthPrompt
QUESTION
I want to build a Teams bot that can send proactive messages, including creating conversations even if the user has never had a conversation with the bot.
I followed the proactive sample and adapted it to send a notification as POST in the notify controller. I am able to continue a conversation, but when I try to create one, the user does not get any messages.
Here is my code to create a conversation from the notify controller:
...ANSWER
Answered 2022-Jan-06 at 18:15You can't start a conversation with a user that has never talked to your bot and when they did that you stored a conversation reference somewhere to use it when sending the proactive message.
What the proactive sample does is precisely that, store in memory the references to the conversations.
Teams assigns a user id that's unique to the bot-user relationship, so there's no way you can start a conversation even if you knew the user's active directory object id. Or at least not without using it to create the conversation reference.
Following the Proactive Sample
https://github.com/microsoft/BotBuilder-Samples/blob/95f2fa8440b4cf3f984c3f1cb82966b8b45d71e8/samples/csharp_dotnetcore/16.proactive-messages/Bots/ProactiveBot.cs#L26 That method is the one storing the conversation reference. Then the notify endpoint loops through the stored conversation references and send notifications. If your user didn't trigger that method ever, then the notify endpoint won't do anything with that user. I see that you modified the notify controller, but I'm not sure how you are getting the recipientId for a user that never talked to you.
Talking to a user for the first time, Microsoft Graph Approach.
To do that you'll need access to the Microsoft Graph API in the AAD tenant and use it to:
- Get the user
- Get the AppInstallationId if the user has installed your bot or potentially force the installation
- Use that to get the ChatId between the bot and that AppInstallation
- Use that ChatId to create the conversation reference for that user.
- Optionally store somewhere the reference to the user id and the conversation reference you created so you don't have to do all the previous steps for that user again.
Check this project out: https://github.com/microsoft/microsoft-teams-apps-company-communicator
QUESTION
I have searched a bit but didn't found something which is helping me. I created a bot for teams and like described in all examples I am using the appsettings.json to store the ID and the password for the bot (MicrosoftAppId and MicrosoftAppPassword). These are both handled by the framework somehow. But now I want to use an Azure Key Vault to store the secret instead of having the appsettings file.
So I found some examples explaining how to do this in BotFramework V3 with BotAuthentication Attribute and even something for BotFramework V4 here (working link for the linked example here). But even that example is old and does not exist anymore like that.
How am I supposed to do this for a teams bot and c# dotnet 3.1?
...ANSWER
Answered 2022-Jan-04 at 12:46You can use the following method to store the secret value
QUESTION
I have an authentication issue when sending requests to MS Teams from a corporate environment (with a dedicated tenant). I don't know if this is a bug or if I misuse the SDK. I already saw Teams samples provided by Microsoft but all of these run on public Azure without dedicated tenant, and I suspect my issue is somewhat related to using a dedicated tenant (having a dedicated tenant, with either a bug in SDK, either a misconfiguration somewhere in my code or in the bot manifest).
The application I'm working on is very business specific, so I made a project to reproduce issue with minimal code in this github repository: msteams-bot-auth-issue. Using this sample project requires to have a Teams bot on a dedicated tenant (I obviously cannot publish my corporate tenant details).
Basically, our application is splitted in two parts: one receives bot activities from MS Teams channel. Another processes them (first part forwards activities to the second one).
We correctly receive activities from MS Teams. But we are unable to call an MS Teams API to get Teams members in conversation (HTTP 401 with response message { "message": "Authorization has been denied for this request." }
).
Interestingly, if I use Microsoft.Bot.Connector v4.7.3 (version we actually use in our application), behavior is a bit different from Microsoft.Bot.Connector v4.15.0: in v4.7.3, no access token is requested before request to get conversation members; in v4.15.0, access token is successfully obtained, and put in request to conversation members request, but we still get an HTTP 401 response. Because we get HTTP 401 and not HTTP 403, I suppose access token is not recognized by MS Teams.
MS Teams response is always the same (HTTP 401 and error message), regardless an access token was included or not in request.
Access token request is composed of two requests:
- discovery (
GET https://login.microsoftonline.com/common/discovery/instance?api-version=1.1&authorization_endpoint=https://login.microsoftonline.com/XXX/oauth2/authorize
whereXXX
is our tenant name). - client credentials request (
POST https://login.microsoftonline.com/XXX/oauth2/authorize
whereXXX
is our tenant name).
Response contains access token, logs are showing "GetTokenAsync: Acquired token using ADAL in 876" (logs emitted by Bot Framework SDK).
Then actual conversation members request is sent with access token (with HTTP header Authorization: Bearer ...
), and response is always HTTP 401.
When I decode the JWT in https://jwt.io, I see these fields (among others):
- aud: https://api.botframework.com
- iss: https://sts.windows.net/XXX/ (where XXX is our tenant name)
- idp: https://sts.windows.net/XXX/ (where XXX is our tenant name)
- appid: YYY (where Y is our MicrosoftAppId)
Interestingly, if a set scope parameter in MicrosoftAppCredentials
class to AuthenticationConstants.ToChannelFromBotOAuthScope
, nothing changes in the JWT. So maybe access rights are not correctly setup for our application.
Maybe this is an issue with our application manifest, but I think we followed samples for MS Teams bots. permissions
field in our manifest is set to [ "identity", "messageTeamMembers" ]
.
There are lots of resources about Bot Framework and MS Teams, but I did not found any meaningful documentation for this scenario.
This may be caused by a corporate proxy, but I don't think so (I cannot guarantee it).
I precise this is an app to app authentication, also sometimes described as "regular bot scenario" (no user authentication involved here).
...ANSWER
Answered 2021-Dec-28 at 08:42Thanks to @StevenKanberg comment, the issue is resolved and was related to a corporate proxy and to tenant restriction feature.
Here are my observations:
Even if we use a corporate MS Teams tenant, we must not authenticate to this tenant. I don't really understand why, but we have to authenticate to MS Teams directly. So when instantiating MicrosoftAppCredentials
, argument ChannelAuthTenant
must not be set (meaning default tenant "botframework.com" will be used). Curiously, authentication worked with our tenant id, but access token was not usable/recognized by MS Teams (error 401 returned by MS Teams). With default tenant, and without proper tenant restrictions feature configuration, we could not authenticate in the first place (also with a more explicit error returned by MS Teams regarding tenant).
QUESTION
I am developing a Teams application with AspNetCore and React with typescript. I would like to add the messaging extension functionality to my app. I have tested the available samples for Action based Messaging extension from here - https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/csharp_dotnetcore/51.teams-messaging-extensions-action
I could run this sample and successfully connect to the bot I created in my Azure resource group.
Since I already have a Teams project created, I want to know if I can just add the code that makes the messaging extension work from this sample or do I need to have a separate project just for running the bot and messaging extension?
Note- I do not have a Bot implementation in my original project.
...ANSWER
Answered 2021-Nov-14 at 08:19It's definitely possible to combine them into the same project, you just need to make sure the endpoints all work correctly. The bot has, by convention, an endpoint at something like "/api/messages", but this is just a convention - you can use that or anything else you like, as long as you configure it properly in the Azure Bot registration so it knows what endpoint is for your bot, compared to the rest of the ASP.Net project.
QUESTION
I am sending an adaptive card to teams with the bot framework. That is working fine. The card should contain an action that opens a task module like explained here.
My code for the card looks like this:
...ANSWER
Answered 2021-Oct-14 at 16:29This might relate to how the platform is reading your json - the "" characters for example might not be handled properly on the desktop. To solve this, rather leave the json conversion up to the platform and, for your example in C#, create a strong type instead. The example you link to does exactly that - see this line:
QUESTION
I have created a simple Azure Bot from a Typescript template from this tutorial. I have tested it in the Bot Framework Emulator and now want to deploy it to Azure. I am trying to follow the instructions here. I get as far as the step "Deploy via ARM template with existing resource group" (I have already created a Resource Group).
So I am trying to run this command from the command line:
...ANSWER
Answered 2021-Sep-24 at 17:20I'm getting an error: az deployment: 'group' is not in the 'az deployment' command group. Sure enough when I look at the help for az deployment, there is no group command.
What version is your AZ CLI?
I am using 2.27.2
and I have it.
QUESTION
I can run this Teams Bot sample: https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/csharp_dotnetcore/57.teams-conversation-bot
When I need to add an AudioCard to play a mp3 song, I updated my code:
...ANSWER
Answered 2021-Aug-29 at 14:00Recall that the "Bot Framework" is a general Bot creation framework from Microsoft, with Teams just being one particular implementation. As a result, some things are simply not supported in a Teams context. In this case, as per the docs over here:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install BotBuilder-Samples
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page