Bot Framework serviceUrl - botframework

I am developing a Notification Only bot to enable proactive Teams notifications.
As far as I am aware it is necessary to store the ServiceUrl from an incoming message to the bot endpoint. I have read that it is also possible that service Url can change in the future (although unlikely) and that if this happens the serviceUrl should be updated and used for future messages.
Using a test O365 instance in UK region I see the following behaviour:
When I add member to team or install the app to a team, the service Url comes through as:
https://smba.trafficmanager.net/uk/
When I remove a member from team or remove the app from team, the service Url comes through as:
https://smba.trafficmanager.net/emea/
If our service tries to send a notification via the rest api, using the /emea ServiceUrl it returns a 403 Forbidden
Doing the same using an O365 instance in US region the service Url is allways:
https://smba.trafficmanager.net/amer/
Is this expected behaviour or a bug?
Are there any rules on when the Service Url should be updated and when it should not?
Many Thanks.

Related

Bot Framework dotnet Slack adapter fails to verify Slack request when changing the Events Request Url

I have a Slack bot that is working fine and interacting with users. I'm using Bot Framework composer and the Slack Adapter.
In the Slack API portal I'm trying to change the Events Request Url the app uses to send Slack Events to my bot.
When I do that, slack sends a challenge request to my bot. The bot first tries to verify that the request is really coming from Slack following: https://api.slack.com/authentication/verifying-requests-from-slack#a_recipe_for_security
The problem is that this is failing and I can't understand why.
I see that Slack is sending all the right content, and that the ClientSigningSecret is being read, otherwise the other calls to the bot wouldn't work.
I know it's a bit far fetched to ask this since it seems to be a problem on my side. But since the bot is validating the requests just fine when users talk to the bot, and the code is from the Slack Adapter which is open source and there's nothing else I can thing of..... maybe someone struggled with the same problem.
I created a support ticket to Slack and they came back pretty quickly.
Pre publish state
Before publishing a Slack app the only configs that exist are the ones you see in the App configuration page. Those are what you use to test your app, this includes the secrets to authenticate the incoming messages from Slack into your backend.
After you publish your Slack App for the first time
Once your app is published, the production version that your users use will see the original settings, including the secrets and these are the ones your backend will get.
The settings you see in the configuration page are like development mode and they won't be persisted into the published app until you request Slack to approve your changes. That's sounds great and is what one would expect, but what you don't see and have no way of imagining is happening is that there are some development time secrets that are different from the ones you see on the settings screen.
When you change the endpoint url to be sent to your backend so that it can return the challenge and Slack would accept the new url, the message payload goes with this development secret and not the one you configured your backend with. Thus your backend will reject the call since it thinks it's not coming from Slack.
Proposed solution from Slack
Don't validate the signature of the incoming request for this type of call in an already published app. I don't like it but there was no other workaround unless Slack changes this. So what I did was:
Remove that check only for this request from the backend and publish to production.
Make the url change in Slack.
Revert the change from the backend.
:(

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,

Sending a message to users as a bot in bot channel of Microsoft Teams using the Graph API

I have created a bot by following the steps mentioned in the doc.I have authenticated user using oauth 2.0 (auth code grant) as mentioned in the doc and in reverse I got a access token. But when I send message to channel in the teams using (/teams/{id}/channels/{id}/messages) API the message was sent on behalf of me. But I want my bot as the sender of message. Here is the image of the message that I have sent using the above API. and is there any way to send direct message to user as a bot?
Instead of using the Graph, there's another approach using the Bot Framework itself, to send a message to a team channel, a group chat, or a 1-1 conversation. The code doesn't even need to live inside the bot itself, it just needs to leverage the bot framework under the covers (for example, I have several Azure Functions that pro-actively message users). This idea is called "Proactive messaging" and you can read more about it in the docs here.
You do need to get certain fields when the user first installs the bot though, or any time the bot receives a message. I've described that more at Programmatically sending a message to a bot in Microsoft Teams. You haven't said what language you're using, but there are examples for a bunch of them - I can send you links if you let me know what you're using.

How can I setting webhook callback url for Bot Framework (Skype)?

I need to setting URL for a service that was been receive event for new messages. According to Microsoft documentation I can set the url for, e.g., Facebook (https://learn.microsoft.com/en-us/azure/bot-service/bot-service-channel-connect-facebook?view=azure-bot-service-3.0#generate-a-page-access-token), but I can't find information about setting url for Skype.
But I can specify a message endpoint for my bot. The message endpoint is a webhook url?
Sorry for my bad English
See also: Messaging Webhook for Microsoft skype bot
PS: about web hooks for Skype: https://msdn.microsoft.com/en-us/skype/trusted-application-api/docs/webhooks
I'm not sure if you are using C# or node but I will try my best to answer both.
The Webhook is just the endpoint for your calling controller in C# so for example in the sample from the botbuilder repository in C# They are using the CallController.cs Your webhook would be https://{your site}/api/call.
In the sample from node they are using server.post('/api/calls', connector.listen()); so your webhook url would be https://{your site}/api/calls in this setup

MS bot not working on Skype for Business

I have registered an MS bot on over Skype for business channel, the bot was searchable and responding for few days but no I am getting below error in "Bot Channel registration">channels> issues
"There was an error sending this message to your bot: HTTP status code NotFound".
On SFB I get error
"Error happened in Skype for Business service when reaching bot service".
Bot is hosted over azure in web API working and fine in Web channel, whereas with SFB its not hitting the API endpoint.
Every time I send a message from skype for businesss, I get the same error on bot channel registration.
Environment is a hybrid of Lync 2010 and Skype for business online and after registration bot was searchable and responding to users on SFB online.
What could be the possible reason for this error?
For my situation I realized that if I dont change messaging endpoint area everything goes well.I mean I was adding Microsoft App Id to my endpoint like https://myendpoint/{{MicrosoftAppId}} after bot created .It is because you can have your microsoft app id after you create the bot.What is awkard is that despite messaging endpoint looks an editable area when I change it I am falling into error place where my endpoint is never called[again webchannel works fine , it looks Skype For Business needs some refactoring]. However I found that if I dont change this endpoint url bot works fine for Skype For Business and my endpoint is hit successfully .So keep your messaging endpoint constant and set it only when creating your bot.

Resources