项目作者: kenakamu

项目描述 :
LINE Channel Connector for BotBuilder
高级语言: C#
项目地址: git://github.com/kenakamu/LINEChannelConnector.git
创建时间: 2018-07-22T18:41:25Z
项目社区:https://github.com/kenakamu/LINEChannelConnector

开源协议:MIT License

下载


LINEChannelConnector

LINE Channel Connector for BotBuilder v4
You can find BotBuilder v3 version in v3 branch

The original idea and many source codes are from BotBuilderChannelConnector which “Allows to diretly interface channels without using the Microsoft Bot Development portal.”

There are several reasons that I couldn’t simply add LINE Channel to the repository, thus I created new one.

This is yet early beta version.

How to use

This channel connector works as part of OWIN pipeline. You need to tweak several places but See LineChannelConnectorV4Test project for how to use.

  1. Update LINE Channel Secret and Channel Access Token in appsettings.json.

  2. Update Startup.cs to include ASP.NET Core middleware in Configure method.

  1. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  2. {
  3. _loggerFactory = loggerFactory;
  4. // UserLINEChannel middleware converts incoming LINE event to BotFramework Activity
  5. app.UseDefaultFiles()
  6. .UseLINEChannel(new LINEConfig()
  7. {
  8. ChannelSecret = Configuration.GetSection("ChannelSecret")?.Value,
  9. ChannelAccessToken = Configuration.GetSection("ChannelAccessToken")?.Value,
  10. Uri = Configuration.GetSection("Uri")?.Value,
  11. })
  12. .UseStaticFiles()
  13. .UseBotFramework();
  14. }
  1. Update Bot middleware in ConfigureServices method.
  1. services.AddBot<EchoWithCounterBot>(options =>
  2. {
  3. // This bot middleware replace ConnectorClient and use LINEConnectorClient
  4. options.Middleware.Add(new LINEAdapterMiddleware(new LINEConfig()
  5. {
  6. ChannelSecret = Configuration.GetSection("ChannelSecret")?.Value,
  7. ChannelAccessToken = Configuration.GetSection("ChannelAccessToken.Value,
  8. Uri = Configuration.GetSection("Uri")?.Value,
  9. }));
  10. ...

How this works.

There are two things this connector does.

Convert incoming LINE request to BotBuilder Activity
Obviously, when LINE sends request to the bot, it has LINE format. The connector works as ASP.NET core OWIN middleware to convert LINE format to BotBuilder Activity.

Convert outgoing BotBuilder Activity to LINE reply
This is implemented in LINEClient but specify LINEConnectorClient as IConnectorClient in TurnContext if it comes from LINE. See LineAdapterMiddleware.cs for detail.

Limitation

  • You need to use either Developer mode or paid mode as it uses push a lot.
  • LINE unique capabilities are not imeplemented yet.

Future plans

There are many future plans if some people actually using this.

  • Support LINE specific features, such as URL Schema, LIFF, etc.
  • Support Flex Messages.