Official library for building ChatAIze chatbot add-ons.
- Install the latest version of the .NET 9.0 SDK - https://dotnet.microsoft.com/en-us/download/dotnet/9.0.
- Create a new C# Class Library project.
- Install
ChatAIze.PluginApi
NuGet package. - Create a class that implements the
IPluginLoader
interface from theChatAIze.Abstractions.Plugins
namespace. Alternatively, you can implement theIAsyncPluginLoader
interface for asynchronous loading. - In the
Load
method (orLoadAsync
), construct and return a new instance of theChatbotPlugin
class with the specifiedId
andTitle
. - Add settings, functions, conditions, and actions to your plugin:
plugin.AddStringSetting()
,plugin.AddFunction()
,plugin.AddCondition()
,plugin.AddAction()
, etc. - Build the project in Release configuration to generate a DLL file.
- Upload the generated DLL file from the chatbot dashboard: Integrations > Manage Plugins > Upload.
- The chatbot will automatically load the plugin, and its functionality should be available immediately.
- Verify that the plugin is listed under: Integrations > Manage Plugins.
dotnet add package ChatAIze.PluginAPI
Install-Package ChatAIze.PluginAPI
The Load
and LoadAsync
methods are called automatically when the chatbot server starts or when the plugin is uploaded via the dashboard.
using ChatAIze.Abstractions.Plugins;
using ChatAIze.PluginApi;
namespace ExamplePlugin;
public class ExamplePluginLoader : IPluginLoader
{
public IChatbotPlugin Load()
{
var plugin = new ChatbotPlugin
{
Id = "com.example.plugin",
Title = "Example Plugin"
};
return plugin;
}
}
using ChatAIze.Abstractions.Plugins;
using ChatAIze.PluginApi;
namespace ExamplePlugin;
public class ExamplePluginLoader : IAsyncPluginLoader
{
public async ValueTask<IChatbotPlugin> LoadAsync(CancellationToken cancellationToken = default)
{
await Task.Delay(1000, cancellationToken); // Simulate some async work
var plugin = new ChatbotPlugin
{
Id = "com.example.plugin",
Title = "Example Plugin"
};
return plugin;
}
}
All functions added to the plugin are discoverable by the chatbot and can be called on-demand during conversations.
Start by writing a normal C# method, then register it with the plugin using plugin.AddFunction()
.
- Function names must be unique across all loaded plugins.
- Asynchronous functions and cancellation tokens are supported.
- It is recommended to use simple parameter and return types (
string
,int
,bool
, etc.) or custom classes with primitive properties. - Returned objects are serialized to JSON and visible to the chatbot.
- You can optionally add
IFunctionContext
parameter to access conversation details, user info, plugin settings, and more.
using ChatAIze.Abstractions.Chat;
using ChatAIze.Abstractions.Plugins;
using ChatAIze.PluginApi;
namespace ExamplePlugin;
public class ExamplePluginLoader : IPluginLoader
{
private readonly HttpClient _httpClient = new();
public IChatbotPlugin Load()
{
var plugin = new ChatbotPlugin
{
Id = "exampleplugin",
Title = "Example Plugin",
};
plugin.AddFunction(GetDogPhoto);
return plugin;
}
public async Task<string> GetDogPhoto(IFunctionContext context, CancellationToken cancellationToken = default)
{
if (context.User.Email is null || !context.User.Email.EndsWith("@example.com", StringComparison.OrdinalIgnoreCase))
{
return "You cannot use this function.";
}
if (context.IsPreview || context.IsDebugModeOn || context.IsCommunicationSandboxed)
{
return "Testing...";
}
var response = await _httpClient.GetStringAsync("https://dog.ceo/api/breeds/image/random", cancellationToken);
return response;
}
}