Skip to content

Commit 3a2b60b

Browse files
author
Deathgiver
committed
feat: Update Cli, MCP
1 parent 6835822 commit 3a2b60b

36 files changed

Lines changed: 1186 additions & 2216 deletions

apps/cli/README.md

Lines changed: 132 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -2,229 +2,253 @@
22

33
CLI for interacting with the ChatbotX API.
44

5-
## 1. Set API Configuration (Required)
5+
Commands are automatically generated from the ChatbotX public API spec — no manual update needed when new APIs are added.
66

7-
Before running other commands, save your API key:
7+
---
8+
9+
## Installation
810

911
```bash
10-
chatbotx config set --apiKey <yourApiKey>
12+
npm install -g chatbotx-cli
13+
# or
14+
pnpm add -g chatbotx-cli
1115
```
1216

13-
You can also save a custom API URL:
17+
---
1418

15-
```bash
16-
chatbotx config set --apiUrl https://cloud.chatbotx.io
17-
```
19+
## Setup
20+
21+
### 1. Set API Configuration
1822

19-
Save both API key and API URL in one command:
23+
Before running any command, save your API key and URL:
2024

2125
```bash
2226
chatbotx config set --apiKey <yourApiKey> --apiUrl <yourApiUrl>
2327
```
2428

25-
If you are in local/dev environment with a self-signed certificate, you can temporarily disable TLS certificate validation:
29+
- `--apiKey` — Workspace API key (found in ChatbotX Settings → Developer → API Keys)
30+
- `--apiUrl` — Base API URL of your instance, e.g. `https://app.chatbotx.io/api`
31+
32+
You can also set them individually:
2633

2734
```bash
28-
chatbotx config set --allowSelfSignedCert true
35+
chatbotx config set --apiKey <yourApiKey>
36+
chatbotx config set --apiUrl https://app.chatbotx.io/api
2937
```
3038

31-
You can also set it per-run using environment variable:
39+
Or via environment variables:
3240

3341
```bash
34-
CHATBOTX_ALLOW_SELF_SIGNED_CERT=true chatbotx tags list
42+
export CHATBOTX_API_KEY=your_api_key
43+
export CHATBOTX_API_URL=https://app.chatbotx.io/api
3544
```
3645

37-
Preferred (more secure) approach is to trust your CA certificate:
46+
For local dev with a self-signed certificate:
3847

3948
```bash
40-
NODE_EXTRA_CA_CERTS=/path/to/ca.pem chatbotx tags list
49+
chatbotx config set --allowSelfSignedCert true
50+
# or
51+
export CHATBOTX_ALLOW_SELF_SIGNED_CERT=true
4152
```
4253

43-
Notes:
54+
### 2. Global Options
4455

45-
- The CLI supports the global option `--apiUrl` if you want to override the stored base URL for a single run.
46-
- The default base URL is `https://cloud.chatbotx.io`.
56+
Available on every command:
4757

48-
## 2. Commands: `tags`
58+
| Option | Description |
59+
|---|---|
60+
| `--apiKey` | Override API key for this run |
61+
| `--apiUrl` | Override API URL for this run |
62+
| `--allowSelfSignedCert` | Disable TLS cert validation |
63+
| `--refresh-spec` | Force re-fetch the OpenAPI spec (clears cache) |
4964

50-
### List all tags
65+
---
5166

52-
```bash
53-
chatbotx tags list
54-
```
67+
## Commands
5568

56-
### Create a new tag
69+
### `config`
5770

5871
```bash
59-
chatbotx tags create --name <tagName>
72+
chatbotx config set --apiKey <key> --apiUrl <url>
6073
```
6174

62-
### Show tag details
75+
---
6376

64-
```bash
65-
chatbotx tags show --id <tagId>
66-
```
67-
68-
### Show tag details by name
77+
### `workspace`
6978

7079
```bash
71-
chatbotx tags show-by-name --name <tagName>
80+
chatbotx workspace list # Get workspace info
7281
```
7382

74-
### Update a tag
83+
---
7584

76-
```bash
77-
chatbotx tags update --id <tagId> --name <newTagName>
78-
```
79-
80-
### Delete a tag
85+
### `workspace-members`
8186

8287
```bash
83-
chatbotx tags delete --id <tagId>
88+
chatbotx workspace-members list # List workspace members
8489
```
8590

86-
## 3. Commands: `custom-fields`
91+
---
8792

88-
### List all custom fields
93+
### `channels`
8994

9095
```bash
91-
chatbotx custom-fields list
96+
chatbotx channels list # List channels
9297
```
9398

94-
### Create a new custom field
99+
---
100+
101+
### `inbox-teams`
95102

96103
```bash
97-
chatbotx custom-fields create --name <fieldName> --customFieldType <type>
104+
chatbotx inbox-teams list # List inbox teams
98105
```
99106

100-
Valid `customFieldType` values:
101-
102-
- `shortText`
103-
- `number`
104-
- `date`
105-
- `datetime`
106-
- `boolean`
107-
- `longText`
107+
---
108108

109-
### Show custom field details
109+
### `tags`
110110

111111
```bash
112-
chatbotx custom-fields show --id <customFieldId>
112+
chatbotx tags list # Get all tags
113+
chatbotx tags create --name <name> # Create a new tag
114+
chatbotx tags show <id> # Get tag by ID
115+
chatbotx tags update <id> --name <name> # Update tag name
116+
chatbotx tags delete <id> # Delete tag
117+
chatbotx tags find-by-name <name> # Find tag by name
113118
```
114119

115-
### Show custom field details by name
120+
---
121+
122+
### `custom-fields`
116123

117124
```bash
118-
chatbotx custom-fields show-by-name --name <fieldName>
125+
chatbotx custom-fields list # Get all custom fields
126+
chatbotx custom-fields create --name <name> ... # Create a custom field
127+
chatbotx custom-fields show <id> # Get custom field by ID
128+
chatbotx custom-fields find-by-name <name> # Find custom field by name
119129
```
120130

121-
## 4. Commands: `contacts`
131+
---
122132

123-
### Get contact by ID
133+
### `bot-fields`
124134

125135
```bash
126-
chatbotx contacts show --contactId <contactId>
136+
chatbotx bot-fields list # Get all bot fields
137+
chatbotx bot-fields create ... # Create a bot field
138+
chatbotx bot-fields show <key> # Get bot field by key/name
139+
chatbotx bot-fields update <key> --value <value> # Update bot field value
140+
chatbotx bot-fields delete <key> # Unset bot field value
127141
```
128142

129-
### List contacts by custom field value
143+
---
130144

131-
```bash
132-
chatbotx contacts list-by-custom-field --customFieldId <customFieldId> --customFieldValue <value>
133-
```
134-
135-
### List tags of a contact
145+
### `contacts`
136146

137147
```bash
138-
chatbotx contacts list-tags --contactId <contactId>
139-
```
148+
# Basic CRUD
149+
chatbotx contacts create --phoneNumber <phone> --email <email> --gender <gender>
150+
chatbotx contacts show <contactId>
151+
chatbotx contacts find-by-custom-field --customFieldId <id> --value <value>
140152

141-
### Add a tag to a contact
153+
# Tags
154+
chatbotx contacts list-tags <contactId>
155+
chatbotx contacts add-tag <contactId> <tagId>
156+
chatbotx contacts delete-tag <contactId> <tagId>
142157

143-
```bash
144-
chatbotx contacts add-tag --contactId <contactId> --tagId <tagId>
145-
```
146-
147-
### Delete a tag from a contact
158+
# Custom fields
159+
chatbotx contacts list-custom-fields <contactId>
160+
chatbotx contacts show-custom-field <contactId> <customFieldId>
161+
chatbotx contacts add-custom-field <contactId> <customFieldId> --value <value>
162+
chatbotx contacts delete-custom-field <contactId> <customFieldId>
148163

149-
```bash
150-
chatbotx contacts delete-tag --contactId <contactId> --tagId <tagId>
164+
# Messaging
165+
chatbotx contacts add-message <contactId> --text <message>
166+
chatbotx contacts add-message <contactId> --flowId <id> --nodeId <id>
151167
```
152168

153-
### List custom fields of a contact
169+
---
170+
171+
### `conversations`
154172

155173
```bash
156-
chatbotx contacts list-custom-fields --contactId <contactId>
174+
chatbotx conversations create ... # Create a conversation
157175
```
158176

159-
### Get a contact's custom field value
177+
---
178+
179+
### `broadcasts`
160180

161181
```bash
162-
chatbotx contacts get-custom-field-value --contactId <contactId> --customFieldId <customFieldId>
182+
chatbotx broadcasts list # Get all broadcasts
163183
```
164184

165-
### Update a contact custom field value
185+
---
186+
187+
### `flows`
166188

167189
```bash
168-
chatbotx contacts update-custom-field-value --contactId <contactId> --customFieldId <customFieldId> --value <customFieldValue>
190+
chatbotx flows list # Get all flows
169191
```
170192

171-
### Delete a contact custom field
193+
---
194+
195+
### `sequences`
172196

173197
```bash
174-
chatbotx contacts delete-custom-field --contactId <contactId> --customFieldId <customFieldId>
198+
chatbotx sequences list # List sequences
199+
chatbotx sequences show <id> # Get sequence details
175200
```
176201

177-
### Send a message to a contact
202+
---
203+
204+
### `saved-replies`
178205

179206
```bash
180-
chatbotx contacts send-message --contactId <contactId> --channel <channel> --content <message> --files <file1,file2> --flowId <flowId> --clientId <clientId>
207+
chatbotx saved-replies list # List saved replies
181208
```
182209

183-
Valid `channel` values:
184-
185-
- `webchat`
186-
- `messenger`
187-
- `whatsapp`
188-
- `zalo`
210+
---
189211

190-
### Create a new contact
212+
### `whatsapp-message-templates`
191213

192214
```bash
193-
chatbotx contacts create --phoneNumber <phoneNumber> --email <email> --gender <male|female|unknown> --firstName <firstName> --lastName <lastName>
215+
chatbotx whatsapp-message-templates list # List WhatsApp message templates
194216
```
195217

196-
## 5. Commands: `bot-fields`
218+
---
197219

198-
### Get bot field by ID
220+
### `error-logs`
199221

200222
```bash
201-
chatbotx bot-fields show --id <botFieldId>
223+
chatbotx error-logs list # List error logs
202224
```
203225

204-
### Update bot field value
226+
---
205227

206-
```bash
207-
chatbotx bot-fields update --id <botFieldId> --value <value>
208-
```
228+
## Caching
209229

210-
### Unset bot field value
230+
The CLI caches the API spec at `~/.chatbotX/openapi-cache.json` for 1 hour to avoid fetching on every run.
211231

212232
```bash
213-
chatbotx bot-fields delete --id <botFieldId>
214-
```
233+
# Force refresh the spec cache
234+
chatbotx --refresh-spec <command>
215235

216-
## 6. Commands: `flows`
236+
# Or delete the cache manually
237+
rm ~/.chatbotX/openapi-cache.json
238+
```
217239

218-
### List all flows
240+
Cache TTL can be overridden via environment variable:
219241

220242
```bash
221-
chatbotx flows list
243+
CHATBOTX_SPEC_CACHE_TTL_SECONDS=300 chatbotx tags list
222244
```
223245

224-
## 7. Commands: `broadcasts`
246+
---
225247

226-
### List all broadcasts
248+
## Getting Help
227249

228250
```bash
229-
chatbotx broadcasts list
251+
chatbotx --help # List all command groups
252+
chatbotx tags --help # List actions for a group
253+
chatbotx tags create --help # Show options for a specific action
230254
```

apps/cli/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,16 @@
2525
"command-line"
2626
],
2727
"dependencies": {
28-
"@chatbotx.io/public-apis": "workspace:*",
2928
"@t3-oss/env-core": "^0.13.11",
30-
"ky": "^2.0.2",
3129
"yargs": "^18.0.0",
3230
"zod": "^4.3.6"
3331
},
3432
"devDependencies": {
35-
"@chatbotx.io/typescript-config": "workspace:*",
36-
"@chatbotx.io/vitest-config": "workspace:*",
3733
"@types/node": "~24.12.2",
3834
"@types/yargs": "^17.0.35",
3935
"dotenv-cli": "^11.0.0",
4036
"tsdown": "0.21.10",
41-
"tsup": "^8.5.1",
37+
"tsx": "^4.0.0",
4238
"typescript": "^5",
4339
"vitest": "^3.2.4"
4440
}

0 commit comments

Comments
 (0)