> ## Documentation Index
> Fetch the complete documentation index at: https://planetscale.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Grok Bot

> Set up Database Bot to answer database questions, investigate performance, and follow webhook events.

Database Bot helps you get started with PlanetScale, understand database performance, and fix slow or failing queries using its [MCP server](/docs/mcp-server) and installed skills.

<CardGroup cols={2}>
  <Card title="Add Database Bot" icon="robot" href="https://x.ai/bot/0hgwu8KbM0FIY-idg0x6L">
    Open the Database Bot by PlanetScale template, then choose Add to Grok Bot.
  </Card>

  <Card title="Connect the PlanetScale plugin" icon="plug" href="https://x.ai/bot/plugin/741">
    Add PlanetScale to Grok Bot and authorize access to your databases.
  </Card>
</CardGroup>

## Before you begin

You need a PlanetScale account and access to the databases you want to investigate. If you are new to Grok Bot, start with these resources:

* [Download Grok Bot](https://x.ai/bot) and [follow the getting-started guide](https://docs.x.ai/grok-bot/get-started).
* [Set up Grok Bot on mobile](https://docs.x.ai/grok-bot/mobile).
* [Connect plugins](https://cursor.com/help/grok-bot/connect-plugins).

## Add Database Bot and connect it to PlanetScale

<Steps>
  <Step title="Review and add the bot">
    Open the [Database Bot template](https://x.ai/bot/0hgwu8KbM0FIY-idg0x6L). You should see Database Bot by PlanetScale.

    <Frame>
      <img src="https://mintcdn.com/planetscale-2/Qv8bmPHOBgofISPU/agents/images/grok-bot-template.png?fit=max&auto=format&n=Qv8bmPHOBgofISPU&q=85&s=d3167892ccdddc21c36a1544cba9a31f" alt="Database Bot template preview in Grok Bot, showing Context, PlanetScale Webhook Triage, and the Add Bot button" width="364" height="437" data-path="agents/images/grok-bot-template.png" />
    </Frame>
  </Step>

  <Step title="Let the agent set itself up">
    Database Bot creates its memories, skills, and **PlanetScale Webhook Triage** routine, then prompts you to install the PlanetScale plugin. The routine starts paused.

    <Frame>
      <img src="https://mintcdn.com/planetscale-2/Qv8bmPHOBgofISPU/agents/images/grok-bot-setup.png?fit=max&auto=format&n=Qv8bmPHOBgofISPU&q=85&s=e935535d51e7c4403ba4ac0c346077ee" alt="Database Bot setting itself up and creating the PlanetScale Webhook Triage routine" width="1295" height="380" data-path="agents/images/grok-bot-setup.png" />
    </Frame>
  </Step>

  <Step title="Install the PlanetScale plugin">
    Accept the PlanetScale plugin installation prompt. If you don't see it, open the [PlanetScale plugin](https://x.ai/bot/plugin/741) and choose **Add**.

    <Frame>
      <img src="https://mintcdn.com/planetscale-2/Qv8bmPHOBgofISPU/agents/images/grok-bot-install.png?fit=max&auto=format&n=Qv8bmPHOBgofISPU&q=85&s=9906fbaf3cae9a865fa80f588866c0e9" alt="Database Bot confirming setup is complete and prompting you to install the PlanetScale plugin" width="1130" height="510" data-path="agents/images/grok-bot-install.png" />
    </Frame>
  </Step>

  <Step title="Authorize PlanetScale">
    Choose **Authorize** on the PlanetScale card and follow the PlanetScale authorization flow in your browser.

    <Frame>
      <img src="https://mintcdn.com/planetscale-2/Qv8bmPHOBgofISPU/agents/images/grok-bot-authorize.png?fit=max&auto=format&n=Qv8bmPHOBgofISPU&q=85&s=9f5bcabb19c4cfa613db76a0e2ba6440" alt="PlanetScale installed with an Authorize button on its connection card" width="1130" height="325" data-path="agents/images/grok-bot-authorize.png" />
    </Frame>
  </Step>

  <Step title="Choose a database">
    Tell the bot which organization, database, and branch to use. Ask it to verify access with a read-only check before investigating.
  </Step>
</Steps>

For example:

```text theme={null}
Use PlanetScale organization <organization>, database <database>, branch <branch>.
Confirm you can access it, then explain which queries account for the most
execution time in Insights. Show your evidence and suggested next steps.
Do not change the database.
```

## Connect a codebase (optional)

With access to your repository, Database Bot can trace database issues back to your code and help fix them via [Cursor Cloud Agents](https://cursor.com/docs/cloud-agent). Tell the bot which repository to work on. If it is not already connected to Cursor, connect your source control account through [Cursor Integrations](https://cursor.com/dashboard/integrations). See [Work with Grok Bot](https://cursor.com/docs/grok-bot/work) for more.

## Setting up the webhook routine

Webhooks are optional. They let Database Bot investigate events as they arrive, check whether database changes completed, and flag what needs your attention. Without webhooks, the bot responds when you ask.

<Steps>
  <Step title="Configure and enable the routine">
    Ask the bot to configure **PlanetScale Webhook Triage** for your chosen organizations and databases, then turn it on. Open the routine to find its **Webhook URL** and **Authorization header**.

    <Frame caption="Webhook credentials are hidden in this screenshot.">
      <img src="https://mintcdn.com/planetscale-2/Qv8bmPHOBgofISPU/agents/images/grok-bot-webhook-settings.png?fit=max&auto=format&n=Qv8bmPHOBgofISPU&q=85&s=b079caa8398aa39963203142e5ab7a43" alt="PlanetScale Webhook Triage routine settings showing the active toggle and webhook endpoint, key, and header with values obscured" width="2154" height="2326" data-path="agents/images/grok-bot-webhook-settings.png" />
    </Frame>
  </Step>

  <Step title="Add the webhook in PlanetScale">
    In your database's **Settings → Webhooks → Add webhook**, paste the routine's Webhook URL into **URL** and the header value into **Authorization header**, including the scheme, such as `Bearer <token>`, without the `Authorization:` label.

    <Frame>
      <img src="https://mintcdn.com/planetscale-2/Qv8bmPHOBgofISPU/agents/images/grok-bot-add-webhook-light.png?fit=max&auto=format&n=Qv8bmPHOBgofISPU&q=85&s=60e2c37b6fe9aa35fabb6917aeebe60f" alt="PlanetScale Add webhook form with URL, Authorization header, and event selection fields" className="block dark:hidden" width="2658" height="2010" data-path="agents/images/grok-bot-add-webhook-light.png" />

      <img src="https://mintcdn.com/planetscale-2/Qv8bmPHOBgofISPU/agents/images/grok-bot-add-webhook-dark.png?fit=max&auto=format&n=Qv8bmPHOBgofISPU&q=85&s=2e26b62eb1c8df9dfcf9ed45a45a6bed" alt="PlanetScale Add webhook form with URL, Authorization header, and event selection fields" className="hidden dark:block" width="2658" height="2010" data-path="agents/images/grok-bot-add-webhook-dark.png" />
    </Frame>
  </Step>

  <Step title="Choose events and test delivery">
    Choose the [events you want the bot to follow](/docs/api/webhook-events), save the webhook, and use **Test webhook**. Confirm delivery in PlanetScale and acknowledgment in Grok Bot.

    Webhooks cover supported events; they don't notify the bot about every slow query or CPU spike.
  </Step>
</Steps>

See [Setting up webhooks](/docs/api/webhooks) for more details.

## Need help?

Get help from [the PlanetScale Support team](https://planetscale.com/contact?initial=support), or join our [Discord community](https://pscale.link/community) to see how others are using PlanetScale.
