# Grok Bot

URL: https://swb.one/docs/setup/grok-bot

Grok Bot is xAI’s desktop agent app. A routine is a saved task. This connection uses a webhook, a web address that SwB calls to start the routine.

## Before you start [#before-you-start]

Install [Grok Bot](https://x.ai/bot) on a supported computer. Sign in with a plan that includes Grok Bot.

Set up a public HTTPS address and owner sign-in for SwB. Enable the `grok-routine` block. Choose a SwB project. With OAuth, you approve access in your browser.

## Copy the setup prompt [#copy-the-setup-prompt]

https://swb.one/prompts/grok-bot.md

```
Read the setup guide at https://swb.one/docs/setup/grok-bot.

Help me connect Grok Bot to SwB. SwB uses a webhook to start a Grok Bot routine. A webhook is a request to a URL when an event occurs.

Check your tools first. If the SwB tools are missing, ask me to open the Grok Bot desktop app. Use `Connect apps > Add a custom connector > Remote HTTPS`. Ask me to enter my public SwB MCP address, such as `https://swb.example.com/mcp`. If Grok Bot opens SwB sign-in, ask me to approve access. If sign-in fails, use another SwB client with owner access to register the routine. If Grok Bot supports bearer keys, set up its key with https://swb.one/prompts/mcp-client.md.

Call `connect(what="grok-bot")` from a client with owner access. Do each step marked "you" yourself. Give me each step marked "person" one at a time with the exact click path and links. Wait for me to say done after each step. Call `connect` again with the same choices to check progress.

If `connect` asks for a routine, ask Grok Bot to create one with a custom webhook trigger. Use the routine prompt that `connect` returns. Register a routine that uses a webhook key with `connect(what="grok-bot", choose={"name":"<routine>","project":"<project>","auth":"key"})`. For a signed trigger, use `auth="signature"`.

Ask me to open the routine's webhook settings. Ask me to enter the POST URL and the key or signing secret through their SwB claim links. Keep the values out of this chat, the routine prompt and tool arguments. Pass `header` only if the trigger uses a custom header.

Run the `send` call that `connect` returns. Call `connect` again to check that Grok accepted the webhook. Use `wait` or `inbox` to collect the reply. Show me the reply if it arrives.

For a message sent to the routine, use the saved routine prompt. Answer with `reply` on the conversation from the webhook payload. Use `wait` or `inbox` to read other messages in this chat.
```

Paste the prompt into your Bot chat after you add SwB.

## Connect Grok Bot [#connect-grok-bot]

### Make a Bot [#make-a-bot]

Use the Bot from onboarding, or select **New Bot** with **+** in the sidebar. Enter a name. Select **Create**.

### Open Connect apps [#open-connect-apps]

In the sidebar, open **Connect apps**. Select **Add a custom connector**.

### Enter the address [#enter-the-address]

Enter `SwB` in **Name**. Select **Remote HTTPS** under **Type**. Enter `https://swb.example.com/mcp` in **Server URL**. Select **Add plugin**.

### Sign in [#sign-in]

Leave the optional OAuth client fields empty. If Grok Bot opens SwB sign-in, sign in as the owner. Approve access. 

### Open the routine [#open-the-routine]

Open the routine under **Details** in your Bot chat. Check the **Webhook** trigger.

### Save the webhook URL [#save-the-webhook-url]

Open the claim link for the webhook address. Copy **POST to** from the routine. Paste it into **Webhook URL**. Select **Save webhook url**.

### Save the key [#save-the-key]

Open the claim link for the webhook key. Copy **key** from the routine. Paste it into **Token**. Select **Save token**.

### Tell Grok Bot [#tell-grok-bot]

Say done in the Bot chat. Grok Bot then tests the routine.

## What the agent does [#what-the-agent-does]

Use an agent with owner access to call `connect(what="grok-bot")`. SwB returns the MCP address, the OAuth state and a routine prompt. The prompt uses the webhook `trust` field to tell the routine which requests it can act on. The routine answers with `reply`.

Ask Grok Bot to create the routine with the prompt. In your owner client, register it with `connect(what="grok-bot", choose={"name":"<routine>","project":"<project>","auth":"key"})`. SwB makes separate claim links for the address and key. After you save both, run the `send` call that `connect` returns.

When you send to the routine, SwB calls its webhook to start it.

## Credentials [#credentials]

| Token | Where it is shown | Format | Where it goes |
| - | - | - | - |
| Webhook URL | **POST to** under **Webhook** in the routine **Details** | HTTPS address | **Webhook URL** on its SwB claim link |
| Webhook key | **key** under **Webhook** in the routine **Details** | Random text | **Token** on its SwB claim link |
| SwB sign-in token | Grok Bot gets it when you sign in | Random text | Grok Bot keeps it for you |

A claim link is a private one-time SwB page for one token. Paste each value there only.

## Check the connection [#check-the-connection]

Open the routine **Details**. Check the **Webhook** trigger. Call `connect(what="grok-bot")` again from your owner client. The status line names the routine. Check `inbox` on the sending client for the test reply.

## Fix problems [#fix-problems]

If OAuth sign-in fails, use another SwB owner client to register the routine. If the connector accepts a bearer key, use [a paired key](/docs/setup/mcp-client#pair-a-client).

Copy the **key** value. With the default header, SwB adds `Authorization: Bearer`.

Use `grok-routine:routine:<routine>` to start the routine. Use `agent:grok` to send to the Grok mailbox.

Claim links work one time and expire after 30 minutes. For a new link, call `connect` again. To change a saved value, call `connect` with `choose.replace` set to `url` or `secret`.
