Implementation:Openclaw Openclaw Platform Credential Helpers
| Knowledge Sources | |
|---|---|
| Domains | Messaging, Authentication, CLI |
| Last Updated | 2026-02-06 12:00 GMT |
Overview
Concrete CLI helpers for guiding platform credential input during the openclaw channels add command, provided by the OpenClaw CLI.
Description
The channelsAddCommand function in src/commands/channels/add.ts (lines 79-277) implements two modes for credential collection: an interactive wizard mode and a flag-based direct mode. In wizard mode, the function creates a Clack prompter and calls setupChannels to walk the operator through channel selection and credential entry. In direct mode, it reads credential values from CLI flags (--token, --bot-token, --app-token, --signal-number, --cli-path, etc.) and passes them to the channel plugin's validation and application hooks.
The credential input is normalized through the parseList helper (for comma/semicolon/newline-separated lists like --group-channels and --dm-allowlist) and through type coercion (e.g., initialSyncLimit is parsed from string to integer). The channel plugin's validateInput hook is invoked before any configuration is written, ensuring that malformed or missing credentials are rejected early with a descriptive error message.
Each channel plugin registers its own applyAccountConfig setup hook that knows how to map the generic ChannelSetupInput fields into the platform-specific configuration schema. This keeps the CLI helpers platform-agnostic while still supporting the full range of credential shapes across Telegram, Discord, Slack, Signal, iMessage, Matrix, and extension channels.
Usage
These helpers are invoked when an operator runs openclaw channels add --channel <name> with credential flags, or when the interactive wizard is triggered (no flags provided). Import the command to wire it into the CLI:
Code Reference
Source Location
- Repository: openclaw
- File:
src/commands/channels/add.ts - Lines: 79-277
Signature
export async function channelsAddCommand(
opts: ChannelsAddOptions,
runtime: RuntimeEnv = defaultRuntime,
params?: { hasFlags?: boolean },
): Promise<void>
Supporting Types
export type ChannelsAddOptions = {
channel?: string;
account?: string;
name?: string;
token?: string;
tokenFile?: string;
botToken?: string;
appToken?: string;
signalNumber?: string;
cliPath?: string;
dbPath?: string;
service?: "imessage" | "sms" | "auto";
region?: string;
authDir?: string;
httpUrl?: string;
httpHost?: string;
httpPort?: string;
webhookPath?: string;
webhookUrl?: string;
audienceType?: string;
audience?: string;
useEnv?: boolean;
homeserver?: string;
userId?: string;
accessToken?: string;
password?: string;
deviceName?: string;
initialSyncLimit?: number | string;
ship?: string;
url?: string;
code?: string;
groupChannels?: string;
dmAllowlist?: string;
autoDiscoverChannels?: boolean;
};
Import
import { channelsAddCommand, type ChannelsAddOptions } from "./commands/channels/add.js";
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| opts | ChannelsAddOptions |
Yes | CLI flags specifying channel name and credential values (tokens, paths, URLs) |
| runtime | RuntimeEnv |
No | Runtime environment for logging and exit; defaults to defaultRuntime
|
| params | { hasFlags?: boolean } |
No | When hasFlags is false or omitted, the interactive wizard is triggered instead of flag-based mode
|
Outputs
| Name | Type | Description |
|---|---|---|
| (return) | Promise<void> |
Resolves after writing the updated config file; exits with code 1 on validation errors |
Usage Examples
Flag-Based Telegram Setup
await channelsAddCommand({
channel: "telegram",
botToken: "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11",
account: "my-bot",
name: "My Telegram Bot",
}, runtime, { hasFlags: true });
Flag-Based Discord Setup
await channelsAddCommand({
channel: "discord",
token: "MTIzNDU2Nzg5MDEyMzQ1Njc4OQ.XXXXXX.XXXXXXXX",
account: "default",
}, runtime, { hasFlags: true });
Interactive Wizard (No Flags)
await channelsAddCommand({}, runtime);
// Launches the Clack prompter for guided credential input