Ui componentsTools

Escalate to Support

Dynamically direct users to support as needed

Overview

You can use tools to identify when the AI assistant can't fully address a user's question and provide appropriate support options.

A button can be shown in the assistant message that can use actions to:

  • Link to a support page
  • Have the user fill out a support form
  • Transfer to live chat
Note
Note
Tools are available for the Enterprise tier. Please contact support@inkeep.com for details.
Example of the escalate to support tool

Answer Confidence Tool

This example uses the provideAnswerConfidenceSchema from Common Tools to determine the AI assistant's confidence level. You can define your own classifications or logic for the escelation paths you prefer.

When the answer is not confident, we can show a dynamic button to escalate to support.

import { z } from "zod";
import { zodToJsonSchema } from "zod-to-json-schema";
import type { ToolFunction } from '@inkeep/cxkit-react';
import { provideAnswerConfidenceSchema } from './common-tool-schemas.ts';
 
const aiChatSettings = {
  getTools: () => [
    {
      type: "function",
      function: {
        name: "provideAnswerConfidence",
        description: "Determine how confident the AI assistant was and whether or not to escalate to humans.",
        parameters: zodToJsonSchema(provideAnswerConfidenceSchema),
      },
      renderMessageButtons: ({ args }) => {
        const confidence = args.answerConfidence;
        if (["not_confident", "no_sources", "other"].includes(confidence)) {
          return [
            {
              label: "Contact Support",
              icon: { builtIn: "IoHelpBuoyOutline" },
              action: {
                type: "open_link",
                url: "/support",
              },
            }
          ];
        }
        return [];
      },
    } as ToolFunction<{
      answerConfidence: string;
      explanation: string;
    }>,
  ],
};

Support Ticket Form

This example embeds a form for creating support tickets directly within the chat interface:

import { z } from "zod";
import { zodToJsonSchema } from "zod-to-json-schema";
import { provideAnswerConfidenceSchema } from './common-tool-schemas.ts';
 
const aiChatSettings = {
  getTools: () => [
    {
      type: "function",
      function: {
        name: "provideAnswerConfidence",
        description: "Determine how confident the AI assistant was and whether or not to escalate to humans.",
        parameters: zodToJsonSchema(provideAnswerConfidenceSchema),
      },
      renderMessageButtons: ({ args }) => {
        const confidence = args.answerConfidence;
        if (["not_confident", "no_sources", "other"].includes(confidence)) {
          return [
            {
              label: "Create Ticket",
              icon: { builtIn: "LuUsers" },
              action: {
                type: "open_form",
                formSettings: {
                  heading: "Contact Support",
                  description: "We'll help you resolve your issue.",
                  fields: [
                    {
                      label: "Email",
                      name: "email",
                      inputType: "email",
                      isRequired: true,
                    },
                    {
                      label: "Description",
                      name: "description",
                      inputType: "textarea",
                      isRequired: true,
                    },
                    {
                      _type: "include_chat_session",
                      label: "Include chat history",
                      defaultValue: true,
                    },
                  ],
                  buttons: {
                    submit: {
                      label: "Submit Request",
                      onSubmit: async ({ values, conversation }) => {
                        // Create support ticket in your support platform
                        await submitSupportRequest(values);
                      },
                    },
                    close: {
                      action: "return_to_chat",
                    }
                  },
                  successView: {
                    heading: "Request Submitted",
                    message: "We'll get back to you shortly.",
                    doneButton: {
                      label: "Close",
                      action: "return_to_chat",
                    },
                  },
                },
              },
            }
          ];
        }
        return [];
      },
    },
  ],
};

Transfer to Live Chat

import { z } from "zod";
import { zodToJsonSchema } from "zod-to-json-schema";
import { provideAnswerConfidenceSchema } from './common-tool-schemas.ts';
 
const aiChatSettings = {
  getTools: () => [
    {
      type: "function",
      function: {
        name: "provideAnswerConfidence",
        description: "Determine how confident the AI assistant was and whether or not to escalate to humans.",
        parameters: zodToJsonSchema(provideAnswerConfidenceSchema),
      },
      renderMessageButtons: ({ args }) => {
        const confidence = args.answerConfidence;
        if (["not_confident", "no_sources", "other"].includes(confidence)) {
          return [
            {
              label: "Talk to Support",
              icon: { builtIn: "IoChatbubblesOutline" },
              action: {
                type: "invoke_callback",
                callback: ({ conversation }) => {
                  // Switch to live chat. Implementation depends on your live chat provider.
                  switchToLiveChat(conversation);
                },
              },
            }
          ];
        }
        return [];
      },
    },
  ],
};

On this page