Skip to content

AIFunction Tools

Example showing how to use Botpress operations as MEAI AIFunction tools with any IChatClient.

This example assumes using Botpress; is in scope and apiKey contains your Botpress API key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
// Create a Botpress client and wrap operations as AIFunction tools
using var client = new BotpressClient(apiKey);
var workspaceId = GetWorkspaceId();
var botId = GetBotId();

// Create AIFunction tools for use with any IChatClient
AIFunction listBots = client.AsListBotsTool(workspaceId);
AIFunction getBot = client.AsGetBotTool(workspaceId);
AIFunction listConversations = client.AsListConversationsTool(botId);
AIFunction listMessages = client.AsListMessagesTool(botId);
AIFunction getAnalytics = client.AsGetBotAnalyticsTool(workspaceId);

// Tools can be added to ChatOptions.Tools for use with any IChatClient