Creating custom tools
Add custom tools to GitBook Assistant to allow it to interact with your product, website, and more
window.GitBook("configure", {
tools: [
{
// Register the tool with a name and description.
name: "create_ticket",
description:
"Create a ticket for the user. You MUST fill in the ticket_issue field.",
// The input schema is data that can be accessed in the execute function.
inputSchema: {
type: "object",
properties: {
ticket_issue: {
type: "string",
description:
"The issue to create the ticket for. If unknown, ask the user first.",
},
},
required: ["ticket_issue"],
},
// An optional confirmation button that shows before the execute function is run.
confirmation: { icon: "circle-question", label: "Create support ticket?" },
// The execute function is the function that will be called when the tool is used.
execute: async (input) => {
const { ticket_issue } = input;
// Create a ticket with the user's issue
const ticket = await fetch("/api/tickets", {
method: "POST",
body: JSON.stringify({ issue: ticket_issue }),
}).then((r) => r.json());
return {
// The output is passed back to the AI.
output: {
ticketId: ticket.id,
status: "success",
},
// The summary is shown to the user.
summary: `Created ticket #${ticket.id} for ${ticket_issue}`,
};
},
},
],
});How it works
Key
Description
Last updated
Was this helpful?