Skip to content

dyedurham/GlobalX.ChatBots.WebexTeams

Repository files navigation

GlobalX.ChatBots.WebexTeams

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

A .NET Core library containing implementations of core interfaces of GlobalX.ChatBots.Core for Webex 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.WebexTeams": {
        "WebexTeamsApiUrl": "https://api.ciscospark.com",
        "BotAuthToken": "token",
        "Webhooks": [
            {
                "Name": "name",
                "TargetUrl": "https://fake-url.com",
                "Resource": "Messages",
                "Event": "Created",
                "Filter": "mentionedPeople=me"
            }
        ]
    }
}

Using Dependency Injection

In the ConfigureServices method of your Startup.cs file, add the following:

using GlobalX.ChatBots.WebexTeams;

public IServiceProvider ConfigureServices(IServiceCollection services)
{
    // Add other service registrations here
    services.ConfigureWebexTeamsBot(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.WebexTeams;
using GlobalX.ChatBots.WebexTeams.Configuration;

public IServiceProvider ConfigureServices(IServiceCollection services)
{
    // Add other service registrations here
    var settings = new WebexTeamsSettings
    {
        WebexTeamsApiUrl = "https://api.ciscospark.com",
        BotAuthToken = "token",
        Webhooks = new[]
        {
            new Webhook
            {
                Name = "name",
                TargetUrl = "https://fake-url.com",
                Resource = ResourceType.Messages,
                Event = EventType.Created,
                Filter = "mentionedPeople=me"
            }
        }
    };

    services.ConfigureWebexTeamsBot(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 webex teams implementation of the library by calling the WebexTeamsChatHelperFactory.CreateWebexTeamsChatHelper method.

using GlobalX.ChatBots.Core;
using GlobalX.ChatBots.WebexTeams;
using GlobalX.ChatBots.WebexTeams.Configuration;

// Some code here

var settings = new WebexTeamsSettings
{
    WebexTeamsApiUrl = "https://api.ciscospark.com",
    BotAuthToken = "token"
};

WebexTeamsChatHelper webexTeamsChatHelper = WebexTeamsChatHelperFactory.CreateWebexTeamsChatHelper(settings);
webexTeamsChatHelper.Webhooks.RegisterWebhooksAsync();

About

Implementation of GlobalX.ChatBots.Core for WebexTeams

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages