Skip to content

Latest commit

 

History

History
103 lines (80 loc) · 3.17 KB

README.md

File metadata and controls

103 lines (80 loc) · 3.17 KB

GlobalX.ChatBots.MicrosoftTeams

GlobalX.ChatBots.MicrosoftTeams nuget package GlobalX.ChatBots.MicrosoftTeams on Travis CI GlobalX.ChatBots.MicrosoftTeams on Codecov commits contributors commitizen friendly

A .NET Core library containing implementations of core interfaces of GlobalX.ChatBots.Core for Microsoft Teams.

Getting started

Configuration

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.

Example Configuration

// In appsettings.json
{
    "GlobalX.ChatBots.MicrosoftTeams": {
        // TODO
    }
}

Using Dependency Injection

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();
}

Without Dependency Injection

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();