Line.OpenApi.Extensions.AI
1.0.0
dotnet add package Line.OpenApi.Extensions.AI --version 1.0.0
NuGet\Install-Package Line.OpenApi.Extensions.AI -Version 1.0.0
<PackageReference Include="Line.OpenApi.Extensions.AI" Version="1.0.0" />
<PackageVersion Include="Line.OpenApi.Extensions.AI" Version="1.0.0" />
<PackageReference Include="Line.OpenApi.Extensions.AI" />
paket add Line.OpenApi.Extensions.AI --version 1.0.0
#r "nuget: Line.OpenApi.Extensions.AI, 1.0.0"
#:package Line.OpenApi.Extensions.AI@1.0.0
#addin nuget:?package=Line.OpenApi.Extensions.AI&version=1.0.0
#tool nuget:?package=Line.OpenApi.Extensions.AI&version=1.0.0
English | 日本語
Line.OpenApi.Extensions.AI — LINE messaging tools for LLM tool-calling
Exposes the LINE Messaging use case as in-process Microsoft.Extensions.AI AIFunction tools, so an AI agent built on Semantic Kernel or any Microsoft.Extensions.AI host can operate a LINE bot — send messages, look up bot info / quota / a user profile, or validate a message payload — by calling tools.
It complements the out-of-process Line.OpenApi.Tools MCP server: use the MCP server for an external agent (Claude Desktop / Claude Code), and this package when you are building your own .NET agent and want the tools in-process, with no separate process.
- Safe by default — read-only unless you explicitly opt in to sending.
- Gated sending — a send policy and a human-in-the-loop hook, both set by you and never visible to the model.
- Tiny dependency surface — depends only on
Line.OpenApi.MessagingandMicrosoft.Extensions.AI.Abstractions. No implementation / DI packages are pulled in.
Target framework: net10.0.
Installation
dotnet add package Line.OpenApi.Extensions.AI
Quick start
using Line.OpenApi.Extensions.AI;
using Line.OpenApi.Messaging;
using Microsoft.Extensions.AI;
// The caller builds the MessagingClient (the same client the non-AI library code uses).
var line = MessagingClient.CreateWithStaticToken("CHANNEL_ACCESS_TOKEN");
// Safe by default: read-only tools only (bot info / quota / profile / message-validate).
IReadOnlyList<AIFunction> tools = LineMessagingAiTools.CreateReadOnly(line);
// Hand them to any Microsoft.Extensions.AI chat client:
var chatOptions = new ChatOptions { Tools = [.. tools] };
IChatClient agent = chatClient.AsBuilder().UseFunctionInvocation().Build();
var response = await agent.GetResponseAsync("How many messages can I still send this month?", chatOptions);
To let the model send, opt in explicitly and add your gates:
IReadOnlyList<AIFunction> tools = LineMessagingAiTools.Create(line, new LineAiToolOptions
{
EnableSending = true, // enables push / multicast / reply (default false)
AllowBroadcast = false, // broadcast = largest blast radius; separate opt-in
// Structural gate: bound the blast radius (operation / recipients / count). Return false to refuse.
SendPolicy = (ctx, ct) => new(
ctx.Operation != LineSendOperation.Broadcast &&
ctx.Recipients.All(id => myAllowList.Contains(id))),
// Human-in-the-loop / audit: inspect the actual content before it goes out. Return false to refuse.
BeforeSend = async (ctx, ct) =>
{
Console.WriteLine($"About to {ctx.Operation}: {ctx.MessagesJson}");
return await AskForApprovalAsync(ct);
},
});
Safety model
All safety gates are set by you (the developer) when the tools are created — via LineAiToolOptions. None of them is exposed as a tool argument, so a model — even one following a prompt-injected instruction — cannot flip them through a tool call.
| Gate | Default | Effect |
|---|---|---|
EnableSending |
false |
Produces the send tools (push / multicast / reply). Off → read-only toolset. |
AllowBroadcast |
false |
Also produces broadcast (sends to every friend). Requires EnableSending. |
SendPolicy |
null |
Evaluated before every send to bound blast radius. Return false to refuse. |
BeforeSend |
null |
Human-in-the-loop / audit hook after the policy. The place to review message content. |
DryRun |
false |
Send tools validate the payload only and never contact the API (skips policy / approval). |
A refused send never reaches the API and surfaces a LineSendRefusedException.
Tools
The read / validate tools are always produced; the send tools are produced only when the matching gate is set. The Arguments column is the whole argument list a model sees — the safety gates are not among them.
| Tool | Arguments | Kind | Produced when |
|---|---|---|---|
line_bot_info |
(none) | read | Always |
line_bot_quota |
(none) | read | Always |
line_bot_profile |
userId |
read | Always |
line_message_validate |
messagesJson |
validate (never sends) | Always |
line_message_push |
to, messagesJson |
send | EnableSending = true |
line_message_multicast |
to, messagesJson |
send | EnableSending = true |
line_message_reply |
replyToken, messagesJson |
send | EnableSending = true |
line_message_broadcast |
messagesJson |
send (all friends) | EnableSending = true and AllowBroadcast = true |
Tool names mirror the Line.OpenApi.Tools MCP tools. messagesJson is a JSON array of LINE message objects (1–5), the same shape the Messaging API accepts.
Semantic Kernel
The tools are plain AIFunctions, so Semantic Kernel consumes them directly:
kernel.Plugins.AddFromFunctions("Line", tools);
Notes
- Only the Abstractions are referenced.
AIFunctionFactorylives inMicrosoft.Extensions.AI.Abstractions; this package does not pull the implementation / DI packages. Bring your ownIChatClientprovider. - Content flows to your LLM provider. Message content and read-tool results are sent to whatever chat client you wire up, and
ctx.MessagesJsonis passed to your gates — treat tool arguments as potential PII in your logs. - Rate / cumulative-count limiting is the host pipeline's responsibility, not this package's.
- Released on its own cadence (tag
ai-v*), separate from the client libraries (v*) and the CLI / MCP tool (tools-v*).
Example
For a runnable end-to-end example — a scripted or a real model driving the tools through the gates, offline by default — see samples/Line.OpenApi.Samples.Ai.
Related documentation
- Repository & client libraries:
README.md - CLI / MCP tool:
Line.OpenApi.Tools(docs) - Design:
docs/LINE-dotnet-AI-plugin-design.md
License
MIT (see LICENSE at the repository root).
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Line.OpenApi.Messaging (>= 1.0.0)
- Microsoft.Extensions.AI.Abstractions (>= 10.9.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 33 | 8/20/2026 |