Call and online meeting bot - Peer to peer call is terminated automatically - botframework

I am trying to develop a simple bot that is supposed to answer incoming call made in personal chat with bot. The bot is employing application hosted media to play or get access to media streams. I am making use of classes and controllers that are implemented in Huebot sample project at Github. The bot is registered on MS Azure and i am using ngrok for local testing and debugging. While debugging after making the call, breakpoints are hit that are placed in 'CallsOnIncoming' or 'CallsOnUpdated' event handlers. So my bot configurations over Azure and in MS Teams seem to be correct. For setting up media platform, I have installed the wildcard SSL certificated issued by Let's Encrypt and CName records are created for corresponding tcp URLs exposed by ngrok. The environment is multi-tenant i.e. bot registration is done on another tenant, while bot is installed and tested in MS Teams on another tenant.
These are Media platform settings:
MediaPlatformInstanceSettings = new MediaPlatformInstanceSettings()
{
CertificateThumbprint = "0B687..................",
InstanceInternalPort = 8445,
InstancePublicPort = 15410,
InstancePublicIPAddress = new IPAddress(0x0),
ServiceFqdn = "4.mycustomdomain.com",
},
Here's the snapshot for ngrok:
The problem is, when call is made to the bot, after 5 to 10 seconds call is terminated automatically. Whereas he Call status should turn to 'Established' and the call shouldn't end until user does this.Please guide, what could be wrong.

The call is terminating because Teams can't connect to your media endpoint of the InstancePublicIPAddress / InstancePublicPort. It timesout (i believe in 15 seconds) and terminates the call when it can't get a media connection.
You need to put the IP address of 4.tcp.ngrok.io from your running ngrok settings above into it.
e.g.
InstancePublicIPAddress = Dns.GetHostEntry("4.tcp.ngrok.io").AddressList[0]
You may want to put error checking around the GetHostEntry call in production code.

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.
:(

Time out, Image send, Email track adding to bot framework composer

I have developed a chatbot for IT Support team in our company, running on MS Teams using Bot Framework Composer. I have integrated it with Azure logic apps to send emails to IT Support team.
I want to know how to;
Get user's email address in MS Teams (We can get user's name using ${turn.activity.from.name} telemetry track event)
Set a timeout period
Send a Image to using HTTP request in JSON format (Then users can upload the screenshot of their issue)
Yes, you can get the user's email address in MS teams by making fetching the roster or user profile or make use of get single member detail from this documentation.
Not sure if you want to restart a conversation or track the last time a message was received from a user, but you can refer to Expire a conversation documentation to get started with.
MS Teams makes use of webhooks to integrate with external apps and makes use of Standard HTTP message exchange feature where responses appear in the same chain as the original request message and can include any bot framework message content, for example, rich text, images, cards, and emojis.

Bot Framework serviceUrl

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.

MS Teams bot no longer receives messages

After moving MS Teams bot to another server, it no longer replies to messages. It still successfully sends proactive messages on its own, however responding to messages no longer works. Messaging endpoint stayed the same (only IP changed)...
I watched for network activity when clicking a button in adaptive card (posted by bot) and error 502 is reported with {"errorCode":1008,"message":"Invoke agent action failed with status code: BadGateway"} returned. I'd appreciate any ideas how to sort this out... Thank you.
If the IP / URL of your bot changed you need to make sure to update the messaging endpoint in the bot definition.
If you registered your bot in dev.botframework.com or azure there's a setting "messaging endpoint url" which you need to update and point to the new ip.
If just the IP behind your URL changed, it might be some caching/dns issue on MS Teams end. Did you try to reinstall the bot completely?

oauthCard login opens empty window

I have the following code:
import { ActivityTypes, CardFactory, TurnContext } from "botbuilder";
export class MyBot {
/**
* Handles incoming activity, received from a user, processes it, and replies as needed
* #param {TurnContext} context on turn context object.
*/
public onTurn = async (turnContext: TurnContext) => {
const oauthCard = CardFactory.oauthCard("ms-graph", "Login", "Please sign in so I know who you are");
return await turnContext.sendActivity({ attachments: [oauthCard] });
}
}
When I run the bot in bot emulator framework, I see the login button. When I click on it however, it just opens an empty signin window that's all white.
I've also configured authentication in Azure:
Edit: I've also configured the app id and password in my .bot file.
There is an option to use Azure Service Bus in place of ngrok which may work for you. It functions much the same but gives you control over where your data is traveling when "tunneling", among other benefits. As it's an Azure service, it can live in the same subscription you already access.
In short, you'll create a local client application that connects your bot via a relay to the Azure Service Bus service. The service bus namespace/relay replaces the messaging endpoint in the bot settings in Azure (for testing). In this way your bot running on localhost can connect to external services. Just be sure to use the same endpoint in Emulator that you use in the Azure bot settings, including the "/api/messages".
The instructions found here can guide you thru the process of setting up and running. The steps are a little long looking but the process itself is fairly simple. There are two options to build: a .NET Framework and a .NET Core. I would recommend the "Framework" version unless you need to run this on a Mac. This isn't an official MS blog (yet) but expect it to show up there.
Hope of help!

Resources