> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.getdial.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.getdial.ai/_mcp/server.

# Opencode

> Use Dial from Opencode by dropping the Dial skill into your Opencode config.

Drop the Dial skill into your Opencode config so the terminal agent learns how to drive the `dial` CLI on demand. Once installed, Opencode can send messages, place calls, and wait for events without you re-explaining the surface.

## Install

Two ways to give Opencode Dial: drop in the **CLI skill** (Opencode drives the `dial` CLI), or wire up the **MCP server** (Opencode calls Dial's tools directly). Pick whichever fits — they're not mutually exclusive.

### Option 1 — CLI skill (Recommended)

First, get the `dial` CLI on your PATH:

```bash title="Shell install"
curl -fsSL https://getdial.ai/install | bash
```

```text title="Agent prompt"
Follow https://getdial.ai/skills.md to install and onboard the dial CLI.
```

Then drop the Opencode-specific Dial skill into your config:

```bash
dial auth verify-otp --code <code> --agent opencode
```

`auth verify-otp` verifies your code first, then copies the Dial skill into Opencode's standard config directory. Re-run the command anytime (after a CLI upgrade, for example) to overwrite the skill in place — the verification step is a no-op once you're signed in.

A single markdown skill describing the `dial` CLI — its commands, flags, and conventions, mirroring the [CLI reference](/documentation/cli/commands) — gets installed. Opencode loads the skill when a Dial-related task comes up; nothing else is touched.

### Option 2 — MCP server

Run Dial as a native [MCP server](/integrations/tools/mcp) and Opencode calls its tools directly. Opencode has no CLI command to add a server — MCP servers are configured in your `opencode.json` under the `mcp` key, so add the entry there. Use the **local** transport (`npx -y @getdial/cli mcp`, which reuses your saved CLI key) or the **remote** transport (`https://getdial.ai/mcp`, which Opencode authenticates via browser OAuth on first use):

```json title="opencode.json (local)"
# opencode.json (project) or ~/.config/opencode/opencode.json (global)
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "dial": {
      "type": "local",
      "command": ["npx", "-y", "@getdial/cli", "mcp"],
      "enabled": true
    }
  }
}
```

```json title="opencode.json (remote)"
# opencode.json (project) or ~/.config/opencode/opencode.json (global)
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "dial": {
      "type": "remote",
      "url": "https://getdial.ai/mcp",
      "enabled": true
    }
  }
}
```

See the [MCP page](/integrations/tools/mcp) for the full tool list and the remote OAuth flow, and Opencode's own [MCP servers docs](https://opencode.ai/docs/mcp-servers/) for the config schema.

## Use it

Both paths work the same way: just ask in plain language.

> Send an SMS to +14155550123 with the body "running late, ETA 10 min".

With the **CLI skill**, Opencode picks up the skill and runs the right `dial` command; with the **MCP server**, it calls Dial's tools directly — no CLI shell-out. See [Using Dial from an agent](/documentation/get-started/using-dial-from-an-agent) for more examples.

## Inbound event handling (Suggestion)

You can also wake Opencode automatically when a Dial event arrives by wiring a [CLI command target](/integrations/methods/cli-command-target): for each inbound event, the listen daemon spawns a handler that delivers a fresh prompt to Opencode's non-interactive mode.

First install the listen daemon:

```bash
dial listen install
```

### 1. Write a handler

```bash
#!/usr/bin/env bash
# /usr/local/bin/handle-dial-event-opencode
event="$1"

type=$(jq -r '.type'        <<<"$event")
from=$(jq -r '.from // ""'  <<<"$event")
body=$(jq -r '.body // ""'  <<<"$event")

prompt=$(cat <<EOF
A Dial event just arrived. Decide what to do and act on it.

  type: $type
  from: $from
  body: $body

raw event JSON:
$event
EOF
)

# Detach a fresh Opencode run and return right away.
nohup opencode run -q "$prompt" </dev/null >>~/.dial/opencode.log 2>&1 &
disown
exit 0
```

`opencode run` is Opencode's non-interactive mode (alternatively `opencode -p "$prompt"`). `-q` (alias `--quiet`) suppresses the spinner, which is the right shape for unattended scripts.

### 2. Register

```bash
chmod +x /usr/local/bin/handle-dial-event-opencode
dial local-target add cmd /usr/local/bin/handle-dial-event-opencode
```

The `nohup … & disown` pattern keeps Opencode running after the handler exits, so a multi-minute agent run never collides with the daemon's per-attempt `--timeout`. See [CLI command target](/integrations/methods/cli-command-target) for the full reference, delivery semantics, and the once-retry behavior.