Agents

Build an in-product copilot without code

Copy page

Build a logged-in, account-aware copilot that diagnoses live account, integration, and usage state and resolves issues in-product — without escalating to a human.

Overview

Who this is for: product teams adding a copilot for logged-in end users, embedded inside your application. (For a copilot your support agents run inside the Zendesk ticket sidebar, see Support Copilot.)

In this tutorial, you'll build an in-product copilot using the Inkeep Visual Builder. It's embedded in your application, acts on behalf of the signed-in user, and — instead of handing problems to a human — diagnoses and fixes them in product.

When a user says "My Slack integration stopped working and we can't add new users", the copilot will:

  1. Pull live account state in one turn — the account, the integration's health, current usage and seats
  2. Render what it found as cards, then act: rotate the broken credential, recommend the right plan
  3. Answer "how do I…" questions from your docs when the user needs guidance rather than a fix

It knows who the user is because your application forwards the signed-in user's credentials to your MCP server on every tool call.

Header forwarding flow: Your App sends custom headers to the Inkeep Agent, which resolves templates and forwards credentials to Your MCP Server

Prerequisites

  • An existing Inkeep Visual Builder instance running (follow the quick start guide to get started)
  • Or access to Inkeep Enterprise
  • A deployed MCP server that exposes your product's account operations and accepts per-user auth tokens (see Build Custom MCP Servers if you need to create one). For this copilot it should expose:
    • Reads — look up the account, its usage metrics, and an integration's status
    • Writes — rotate an integration credential, change the plan
    • Recommendation — suggest the right plan from current usage
  • (Optional) Inkeep Unified Search configured, so the copilot can also answer conceptual "how do I…" questions from your docs

Set up the agent

Create the copilot agent

Go to the Agents tab in the left sidebar, then select Create Agent. Provide the following details:

  • Name: Product copilot
  • Description: An in-product copilot that diagnoses and resolves account, integration, and usage issues

Define the headers schema

The headers schema tells Inkeep which headers to expect and validate on every incoming request. These values come from your host application at runtime and identify the signed-in user.

On the agent settings pane, scroll down to Headers schema and enter the following:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "auth-token": {
      "type": "string",
      "description": "The signed-in user's API token, forwarded to MCP servers."
    },
    "user-id": {
      "type": "string",
      "description": "The signed-in user's ID."
    }
  },
  "required": ["auth-token", "user-id"],
  "additionalProperties": {}
}

Click Save to apply the schema.

Warning
Warning

Header keys are normalized to lowercase before validation. Always define schema properties in lowercase (e.g., auth-token, not authToken).

Configure the sub agent

Click on the Default Sub Agent to configure it. Provide the following details:

  • Name: Product copilot
  • Description: Diagnose account, integration, and usage state and resolve issues in product
  • Prompt: Copy the prompt below

Prompt:

You are an in-product copilot for [Your Product], assisting the signed-in user (id {{headers.user-id}}). You can see their live account state through your tools. Your job is to diagnose issues and RESOLVE them in product — you do not escalate to a human, you act.

How to handle a turn:
1. Chain reads aggressively. When the question implies several lookups ("Slack is broken AND we can't add users"), call all the relevant read tools BEFORE rendering anything.
2. Render the diagnostic cards (Account Overview and/or Integration Health Check) with the real values the tools returned.
3. State in one short sentence what you found and what you're about to do.
4. Call the write tool to fix it, then render an Action Result confirming the change.
5. If usage or seats suggest an upgrade, recommend the right plan and render a Plan Recommendation. If the user accepts ("yes", "upgrade"), change the plan and confirm.

If a knowledge-base search tool is connected, use it for "how do I…" or conceptual questions and answer from the docs — and if the answer reveals something fixable on this account, resolve it rather than just linking a doc. If no knowledge-base tool is connected, say you can only help with account operations rather than guessing.

Rules:
- Never render a card without first calling the tool behind it. Use real returned values — never placeholders.
- Execute routine writes (e.g. rotating a credential) without asking — just do it and confirm with an Action Result.
- For hard-to-reverse writes (plan changes, seat removals, deletions), render a recommendation card first and wait for the user to accept ("yes", "upgrade") before executing.
- Never invent account details, IDs, or statuses.
Tip
Tip

The {{headers.user-id}} template is resolved at runtime from the validated request headers. You can reference any key defined in the headers schema. Replace [Your Product] with your product name.

Register and connect your MCP servers

Register the Product MCP server

Because each user has their own token, you don't store a single static credential. Instead, credentials are forwarded dynamically from the incoming request headers.

Go to the MCP Servers tab in the left sidebar, then select + New MCP Server. Fill in the server details:

  • Name: Product API
  • URL: The URL of your deployed MCP server (e.g., https://api.yourproduct.com/mcp)
  • Credential: Select No Authentication

Click Create to register the server.

Note
Note

Leaving the credential blank is intentional. Auth will be injected per-request via header forwarding in the next step.

Connect it with header forwarding

Navigate to the agent canvas: AgentsProduct copilot. Drag and drop an MCP block from the top left toolbar onto the canvas, then select the Product API MCP server and connect it to the Product copilot sub agent.

Click on the connection line between the MCP server and the sub agent. In the Headers field, enter:

{
  "Authorization": "Bearer {{headers.auth-token}}",
  "X-User-Id": "{{headers.user-id}}"
}

Click Save Changes in the top right corner.

The {{headers.*}} templates are resolved at runtime from the validated incoming request headers. On every tool call to the MCP server, Inkeep replaces the template with the actual header value from the current request — so the copilot always acts as the signed-in user.

To let the copilot answer "how do I…" and conceptual questions from your docs, also connect Inkeep Unified Search as an MCP server and attach it to the same sub agent. The copilot will reach for it on knowledge questions and stay on the account tools for diagnosis and fixes.

Add structured cards

The copilot's diagnosis and fixes land as rich cards, not walls of text. You define these as data components: name each one and give it a JSON schema, and the agent fills it in with real tool results. Create them in the Data Components tab, then attach them to the sub agent — see Data Components for the full walkthrough.

This copilot uses four:

  • Account Overview — plan, seats, usage, and renewal date, rendered after looking up the account.
  • Integration Health Check — the status of one integration (healthy, degraded, down) and the recommended action.
  • Action Result — a confirmation card after a write, e.g. "Slack credential rotated" — the "we fixed it" moment.
  • Plan Recommendation — the right plan with reasons and new limits, which the user can accept to trigger an upgrade.

Embed the copilot in your application

Pass the signed-in user's credentials as custom headers from your chat component. The chat component sends these headers with every request to the agent API.

Note
Note

Replace YOUR_APP_ID with the App ID from your project's Apps settings. See App Credentials for setup details.

Test the copilot

Test in the Visual Builder playground

Click Try it in the top right corner to open the chat interface. Click the Custom headers button and enter test values:

{
  "auth-token": "test-token-abc123",
  "user-id": "user-42"
}

Click Apply, then send a message like "My Slack integration stopped working and we can't add new users — can you fix it?"

The copilot should chain its read tools (account, integration status, usage), render the Account Overview and Integration Health Check cards, rotate the Slack credential, confirm with an Action Result, and — if seats are maxed — render a Plan Recommendation. Verify in your MCP server logs that the Authorization and X-User-Id headers arrive populated from the values you entered.

Test in your application

After embedding the chat component, sign in as a test user and interact with the copilot. Confirm that:

  1. The agent responds with data scoped to the signed-in user
  2. Your MCP server logs show the correct auth token and user ID on each tool call
  3. Switching users changes the data the copilot returns and acts on