Ui componentsTools

Overview

Add custom behavior to the Inkeep Assistant UI

Tools allow you to define custom functions that can be called by the AI assistant during chat interactions. These tools enable the AI to trigger actions in your application or the chat experience.

For example, you can use tools to escalate the conversation to a support channel or embed a sales call to action from within the experience.

Note
Note

Tools are available for the Enterprise tier. Please contact support@inkeep.com for details.

Overview

Tools are defined in the getTools function of the AI chat settings.

Each tool has a type, function definition, and a renderMessageButtons callback which determines which Message Buttons to display.

Message Buttons, if displayed, are shown in the bottom left of the assistant message and can trigger a variety of different actions when clicked by the user.

Action TypeDescriptionUse Case
open_linkOpens a URL in a new tab or current windowLink to documentation, external resources, or contact pages
invoke_callbackExecutes a JavaScript callback functionTrigger custom logic in your application, like showing a modal
open_formDisplays a configurable form dialogCollect user information for support tickets or contact requests

Currently, tools are invoked after the AI assistant has responded with its main message.

You can define tool schemas using zod and zod-to-json-schema or directly with a JSON Object Schema.

const aiChatSettings: InkeepAIChatSettings = {
  // ... other chat settings
  getTools: (ctx: ToolContext) => {
    return [
      {
        type: "function",
        function: {
          name: "callme",
          description: "Call this function every time",
          parameters: {
            // JSON Object Schema
          },
        },
        renderMessageButtons: ({ args }) => {
          return [
            {
              label: "My Button",
              action: {
                type: "open_link",
                url: "https://mydomain.com/page",
              },
            },
          ];
        },
      },
    ];
  },
};

onToolCall

The onToolCall callback function is triggered whenever the AI uses a tool.

const aiChatSettings: InkeepAIChatSettings = {
  // ... other chat settings
  onToolCall: (toolCall: FunctionToolCallArgumentsDoneEvent, ctx: ToolContext) => {
    console.log(toolCall.name);
    console.log(toolCall.arguments);
    console.log(ctx.conversation);
  },
};

Common Tool Use Cases

Here are a few common use cases:

  • Escalate to Support - Show a button that allows a user to escalate to support or hand off to other support channels.
  • Detect Sales Intent - Identify when a user is expressing buying intent and have a sales call to action.
  • Label Answers - Log question-answer data and annotations to your analytics system.

For common tool schema definitions, see Common Tools.

On this page