|
2 | 2 |
|
3 | 3 | CLI for interacting with the ChatbotX API. |
4 | 4 |
|
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. |
6 | 6 |
|
7 | | -Before running other commands, save your API key: |
| 7 | +--- |
| 8 | + |
| 9 | +## Installation |
8 | 10 |
|
9 | 11 | ```bash |
10 | | -chatbotx config set --apiKey <yourApiKey> |
| 12 | +npm install -g chatbotx-cli |
| 13 | +# or |
| 14 | +pnpm add -g chatbotx-cli |
11 | 15 | ``` |
12 | 16 |
|
13 | | -You can also save a custom API URL: |
| 17 | +--- |
14 | 18 |
|
15 | | -```bash |
16 | | -chatbotx config set --apiUrl https://cloud.chatbotx.io |
17 | | -``` |
| 19 | +## Setup |
| 20 | + |
| 21 | +### 1. Set API Configuration |
18 | 22 |
|
19 | | -Save both API key and API URL in one command: |
| 23 | +Before running any command, save your API key and URL: |
20 | 24 |
|
21 | 25 | ```bash |
22 | 26 | chatbotx config set --apiKey <yourApiKey> --apiUrl <yourApiUrl> |
23 | 27 | ``` |
24 | 28 |
|
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: |
26 | 33 |
|
27 | 34 | ```bash |
28 | | -chatbotx config set --allowSelfSignedCert true |
| 35 | +chatbotx config set --apiKey <yourApiKey> |
| 36 | +chatbotx config set --apiUrl https://app.chatbotx.io/api |
29 | 37 | ``` |
30 | 38 |
|
31 | | -You can also set it per-run using environment variable: |
| 39 | +Or via environment variables: |
32 | 40 |
|
33 | 41 | ```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 |
35 | 44 | ``` |
36 | 45 |
|
37 | | -Preferred (more secure) approach is to trust your CA certificate: |
| 46 | +For local dev with a self-signed certificate: |
38 | 47 |
|
39 | 48 | ```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 |
41 | 52 | ``` |
42 | 53 |
|
43 | | -Notes: |
| 54 | +### 2. Global Options |
44 | 55 |
|
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: |
47 | 57 |
|
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) | |
49 | 64 |
|
50 | | -### List all tags |
| 65 | +--- |
51 | 66 |
|
52 | | -```bash |
53 | | -chatbotx tags list |
54 | | -``` |
| 67 | +## Commands |
55 | 68 |
|
56 | | -### Create a new tag |
| 69 | +### `config` |
57 | 70 |
|
58 | 71 | ```bash |
59 | | -chatbotx tags create --name <tagName> |
| 72 | +chatbotx config set --apiKey <key> --apiUrl <url> |
60 | 73 | ``` |
61 | 74 |
|
62 | | -### Show tag details |
| 75 | +--- |
63 | 76 |
|
64 | | -```bash |
65 | | -chatbotx tags show --id <tagId> |
66 | | -``` |
67 | | - |
68 | | -### Show tag details by name |
| 77 | +### `workspace` |
69 | 78 |
|
70 | 79 | ```bash |
71 | | -chatbotx tags show-by-name --name <tagName> |
| 80 | +chatbotx workspace list # Get workspace info |
72 | 81 | ``` |
73 | 82 |
|
74 | | -### Update a tag |
| 83 | +--- |
75 | 84 |
|
76 | | -```bash |
77 | | -chatbotx tags update --id <tagId> --name <newTagName> |
78 | | -``` |
79 | | - |
80 | | -### Delete a tag |
| 85 | +### `workspace-members` |
81 | 86 |
|
82 | 87 | ```bash |
83 | | -chatbotx tags delete --id <tagId> |
| 88 | +chatbotx workspace-members list # List workspace members |
84 | 89 | ``` |
85 | 90 |
|
86 | | -## 3. Commands: `custom-fields` |
| 91 | +--- |
87 | 92 |
|
88 | | -### List all custom fields |
| 93 | +### `channels` |
89 | 94 |
|
90 | 95 | ```bash |
91 | | -chatbotx custom-fields list |
| 96 | +chatbotx channels list # List channels |
92 | 97 | ``` |
93 | 98 |
|
94 | | -### Create a new custom field |
| 99 | +--- |
| 100 | + |
| 101 | +### `inbox-teams` |
95 | 102 |
|
96 | 103 | ```bash |
97 | | -chatbotx custom-fields create --name <fieldName> --customFieldType <type> |
| 104 | +chatbotx inbox-teams list # List inbox teams |
98 | 105 | ``` |
99 | 106 |
|
100 | | -Valid `customFieldType` values: |
101 | | - |
102 | | -- `shortText` |
103 | | -- `number` |
104 | | -- `date` |
105 | | -- `datetime` |
106 | | -- `boolean` |
107 | | -- `longText` |
| 107 | +--- |
108 | 108 |
|
109 | | -### Show custom field details |
| 109 | +### `tags` |
110 | 110 |
|
111 | 111 | ```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 |
113 | 118 | ``` |
114 | 119 |
|
115 | | -### Show custom field details by name |
| 120 | +--- |
| 121 | + |
| 122 | +### `custom-fields` |
116 | 123 |
|
117 | 124 | ```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 |
119 | 129 | ``` |
120 | 130 |
|
121 | | -## 4. Commands: `contacts` |
| 131 | +--- |
122 | 132 |
|
123 | | -### Get contact by ID |
| 133 | +### `bot-fields` |
124 | 134 |
|
125 | 135 | ```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 |
127 | 141 | ``` |
128 | 142 |
|
129 | | -### List contacts by custom field value |
| 143 | +--- |
130 | 144 |
|
131 | | -```bash |
132 | | -chatbotx contacts list-by-custom-field --customFieldId <customFieldId> --customFieldValue <value> |
133 | | -``` |
134 | | - |
135 | | -### List tags of a contact |
| 145 | +### `contacts` |
136 | 146 |
|
137 | 147 | ```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> |
140 | 152 |
|
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> |
142 | 157 |
|
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> |
148 | 163 |
|
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> |
151 | 167 | ``` |
152 | 168 |
|
153 | | -### List custom fields of a contact |
| 169 | +--- |
| 170 | + |
| 171 | +### `conversations` |
154 | 172 |
|
155 | 173 | ```bash |
156 | | -chatbotx contacts list-custom-fields --contactId <contactId> |
| 174 | +chatbotx conversations create ... # Create a conversation |
157 | 175 | ``` |
158 | 176 |
|
159 | | -### Get a contact's custom field value |
| 177 | +--- |
| 178 | + |
| 179 | +### `broadcasts` |
160 | 180 |
|
161 | 181 | ```bash |
162 | | -chatbotx contacts get-custom-field-value --contactId <contactId> --customFieldId <customFieldId> |
| 182 | +chatbotx broadcasts list # Get all broadcasts |
163 | 183 | ``` |
164 | 184 |
|
165 | | -### Update a contact custom field value |
| 185 | +--- |
| 186 | + |
| 187 | +### `flows` |
166 | 188 |
|
167 | 189 | ```bash |
168 | | -chatbotx contacts update-custom-field-value --contactId <contactId> --customFieldId <customFieldId> --value <customFieldValue> |
| 190 | +chatbotx flows list # Get all flows |
169 | 191 | ``` |
170 | 192 |
|
171 | | -### Delete a contact custom field |
| 193 | +--- |
| 194 | + |
| 195 | +### `sequences` |
172 | 196 |
|
173 | 197 | ```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 |
175 | 200 | ``` |
176 | 201 |
|
177 | | -### Send a message to a contact |
| 202 | +--- |
| 203 | + |
| 204 | +### `saved-replies` |
178 | 205 |
|
179 | 206 | ```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 |
181 | 208 | ``` |
182 | 209 |
|
183 | | -Valid `channel` values: |
184 | | - |
185 | | -- `webchat` |
186 | | -- `messenger` |
187 | | -- `whatsapp` |
188 | | -- `zalo` |
| 210 | +--- |
189 | 211 |
|
190 | | -### Create a new contact |
| 212 | +### `whatsapp-message-templates` |
191 | 213 |
|
192 | 214 | ```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 |
194 | 216 | ``` |
195 | 217 |
|
196 | | -## 5. Commands: `bot-fields` |
| 218 | +--- |
197 | 219 |
|
198 | | -### Get bot field by ID |
| 220 | +### `error-logs` |
199 | 221 |
|
200 | 222 | ```bash |
201 | | -chatbotx bot-fields show --id <botFieldId> |
| 223 | +chatbotx error-logs list # List error logs |
202 | 224 | ``` |
203 | 225 |
|
204 | | -### Update bot field value |
| 226 | +--- |
205 | 227 |
|
206 | | -```bash |
207 | | -chatbotx bot-fields update --id <botFieldId> --value <value> |
208 | | -``` |
| 228 | +## Caching |
209 | 229 |
|
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. |
211 | 231 |
|
212 | 232 | ```bash |
213 | | -chatbotx bot-fields delete --id <botFieldId> |
214 | | -``` |
| 233 | +# Force refresh the spec cache |
| 234 | +chatbotx --refresh-spec <command> |
215 | 235 |
|
216 | | -## 6. Commands: `flows` |
| 236 | +# Or delete the cache manually |
| 237 | +rm ~/.chatbotX/openapi-cache.json |
| 238 | +``` |
217 | 239 |
|
218 | | -### List all flows |
| 240 | +Cache TTL can be overridden via environment variable: |
219 | 241 |
|
220 | 242 | ```bash |
221 | | -chatbotx flows list |
| 243 | +CHATBOTX_SPEC_CACHE_TTL_SECONDS=300 chatbotx tags list |
222 | 244 | ``` |
223 | 245 |
|
224 | | -## 7. Commands: `broadcasts` |
| 246 | +--- |
225 | 247 |
|
226 | | -### List all broadcasts |
| 248 | +## Getting Help |
227 | 249 |
|
228 | 250 | ```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 |
230 | 254 | ``` |
0 commit comments