A .NET Core library containing implementations of core interfaces of GlobalX.ChatBots.Core for Microsoft Teams.
In order to use this bot, some configuration is required. This can either be done through appsettings.json, or at the time of configuring the bot.
// In appsettings.json
{
"GlobalX.ChatBots.MicrosoftTeams": {
// TODO
}
}
In the ConfigureServices
method of your Startup.cs
file, add the following:
using GlobalX.ChatBots.MicrosoftTeams;
public IServiceProvider ConfigureServices(IServiceCollection services)
{
// Add other service registrations here
services.ConfigureMicrosoftTeamsBot(Configuration);
return services;
}
If you have not provided your configuration inside appsettings.json, you may do so when you configure the bot:
using GlobalX.ChatBots.MicrosoftTeams;
using GlobalX.ChatBots.MicrosoftTeams.Configuration;
public IServiceProvider ConfigureServices(IServiceCollection services)
{
// Add other service registrations here
var settings = new MicrosoftTeamsSettings
{
// TODO
};
services.ConfigureMicrosoftTeamsBot(settings);
}
To start the webhooks, put the following in your Configure
method.
public void Configure (IApplicationBuilder app, IHostingEnvironment env)
{
// other configuration code here
app.ApplicationServices.GetService<IWebhookHelper>().Webhooks.RegisterWebhooksAsync();
}
You can get a microsoft teams implementation of the library by calling the
MicrosoftTeamsChatHelperFactory.CreateMicrosoftTeamsChatHelper
method.
using GlobalX.ChatBots.Core;
using GlobalX.ChatBots.MicrosoftTeams;
using GlobalX.ChatBots.MicrosoftTeams.Configuration;
// Some code here
var settings = new MicrosoftTeamsSettings
{
// TODO
};
MicrosoftTeamsChatHelper microsoftTeamsChatHelper = MicrosoftTeamsChatHelperFactory.CreateMicrosoftTeamsChatHelper(settings);
microsoftTeamsChatHelper.Webhooks.RegisterWebhooksAsync();