|
41 | 41 | - [Exit codes](#exit-codes) |
42 | 42 | - [Examples](#examples) |
43 | 43 | - [Sending messages](#sending-messages) |
| 44 | + - [Batch message sending](#batch-message-sending) |
44 | 45 | - [Getting message status](#getting-message-status) |
45 | 46 | - [Getting logs](#getting-logs) |
46 | 47 | - [Output formats](#output-formats-1) |
|
55 | 56 | There are two CLI tools in this repository: `smsgate` and `smsgate-ca`. The first one is for SMS Gateway for Android itself, and the second one is for the Certificate Authority. |
56 | 57 |
|
57 | 58 | This CLI provides a robust interface for: |
58 | | -- Sending and managing SMS messages |
| 59 | +- Sending and managing SMS messages (including batch operations from CSV and Excel files) |
59 | 60 | - Configuring webhook integrations |
60 | 61 | - Issuing certificates for private deployments |
61 | 62 |
|
@@ -133,9 +134,9 @@ smsgate [global options] command [command options] [arguments...] |
133 | 134 |
|
134 | 135 | ### Commands |
135 | 136 |
|
136 | | -The CLI offers three main groups of commands: |
| 137 | +The CLI offers four main groups of commands: |
137 | 138 |
|
138 | | -- **Messages**: Commands for sending messages and checking their status. |
| 139 | +- **Messages**: Commands for sending messages and checking their status, including batch operations from CSV and Excel files. |
139 | 140 | - **Webhooks**: Commands for managing webhooks, including creating, updating, and deleting them. |
140 | 141 | - **Logs**: Commands for retrieving logs for a specific time range. |
141 | 142 |
|
@@ -164,16 +165,183 @@ smsgate -u <username> -p <password> send --phones '+12025550123' 'Hello, Dr. Tur |
164 | 165 |
|
165 | 166 | #### Sending messages |
166 | 167 |
|
| 168 | +The `send` command supports various options to customize message delivery: |
| 169 | + |
167 | 170 | ```bash |
168 | | -# Send a message |
| 171 | +# Send a simple text message |
169 | 172 | smsgate send --phones '+12025550123' 'Hello, Dr. Turk!' |
170 | 173 |
|
171 | | -# Send a message to multiple numbers |
| 174 | +# Send to multiple numbers |
172 | 175 | smsgate send --phones '+12025550123' --phones '+12025550124' 'Hello, doctors!' |
173 | 176 | # or |
174 | 177 | smsgate send --phones '+12025550123,+12025550124' 'Hello, doctors!' |
| 178 | + |
| 179 | +# Send with explicit device selection |
| 180 | +smsgate send --phones '+12025550123' --device-id device123 'Message' |
| 181 | + |
| 182 | +# Send with SIM number selection (1-based) |
| 183 | +smsgate send --phones '+12025550123' --sim-number 2 'Message' |
| 184 | + |
| 185 | +# Send with priority (>=100 bypasses limits) |
| 186 | +smsgate send --phones '+12025550123' --priority 100 'Urgent message' |
| 187 | + |
| 188 | +# Send with time-to-live (TTL) |
| 189 | +smsgate send --phones '+12025550123' --ttl 1h30m 'Expiring message' |
| 190 | + |
| 191 | +# Send with expiration date (RFC3339 format) |
| 192 | +smsgate send --phones '+12025550123' --valid-until '2024-12-31T23:59:59Z' 'Message' |
| 193 | + |
| 194 | +# Disable delivery report |
| 195 | +smsgate send --phones '+12025550123' --delivery-report=false 'Message' |
| 196 | + |
| 197 | +# Skip phone number validation |
| 198 | +smsgate send --phones '+12025550123' --skip-phone-validation 'Message' |
| 199 | + |
| 200 | +# Filter by device activity (devices active within last 12 hours) |
| 201 | +smsgate send --phones '+12025550123' --device-active-within 12 'Message' |
| 202 | + |
| 203 | +# Send data message (base64 encoded) |
| 204 | +echo -n 'hello world' | base64 |
| 205 | +smsgate send --phones '+12025550123' --data --data-port 12345 'aGVsbG8gd29ybGQ=' |
| 206 | +``` |
| 207 | + |
| 208 | +**Send command options:** |
| 209 | + |
| 210 | +| Option | Description | Default Value | Example | |
| 211 | +| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | ----------------------- | |
| 212 | +| `--id` | A unique message ID. If not provided, one will be automatically generated. | empty | `zXDYfTmTVf3iMd16zzdBj` | |
| 213 | +| `--device-id`, `--device` | Optional device ID for explicit selection. If not provided, a random device will be selected. | empty | `oi2i20J8xVP1ct5neqGZt` | |
| 214 | +| `--phones`, `--phone`, `-p` | Specifies the recipient's phone number(s). This option can be used multiple times or accepts comma-separated values. Numbers must be in E.164 format. | **required** | `+12025550123` | |
| 215 | +| `--sim-number`, `--sim` | The one-based SIM card slot number. If not specified, the device's SIM rotation feature will be used. | empty | `2` | |
| 216 | +| `--delivery-report` | Enables delivery report for the message. | `true` | `true` / `false` | |
| 217 | +| `--priority` | Sets the priority of the message. Messages with priority >= 100 bypass all limits and delays. Range: -128 to 127. | `0` | `100` | |
| 218 | +| **Data Message** | | | | |
| 219 | +| `--data` | Send data message instead of text (content must be base64 encoded). | `false` | `true` | |
| 220 | +| `--data-port` | Destination port for data message (1 to 65535). | `53739` | `12345` | |
| 221 | +| **Options** | | | | |
| 222 | +| `--ttl` | Time-to-live (TTL) for the message. Duration format (e.g., `1h30m`). If not provided, the message will not expire.<br>**Conflicts with `--valid-until`.** | empty | `1h30m` | |
| 223 | +| `--valid-until` | The expiration date and time for the message. RFC3339 format (e.g., `2006-01-02T15:04:05Z07:00`).<br>**Conflicts with `--ttl`.** | empty | `2024-12-31T23:59:59Z` | |
| 224 | +| `--skip-phone-validation` | Skip phone number validation. | `false` | `true` | |
| 225 | +| `--device-active-within` | Time window in hours for device activity filtering. `0` means no filtering. | `0` | `12` | |
| 226 | + |
| 227 | +#### Batch message sending |
| 228 | + |
| 229 | +The CLI supports sending messages in bulk from CSV and Excel files. The `batch send` command also supports the shared delivery/device options from `send` (such as `--device-id`, `--sim-number`, `--priority`, `--ttl`, `--valid-until`, `--delivery-report`, `--skip-phone-validation`, `--device-active-within`), allowing fine-grained control over each message in the batch. |
| 230 | + |
| 231 | +**Supported file formats:** |
| 232 | +- **CSV** (Comma-Separated Values) |
| 233 | +- **XLSX** (Excel files) |
| 234 | + |
| 235 | +**Basic usage:** |
| 236 | + |
| 237 | +```bash |
| 238 | +# Send messages from a CSV file |
| 239 | +smsgate batch send contacts.csv --map phone=Phone,text=Message |
| 240 | + |
| 241 | +# Send messages from an Excel file with specific sheet |
| 242 | +smsgate batch send campaign.xlsx --sheet Sheet1 --map phone=A,text=B |
| 243 | + |
| 244 | +# Send with custom delimiter and no header |
| 245 | +smsgate batch send data.csv --delimiter ';' --header=false --map phone=col_1,text=col_2 |
| 246 | +``` |
| 247 | + |
| 248 | +**Batch-specific options:** |
| 249 | + |
| 250 | +| Option | Description | Default Value | Example | |
| 251 | +| --------------------- | -------------------------------------------------- | ------------- | -------------------------- | |
| 252 | +| `--sheet` | XLSX sheet name (defaults to first sheet) | empty | `Sheet1` | |
| 253 | +| `--delimiter` | CSV delimiter character | `,` | `;` | |
| 254 | +| `--header` | Treat first row as header | `true` | `false` | |
| 255 | +| `--map` | Column mapping (required) | **required** | `phone=Phone,text=Message` | |
| 256 | +| `--dry-run` | Validate and print normalized rows without sending | `false` | `true` | |
| 257 | +| `--validate-only` | Validate input only (no preview, no sending) | `false` | `true` | |
| 258 | +| `--concurrency` | Number of concurrent send workers | CPU cores | `5` | |
| 259 | +| `--continue-on-error` | Continue sending after per-row failures | `false` | `true` | |
| 260 | + |
| 261 | +**Inherited message options:** |
| 262 | +The shared delivery/device options from the `send` command are also available (e.g., `--device-id`, `--sim-number`, `--priority`, `--ttl`, `--valid-until`, `--delivery-report`, `--skip-phone-validation`, `--device-active-within`). These apply to every message sent in the batch. |
| 263 | + |
| 264 | +**Column mapping:** |
| 265 | + |
| 266 | +The `--map` option defines how columns in your file map to message fields: |
| 267 | + |
| 268 | +| Field | Required | Description | |
| 269 | +| ------------ | -------- | ------------------------------------- | |
| 270 | +| `phone` | ✅ | Phone number column | |
| 271 | +| `text` | ✅ | Message text column | |
| 272 | +| `device_id` | ❌ | Device identifier column | |
| 273 | +| `sim_number` | ❌ | SIM number column (1-255) | |
| 274 | +| `priority` | ❌ | Message priority column (-128 to 127) | |
| 275 | + |
| 276 | +**Mapping examples:** |
| 277 | + |
| 278 | +```bash |
| 279 | +# Basic mapping with headers |
| 280 | +smsgate batch send --map phone=Phone,text=Message contacts.csv |
| 281 | + |
| 282 | +# Excel file with specific sheet |
| 283 | +smsgate batch send --sheet Sheet1 --map phone=Phone,text=Message campaign.xlsx |
| 284 | + |
| 285 | +# No headers, column positions |
| 286 | +smsgate batch send --header=false --map phone=col_1,text=col_2 data.csv |
| 287 | + |
| 288 | +# Full mapping with optional fields |
| 289 | +smsgate batch send --map phone=Phone,text=Message,device_id=Device,sim_number=SIM,priority=Priority contacts.csv |
| 290 | +``` |
| 291 | + |
| 292 | +**File format examples:** |
| 293 | + |
| 294 | +**CSV with Headers:** |
| 295 | +```csv |
| 296 | +Phone,Message,Device,Priority |
| 297 | ++12025550123,"Hello Dr. Turk!",device1,1 |
| 298 | ++12025550124,"Hello Dr. Smith!",device1,2 |
| 299 | ++12025550125,"Hello Dr. Jones!",device2,1 |
| 300 | +``` |
| 301 | + |
| 302 | +**CSV without Headers:** |
| 303 | +```csv |
| 304 | ++12025550123,"Hello Dr. Turk!",device1,1 |
| 305 | ++12025550124,"Hello Dr. Smith!",device1,2 |
| 306 | ++12025550125,"Hello Dr. Jones!",device2,1 |
175 | 307 | ``` |
176 | 308 |
|
| 309 | +**Excel Files:** |
| 310 | +- Supports multiple sheets (use `--sheet` to specify) |
| 311 | +- First row treated as headers by default |
| 312 | +- Column mapping works the same as CSV |
| 313 | + |
| 314 | +**Workflow modes:** |
| 315 | + |
| 316 | +1. **Validation Only** - Validates file format and column mapping, checks required fields, exits without sending: |
| 317 | + ```bash |
| 318 | + smsgate batch send --map phone=Phone,text=Message --validate-only contacts.csv |
| 319 | + ``` |
| 320 | + |
| 321 | +2. **Dry Run** - Validates and processes all rows, shows what would be sent without actually sending: |
| 322 | + ```bash |
| 323 | + smsgate batch send --map phone=Phone,text=Message --dry-run contacts.csv |
| 324 | + ``` |
| 325 | + |
| 326 | +3. **Full Send** - Sends all messages with real-time progress: |
| 327 | + ```bash |
| 328 | + smsgate batch send --map phone=Phone,text=Message --concurrency=5 contacts.csv |
| 329 | + ``` |
| 330 | + |
| 331 | +**Output and error handling:** |
| 332 | + |
| 333 | +- **Summary**: `Batch send summary: total=100 enqueued=95 failed=3 skipped=2` |
| 334 | +- **Real-time progress**: Shows each message's UUID and state during sending |
| 335 | +- **Error handling**: By default stops on first error; use `--continue-on-error` to send all rows even if some fail |
| 336 | + |
| 337 | +**Best practices:** |
| 338 | + |
| 339 | +1. Always use `--dry-run` or `--validate-only` first to test your configuration |
| 340 | +2. Ensure phone numbers are in E.164 format |
| 341 | +3. Start with lower concurrency values and increase as needed |
| 342 | +4. Use `--continue-on-error` for non-critical bulk sends |
| 343 | +5. Combine with inherited message options (e.g., `--device-id`, `--priority`) for advanced scenarios |
| 344 | + |
177 | 345 | #### Getting message status |
178 | 346 |
|
179 | 347 | ```bash |
|
0 commit comments