LINE Channel Connector for BotBuilder
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.
This channel connector works as part of OWIN pipeline. You need to tweak several places but See LineChannelConnectorV4Test project for how to use.
Update LINE Channel Secret and Channel Access Token in appsettings.json.
Update Startup.cs to include ASP.NET Core middleware in Configure method.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
_loggerFactory = loggerFactory;
// UserLINEChannel middleware converts incoming LINE event to BotFramework Activity
app.UseDefaultFiles()
.UseLINEChannel(new LINEConfig()
{
ChannelSecret = Configuration.GetSection("ChannelSecret")?.Value,
ChannelAccessToken = Configuration.GetSection("ChannelAccessToken")?.Value,
Uri = Configuration.GetSection("Uri")?.Value,
})
.UseStaticFiles()
.UseBotFramework();
}
services.AddBot<EchoWithCounterBot>(options =>
{
// This bot middleware replace ConnectorClient and use LINEConnectorClient
options.Middleware.Add(new LINEAdapterMiddleware(new LINEConfig()
{
ChannelSecret = Configuration.GetSection("ChannelSecret")?.Value,
ChannelAccessToken = Configuration.GetSection("ChannelAccessToken.Value,
Uri = Configuration.GetSection("Uri")?.Value,
}));
...
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
There are many future plans if some people actually using this.