# Grok Bot

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

Grok Bot은 xAI의 데스크톱 에이전트 앱입니다. 루틴은 저장해 둔 작업입니다. 이 연결은 웹훅을 사용합니다. 웹훅은 SwB이 루틴을 시작하려고 호출하는 웹 주소입니다.

## 시작하기 전에 [#시작하기-전에]

지원되는 컴퓨터에 [Grok Bot](https://x.ai/bot)을 설치하세요. Grok Bot이 포함된 플랜으로 로그인하세요.

SwB에 공개 HTTPS 주소와 소유자 로그인을 설정하세요. `grok-routine` 블록을 켜세요. SwB 프로젝트를 고르세요. OAuth를 쓰면 브라우저에서 접근을 승인합니다.

## 설정 프롬프트 복사 [#설정-프롬프트-복사]

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.
```

SwB을 추가한 뒤 이 프롬프트를 Bot 채팅에 붙여 넣으세요.

## Grok Bot 연결 [#grok-bot-연결]

### Bot 만들기 [#bot-만들기]

온보딩에서 만든 Bot을 쓰거나 사이드바의 **+**에서 **New Bot**을 선택하세요. 이름을 입력하세요. **Create**를 선택하세요.

### Connect apps 열기 [#connect-apps-열기]

사이드바에서 **Connect apps**를 여세요. **Add a custom connector**를 선택하세요.

### 주소 입력 [#주소-입력]

**Name**에 `SwB`을 입력하세요. **Type**에서 **Remote HTTPS**를 선택하세요. **Server URL**에 `https://swb.example.com/mcp`를 입력하세요. **Add plugin**을 선택하세요.

### 로그인 [#로그인]

선택 사항인 OAuth 클라이언트 필드는 비워 두세요. Grok Bot이 SwB 로그인 페이지를 열면 소유자로 로그인하세요. 접근을 승인하세요. 

### 루틴 열기 [#루틴-열기]

Bot 채팅의 **Details**에서 루틴을 여세요. **Webhook** 트리거를 확인하세요.

### 웹훅 URL 저장 [#웹훅-url-저장]

웹훅 주소용 등록 링크를 여세요. 루틴에서 **POST to** 값을 복사하세요. **Webhook URL**에 붙여 넣으세요. **Save webhook url**을 선택하세요.

### 키 저장 [#키-저장]

웹훅 키용 등록 링크를 여세요. 루틴에서 **key** 값을 복사하세요. **Token**에 붙여 넣으세요. **Save token**을 선택하세요.

### Grok Bot에게 알리기 [#grok-bot에게-알리기]

Bot 채팅에서 끝났다고 말하세요. 그러면 Grok Bot이 루틴을 테스트합니다.

## 에이전트가 하는 일 [#에이전트가-하는-일]

소유자 권한이 있는 에이전트로 `connect(what="grok-bot")`를 호출하세요. SwB은 MCP 주소, OAuth 상태, 루틴 프롬프트를 돌려줍니다. 프롬프트는 웹훅의 `trust` 필드로 루틴이 처리할 수 있는 요청을 알려 줍니다. 루틴은 `reply`로 답합니다.

Grok Bot에게 이 프롬프트로 루틴을 만들어 달라고 요청하세요. 소유자 클라이언트에서 `connect(what="grok-bot", choose={"name":"<routine>","project":"<project>","auth":"key"})`로 루틴을 등록하세요. SwB은 주소용과 키용 등록 링크를 따로 만듭니다. 둘 다 저장한 뒤 `connect`가 돌려준 `send` 호출을 실행하세요.

루틴으로 보내면 SwB이 루틴의 웹훅을 호출해 루틴을 시작합니다.

## 자격 증명 [#자격-증명]

| 토큰 | 표시되는 곳 | 형식 | 입력할 곳 |
| - | - | - | - |
| 웹훅 URL | 루틴 **Details**의 **Webhook** 아래 **POST to** | HTTPS 주소 | 해당 SwB 등록 링크의 **Webhook URL** |
| 웹훅 키 | 루틴 **Details**의 **Webhook** 아래 **key** | 임의 텍스트 | 해당 SwB 등록 링크의 **Token** |
| SwB 로그인 토큰 | 로그인할 때 Grok Bot이 받습니다 | 임의 텍스트 | Grok Bot이 대신 보관합니다 |

등록 링크는 토큰 하나를 입력하는 일회용 비공개 SwB 페이지입니다. 각 값은 그곳에만 붙여 넣으세요.

## 연결 확인 [#연결-확인]

루틴 **Details**를 여세요. **Webhook** 트리거를 확인하세요. 소유자 클라이언트에서 `connect(what="grok-bot")`를 다시 호출하세요. 상태 줄에 루틴 이름이 나옵니다. 보낸 쪽 클라이언트의 `inbox`에서 테스트 답장을 확인하세요.

## 문제 해결 [#문제-해결]

OAuth 로그인이 실패하면 다른 SwB 소유자 클라이언트로 루틴을 등록하세요. 커넥터가 bearer 키를 받는다면 [페어링 키](/ko/docs/setup/mcp-client#클라이언트-페어링)를 사용하세요.

**key** 값을 복사하세요. 기본 헤더를 쓰면 SwB이 `Authorization: Bearer`를 붙입니다.

루틴을 시작하려면 `grok-routine:routine:<routine>`을 사용하세요. Grok 우편함으로 보내려면 `agent:grok`을 사용하세요.

등록 링크는 한 번만 쓸 수 있고 30분 뒤에 만료됩니다. 새 링크가 필요하면 `connect`를 다시 호출하세요. 저장한 값을 바꾸려면 `choose.replace`를 `url`이나 `secret`으로 지정해 `connect`를 호출하세요.
