Teams Custom Connector, get the installed channel, teams details - microsoft-teams

When developing a Teams Custom connector, I need to get the details where the connector is installed like teams id,channel id, teams Name, channel Name etc and pass those to the backend along with the webhookUrl and userId .
How should I achieve this?

For this, you can use the microsoft/teams-js library provided.
Import the app package from it.
and use the following code snippet.
const teamInfo={
channelId:'',
channelName:'',
teamId:'',
teamName:''
};
app.getContext().then((context) => {
console.log("checking");
console.log(context.channel.id);
console.log(context.channel.displayName);
teamInfo.channelId=context.channel.id;
teamInfo.channelName=context.channel.displayName;
teamInfo.teamId=context.team.groupId;
teamInfo.teamName=context.team.displayName;
});
then you can post teamInfo along with the config.webhookUrl, and other details

Related

How do I use a webhook using an existing bot with discord.py

I am trying to make a webhook where when a specific yt user posts a video I want my bot to post an emded link and text, however the catch is I am trying to add this to an existing discord.py bot that does other functions. I am using 'If this then that' to create the webhook but I don't know URL to use on this page in the Then That section. Am I doing it wrong? Does anyone know how to do this?
Thanks
Maybe try this:
import requests
discord_webhook_url = 'webhook url'
Message = {
"content": "some stuff here"
}
requests.post(discord_webhook_url, data=Message)

GraphQL requesting fields that don't exist without error

I'm trying to handle backwards compatibility with my GraphQL API.
We have on-premise servers that get periodically updated based off of when they connect to the internet. We have a Mobile app that talks to the on-premise server.
Problem
We get into an issue where the Mobile app is up to date and the on-premise server isn't. When a change in the Schema occurs, it causes issues.
Example
Product version 1
type Product {
name: String
}
Product version 2
type Product {
name: String
account: String
}
New version of mobile app asks for:
product(id: "12345") {
name
account
}
Because account is not valid in version 1, I get the error:
"Cannot query field \"account\" on type \"Product\"."
Does anyone know how I can avoid this issue so I don't recieve this particular error. I'm totally fine with account coming back with Null or just some other plan of attack for updating Schema's. But having it completely blow up with no response is not good
Your question did not specify what you're actually using on the backend. But it should be possible to customize the validation rules a GraphQL service uses in any implementation based on the JavaScript reference implementation. Here's how you do it in GraphQL.js:
const { execute, parse, specifiedRules, validate } = require('graphql')
const validationRules = specifiedRules.filter(rule => rule.name !== 'FieldsOnCorrectType')
const document = parse(someQuery)
const errors = validate(schema, document, validationRules)
const data = await execute({ schema, document })
By omitting the FieldsOnCorrectType rule, you won't get any errors and unrecognized fields will simply be left off the response.
But you really shouldn't do that.
Modifying the validation rules will result in spec-breaking changes to your server, which can cause issues with client libraries and other tools you use.
This issue really boils down to your deployment process. You should not push new versions of the client that depend on a newer version of the server API until that version is deployed to the server. Period. That would hold true regardless of whether you're using GraphQL, REST, SOAP, etc.

How to integrate bing spell-check key in microsoft botframework v4 along with other keys?

Even though i add the bing spell check key along with other keys in the .bot file, its not working .
Is there a way you could integrate the key in v4?
You can use the Spell Check Middleware provided by the Bot Builder Community.
For C#:
It is available through NuGet: https://www.nuget.org/packages/Bot.Builder.Community.Middleware.SpellCheck/
Sources: https://github.com/BotBuilderCommunity/botbuilder-community-dotnet/tree/master/libraries/Bot.Builder.Community.Middleware.SpellCheck
To use it, you have to add the Service in the declaration:
services.AddBot<Bot>((options) => {
options.CredentialProvider = new ConfigurationCredentialProvider(Configuration);
// more middleware
options.Middleware.Add(new SpellCheckMiddleware(Configuration));
});
And your configuration must include:
{
"SpellCheckKey": "<YOUR SPELL CHECK KEY HERE>",
"SpellCheckCountryCode": "sv",
"SpellCheckMarket": "sv-SE"
}
See the source page for more details on how to use it
For Node.js:
Npm package: https://www.npmjs.com/package/#botbuildercommunity/spell-check-middleware
Sources / How to use it: https://github.com/BotBuilderCommunity/botbuilder-community-js/blob/master/libraries/botbuilder-spell-check-middleware/README.md

Laravel Notification System

I use a simple Query Code to display Toastr in my application. This is the code:
<script>
document.getElementById("test").onclick = function() {
$.toaster({
priority : 'success',
title : 'yassine Jennane',
message : 'yassine jennane test toster'
});
};
</script>
My problem is when there is another user connected in my application, he isn't receiving the notification at the same moment as the first one do. Why?
Link of the notification script + demo: jQuery & Bootstrap Based Toast Notification Plugin
This won't work like that. You need to create Event Classes and Broadcasting Channels. Further you need to have some socket.io node.js side so that the notifications are shown live on the client side.
You probably don't have experience in this subject, so I would suggest to do following things:
Have a look at following in the documentation: https://laravel.com/docs/5.7/broadcasting
Watch following tutorial on laracasts: https://laracasts.com/series/real-time-laravel-with-socket-io/episodes/1
Of course you can have a look at some other tutorials you find on the internet.
The plugin you're using is a Jquery plugin that makes toasts in user browser, it works only for connected user, if you want to show notification for all the users using your application, you should use Cloud Messaging service, Firebase is good one.

Using MS Teams as Channel: Authentification Dialog (GetTokenDialog class from Microsoft.Bot.Builder.Dialogs) doesn't popup

How can I use the new authentification feature in Bot Builder with MS Teams?
There seems to be an issue with Teams (see Login user with MS Teams bot or https://github.com/Microsoft/BotBuilder/issues/2104), seems if this is not considered in GetTokenDialog?
Is there any chance to get around this?
Just found the reason why it won't work with Teams. In method Microsoft.Bot.Connector.Activity.CreateOAuthReplyAsync(), Parameter asSignInCard has to be set to True for MSTeams, then, the line new CardAction() { Title = buttonLabel, Value = link, Type = ActionTypes.Signin } has to be changed to new CardAction() { Title = buttonLabel, Value = link, Type = ActionTypes.OpenUrl } because MS Teams can obviously not deal with Action type Signin. Hope, the MS developers will fix that method soon.
There are a few things you need to do to get this to work. First you need to create a manifest file for your bot in teams and whitelist token.botframework.com. That is the first problem.
From teams itself in AppStudio you create a Manifest. I had to play around with this a little bit. In AppDetails... Let it generate a new ID. Just hit the button. The URLs really don't matter much for testing. The package name just needs to be unique so something like com.ilonatag.teams.test
In the bots section you plug in your MS AppId and a bot name. This is a the real MSAPPID from your bots MicrosoftAppId" value=" from web.config in your code.
Ok now in "finish->valid domains" I added token.botframework.com and also the URL for my bot just in case. so something like franktest.azurewebsites.net
This part is done but you are not quite done... in your messages controller you need to add this since Teams sends a different verification than the other clients.
if (message.Type == ActivityTypes.Invoke)
{
// Send teams Invoke along to the Dialog stack
if (message.IsTeamsVerificationInvoke())
{
await Conversation.SendAsync(message, () => new Dialogs.RootDialog());
}
}
It took me a bunch of going back and forth with Microsoft to get this sorted out.
This is a known problem using OAuthCard in MS Teams. To solve it, you can change the Button ActionType from signIn to openUrl using this solution on github

Resources