agent-messenger 2.20.5 → 2.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +8 -5
  3. package/dist/package.json +9 -1
  4. package/dist/src/cli.d.ts.map +1 -1
  5. package/dist/src/cli.js +3 -0
  6. package/dist/src/cli.js.map +1 -1
  7. package/dist/src/platforms/webex/client.d.ts +19 -0
  8. package/dist/src/platforms/webex/client.d.ts.map +1 -1
  9. package/dist/src/platforms/webex/client.js +81 -1
  10. package/dist/src/platforms/webex/client.js.map +1 -1
  11. package/dist/src/platforms/webexbot/cli.d.ts +5 -0
  12. package/dist/src/platforms/webexbot/cli.d.ts.map +1 -0
  13. package/dist/src/platforms/webexbot/cli.js +33 -0
  14. package/dist/src/platforms/webexbot/cli.js.map +1 -0
  15. package/dist/src/platforms/webexbot/client.d.ts +61 -0
  16. package/dist/src/platforms/webexbot/client.d.ts.map +1 -0
  17. package/dist/src/platforms/webexbot/client.js +80 -0
  18. package/dist/src/platforms/webexbot/client.js.map +1 -0
  19. package/dist/src/platforms/webexbot/commands/auth.d.ts +28 -0
  20. package/dist/src/platforms/webexbot/commands/auth.d.ts.map +1 -0
  21. package/dist/src/platforms/webexbot/commands/auth.js +166 -0
  22. package/dist/src/platforms/webexbot/commands/auth.js.map +1 -0
  23. package/dist/src/platforms/webexbot/commands/file.d.ts +22 -0
  24. package/dist/src/platforms/webexbot/commands/file.d.ts.map +1 -0
  25. package/dist/src/platforms/webexbot/commands/file.js +64 -0
  26. package/dist/src/platforms/webexbot/commands/file.js.map +1 -0
  27. package/dist/src/platforms/webexbot/commands/index.d.ts +10 -0
  28. package/dist/src/platforms/webexbot/commands/index.d.ts.map +1 -0
  29. package/dist/src/platforms/webexbot/commands/index.js +10 -0
  30. package/dist/src/platforms/webexbot/commands/index.js.map +1 -0
  31. package/dist/src/platforms/webexbot/commands/listen.d.ts +12 -0
  32. package/dist/src/platforms/webexbot/commands/listen.d.ts.map +1 -0
  33. package/dist/src/platforms/webexbot/commands/listen.js +85 -0
  34. package/dist/src/platforms/webexbot/commands/listen.js.map +1 -0
  35. package/dist/src/platforms/webexbot/commands/member.d.ts +19 -0
  36. package/dist/src/platforms/webexbot/commands/member.d.ts.map +1 -0
  37. package/dist/src/platforms/webexbot/commands/member.js +33 -0
  38. package/dist/src/platforms/webexbot/commands/member.js.map +1 -0
  39. package/dist/src/platforms/webexbot/commands/message.d.ts +44 -0
  40. package/dist/src/platforms/webexbot/commands/message.d.ts.map +1 -0
  41. package/dist/src/platforms/webexbot/commands/message.js +193 -0
  42. package/dist/src/platforms/webexbot/commands/message.js.map +1 -0
  43. package/dist/src/platforms/webexbot/commands/shared.d.ts +9 -0
  44. package/dist/src/platforms/webexbot/commands/shared.d.ts.map +1 -0
  45. package/dist/src/platforms/webexbot/commands/shared.js +13 -0
  46. package/dist/src/platforms/webexbot/commands/shared.js.map +1 -0
  47. package/dist/src/platforms/webexbot/commands/snapshot.d.ts +24 -0
  48. package/dist/src/platforms/webexbot/commands/snapshot.d.ts.map +1 -0
  49. package/dist/src/platforms/webexbot/commands/snapshot.js +37 -0
  50. package/dist/src/platforms/webexbot/commands/snapshot.js.map +1 -0
  51. package/dist/src/platforms/webexbot/commands/space.d.ts +28 -0
  52. package/dist/src/platforms/webexbot/commands/space.d.ts.map +1 -0
  53. package/dist/src/platforms/webexbot/commands/space.js +61 -0
  54. package/dist/src/platforms/webexbot/commands/space.js.map +1 -0
  55. package/dist/src/platforms/webexbot/commands/user.d.ts +30 -0
  56. package/dist/src/platforms/webexbot/commands/user.d.ts.map +1 -0
  57. package/dist/src/platforms/webexbot/commands/user.js +66 -0
  58. package/dist/src/platforms/webexbot/commands/user.js.map +1 -0
  59. package/dist/src/platforms/webexbot/commands/whoami.d.ts +16 -0
  60. package/dist/src/platforms/webexbot/commands/whoami.d.ts.map +1 -0
  61. package/dist/src/platforms/webexbot/commands/whoami.js +29 -0
  62. package/dist/src/platforms/webexbot/commands/whoami.js.map +1 -0
  63. package/dist/src/platforms/webexbot/credential-manager.d.ts +17 -0
  64. package/dist/src/platforms/webexbot/credential-manager.d.ts.map +1 -0
  65. package/dist/src/platforms/webexbot/credential-manager.js +120 -0
  66. package/dist/src/platforms/webexbot/credential-manager.js.map +1 -0
  67. package/dist/src/platforms/webexbot/index.d.ts +9 -0
  68. package/dist/src/platforms/webexbot/index.d.ts.map +1 -0
  69. package/dist/src/platforms/webexbot/index.js +6 -0
  70. package/dist/src/platforms/webexbot/index.js.map +1 -0
  71. package/dist/src/platforms/webexbot/listener.d.ts +44 -0
  72. package/dist/src/platforms/webexbot/listener.d.ts.map +1 -0
  73. package/dist/src/platforms/webexbot/listener.js +214 -0
  74. package/dist/src/platforms/webexbot/listener.js.map +1 -0
  75. package/dist/src/platforms/webexbot/types.d.ts +60 -0
  76. package/dist/src/platforms/webexbot/types.d.ts.map +1 -0
  77. package/dist/src/platforms/webexbot/types.js +28 -0
  78. package/dist/src/platforms/webexbot/types.js.map +1 -0
  79. package/dist/src/platforms/webexbot/wdm-discovery.d.ts +4 -0
  80. package/dist/src/platforms/webexbot/wdm-discovery.d.ts.map +1 -0
  81. package/dist/src/platforms/webexbot/wdm-discovery.js +36 -0
  82. package/dist/src/platforms/webexbot/wdm-discovery.js.map +1 -0
  83. package/docs/content/docs/cli/meta.json +1 -0
  84. package/docs/content/docs/cli/webexbot.mdx +292 -0
  85. package/docs/content/docs/sdk/meta.json +1 -0
  86. package/docs/content/docs/sdk/webexbot.mdx +342 -0
  87. package/docs/src/app/page.tsx +115 -19
  88. package/package.json +9 -1
  89. package/skills/agent-channeltalk/SKILL.md +1 -1
  90. package/skills/agent-channeltalkbot/SKILL.md +1 -1
  91. package/skills/agent-discord/SKILL.md +1 -1
  92. package/skills/agent-discordbot/SKILL.md +1 -1
  93. package/skills/agent-instagram/SKILL.md +1 -1
  94. package/skills/agent-kakaotalk/SKILL.md +1 -1
  95. package/skills/agent-line/SKILL.md +1 -1
  96. package/skills/agent-slack/SKILL.md +1 -1
  97. package/skills/agent-slackbot/SKILL.md +1 -1
  98. package/skills/agent-teams/SKILL.md +1 -1
  99. package/skills/agent-telegram/SKILL.md +1 -1
  100. package/skills/agent-telegrambot/SKILL.md +1 -1
  101. package/skills/agent-webex/SKILL.md +1 -1
  102. package/skills/agent-webexbot/SKILL.md +414 -0
  103. package/skills/agent-webexbot/references/authentication.md +225 -0
  104. package/skills/agent-webexbot/references/common-patterns.md +708 -0
  105. package/skills/agent-wechatbot/SKILL.md +1 -1
  106. package/skills/agent-whatsapp/SKILL.md +1 -1
  107. package/skills/agent-whatsappbot/SKILL.md +1 -1
  108. package/src/cli.ts +4 -0
  109. package/src/platforms/webex/client.test.ts +10 -0
  110. package/src/platforms/webex/client.ts +97 -3
  111. package/src/platforms/webex/typings/webex-message-handler.d.ts +360 -29
  112. package/src/platforms/webexbot/cli.ts +48 -0
  113. package/src/platforms/webexbot/client.test.ts +198 -0
  114. package/src/platforms/webexbot/client.ts +113 -0
  115. package/src/platforms/webexbot/commands/auth.test.ts +185 -0
  116. package/src/platforms/webexbot/commands/auth.ts +210 -0
  117. package/src/platforms/webexbot/commands/file.ts +104 -0
  118. package/src/platforms/webexbot/commands/index.ts +9 -0
  119. package/src/platforms/webexbot/commands/listen.test.ts +20 -0
  120. package/src/platforms/webexbot/commands/listen.ts +104 -0
  121. package/src/platforms/webexbot/commands/member.ts +51 -0
  122. package/src/platforms/webexbot/commands/message.ts +263 -0
  123. package/src/platforms/webexbot/commands/shared.ts +22 -0
  124. package/src/platforms/webexbot/commands/snapshot.ts +60 -0
  125. package/src/platforms/webexbot/commands/space.ts +88 -0
  126. package/src/platforms/webexbot/commands/user.test.ts +77 -0
  127. package/src/platforms/webexbot/commands/user.ts +98 -0
  128. package/src/platforms/webexbot/commands/whoami.ts +43 -0
  129. package/src/platforms/webexbot/credential-manager.test.ts +182 -0
  130. package/src/platforms/webexbot/credential-manager.ts +149 -0
  131. package/src/platforms/webexbot/index.ts +8 -0
  132. package/src/platforms/webexbot/listener.test.ts +234 -0
  133. package/src/platforms/webexbot/listener.ts +255 -0
  134. package/src/platforms/webexbot/types.test.ts +87 -0
  135. package/src/platforms/webexbot/types.ts +72 -0
  136. package/src/platforms/webexbot/wdm-discovery.test.ts +97 -0
  137. package/src/platforms/webexbot/wdm-discovery.ts +43 -0
@@ -0,0 +1,708 @@
1
+ # Common Patterns
2
+
3
+ ## Overview
4
+
5
+ This guide covers typical workflows for AI agents interacting with Cisco Webex using `agent-webexbot`.
6
+
7
+ **Note**: Webex uses opaque Base64-encoded IDs for spaces, messages, and people. You can't guess them. Always get IDs from `space list` first. The bot can only interact with spaces it has been added to.
8
+
9
+ ## Auth Patterns
10
+
11
+ ### Pattern 1: Authenticate
12
+
13
+ **Use case**: First-time setup
14
+
15
+ ```bash
16
+ #!/bin/bash
17
+
18
+ # Set bot token (validates against Webex API)
19
+ agent-webexbot auth set YOUR_BOT_TOKEN
20
+
21
+ # Or with a custom identifier for multi-bot setups
22
+ agent-webexbot auth set YOUR_BOT_TOKEN --bot deploy
23
+ ```
24
+
25
+ **When to use**: Before any other command, if not already authenticated.
26
+
27
+ ### Pattern 2: Check Auth Status
28
+
29
+ **Use case**: Verify authentication before running operations
30
+
31
+ ```bash
32
+ #!/bin/bash
33
+
34
+ STATUS=$(agent-webexbot auth status)
35
+
36
+ if echo "$STATUS" | jq -e '.error' > /dev/null 2>&1; then
37
+ echo "Not authenticated. Run 'auth set <token>' first."
38
+ exit 1
39
+ fi
40
+
41
+ BOT_NAME=$(echo "$STATUS" | jq -r '.bot_name')
42
+ echo "Authenticated as: $BOT_NAME"
43
+ ```
44
+
45
+ **When to use**: Start of any script or workflow.
46
+
47
+ ## Space Patterns
48
+
49
+ ### Pattern 3: List All Spaces
50
+
51
+ **Use case**: Discover spaces the bot is a member of
52
+
53
+ ```bash
54
+ #!/bin/bash
55
+
56
+ # List all spaces
57
+ SPACES=$(agent-webexbot space list)
58
+ echo "$SPACES" | jq -r '.spaces[] | "\(.title) (\(.id))"'
59
+ ```
60
+
61
+ ### Pattern 4: Filter Spaces by Type
62
+
63
+ **Use case**: Show only group spaces or direct messages
64
+
65
+ ```bash
66
+ #!/bin/bash
67
+
68
+ # Group spaces only
69
+ agent-webexbot space list --type group
70
+
71
+ # Direct messages only
72
+ agent-webexbot space list --type direct
73
+
74
+ # Limit results
75
+ agent-webexbot space list --type group --max 10
76
+ ```
77
+
78
+ ### Pattern 5: Get Space Info
79
+
80
+ **Use case**: Look up details for a specific space
81
+
82
+ ```bash
83
+ #!/bin/bash
84
+
85
+ SPACE_ID="Y2lzY29zcGFyazovL..."
86
+
87
+ INFO=$(agent-webexbot space info "$SPACE_ID")
88
+ TITLE=$(echo "$INFO" | jq -r '.title')
89
+ TYPE=$(echo "$INFO" | jq -r '.type')
90
+
91
+ echo "Space: $TITLE ($TYPE)"
92
+ ```
93
+
94
+ ### Pattern 6: Find Space by Title
95
+
96
+ **Use case**: Get a space ID from its title
97
+
98
+ ```bash
99
+ #!/bin/bash
100
+
101
+ find_space_id() {
102
+ local title=$1
103
+
104
+ SPACES=$(agent-webexbot space list)
105
+ SPACE_ID=$(echo "$SPACES" | jq -r --arg t "$title" '.spaces[] | select(.title==$t) | .id')
106
+
107
+ if [ -z "$SPACE_ID" ]; then
108
+ echo "Space '$title' not found" >&2
109
+ return 1
110
+ fi
111
+
112
+ echo "$SPACE_ID"
113
+ }
114
+
115
+ # Usage
116
+ ENG_ID=$(find_space_id "Engineering")
117
+ if [ $? -eq 0 ]; then
118
+ agent-webexbot message send "$ENG_ID" "Hello Engineering!"
119
+ fi
120
+ ```
121
+
122
+ **When to use**: When you know the space title but need the ID.
123
+
124
+ ## Message Patterns
125
+
126
+ ### Pattern 7: Send a Simple Message
127
+
128
+ **Use case**: Post a notification or update
129
+
130
+ ```bash
131
+ #!/bin/bash
132
+
133
+ SPACE_ID="Y2lzY29zcGFyazovL..."
134
+
135
+ RESULT=$(agent-webexbot message send "$SPACE_ID" "Deployment completed successfully!")
136
+
137
+ if echo "$RESULT" | jq -e '.id' > /dev/null 2>&1; then
138
+ echo "Message sent!"
139
+ else
140
+ echo "Failed: $(echo "$RESULT" | jq -r '.error')"
141
+ exit 1
142
+ fi
143
+ ```
144
+
145
+ ### Pattern 8: Send a Markdown Message
146
+
147
+ **Use case**: Rich formatting in messages
148
+
149
+ ```bash
150
+ #!/bin/bash
151
+
152
+ SPACE_ID="Y2lzY29zcGFyazovL..."
153
+
154
+ agent-webexbot message send "$SPACE_ID" "**Build Status**
155
+ - Branch: \`main\`
156
+ - Tests: 142 passed, 0 failed
157
+ - Coverage: 94.2%" --markdown
158
+ ```
159
+
160
+ ### Pattern 9: Send a Direct Message
161
+
162
+ **Use case**: Message someone directly by email, without finding a space ID first
163
+
164
+ ```bash
165
+ #!/bin/bash
166
+
167
+ # Send a DM by email
168
+ agent-webexbot message dm alice@example.com "Hey, quick question about the PR"
169
+
170
+ # Send a DM with markdown
171
+ agent-webexbot message dm alice@example.com "**Build failed** - can you check?" --markdown
172
+ ```
173
+
174
+ **When to use**: Quick 1:1 messages when you know the recipient's email.
175
+
176
+ ### Pattern 10: Send and Track a Message
177
+
178
+ **Use case**: Send a message and save its ID for later editing
179
+
180
+ ```bash
181
+ #!/bin/bash
182
+
183
+ SPACE_ID="Y2lzY29zcGFyazovL..."
184
+
185
+ # Send initial status
186
+ RESULT=$(agent-webexbot message send "$SPACE_ID" "Deploying v2.1.0...")
187
+ MSG_ID=$(echo "$RESULT" | jq -r '.id')
188
+
189
+ # ... do work ...
190
+ sleep 5
191
+
192
+ # Update the message with final status
193
+ agent-webexbot message edit "$MSG_ID" "$SPACE_ID" "Deployed v2.1.0 successfully!"
194
+ ```
195
+
196
+ ### Pattern 11: List Recent Messages
197
+
198
+ **Use case**: Read conversation history
199
+
200
+ ```bash
201
+ #!/bin/bash
202
+
203
+ SPACE_ID="Y2lzY29zcGFyazovL..."
204
+
205
+ # Get last 10 messages
206
+ MESSAGES=$(agent-webexbot message list "$SPACE_ID" --max 10)
207
+
208
+ echo "$MESSAGES" | jq -r '.messages[] | "[\(.created)] \(.personEmail): \(.text)"'
209
+ ```
210
+
211
+ ### Pattern 12: Delete a Message
212
+
213
+ **Use case**: Remove a message the bot sent
214
+
215
+ ```bash
216
+ #!/bin/bash
217
+
218
+ MESSAGE_ID="Y2lzY29zcGFyazovL..."
219
+
220
+ agent-webexbot message delete "$MESSAGE_ID"
221
+ ```
222
+
223
+ ## Thread Patterns
224
+
225
+ ### Pattern 12a: Reply in a Thread
226
+
227
+ **Use case**: Keep a conversation organized under a parent message
228
+
229
+ ```bash
230
+ #!/bin/bash
231
+
232
+ SPACE_ID="Y2lzY29zcGFyazovL..."
233
+
234
+ # Send a parent message and capture its ID
235
+ PARENT=$(agent-webexbot message send "$SPACE_ID" "Deploy started" | jq -r '.id')
236
+
237
+ # Reply within the thread
238
+ agent-webexbot message reply "$SPACE_ID" "$PARENT" "Step 1 complete"
239
+
240
+ # Equivalent using send --parent
241
+ agent-webexbot message send "$SPACE_ID" "Step 2 complete" --parent "$PARENT"
242
+ ```
243
+
244
+ ### Pattern 12b: Read Thread Replies
245
+
246
+ **Use case**: Fetch all replies under a parent message
247
+
248
+ ```bash
249
+ #!/bin/bash
250
+
251
+ SPACE_ID="Y2lzY29zcGFyazovL..."
252
+ PARENT_ID="Y2lzY29zcGFyazovL..."
253
+
254
+ agent-webexbot message replies "$SPACE_ID" "$PARENT_ID" --max 20 \
255
+ | jq -r '.messages[] | "[\(.created)] \(.personEmail): \(.text)"'
256
+ ```
257
+
258
+ ## File Patterns
259
+
260
+ ### Pattern 12c: Upload a File
261
+
262
+ **Use case**: Attach a local file (report, log, image) to a space
263
+
264
+ ```bash
265
+ #!/bin/bash
266
+
267
+ SPACE_ID="Y2lzY29zcGFyazovL..."
268
+
269
+ # Upload with an accompanying message
270
+ agent-webexbot file upload "$SPACE_ID" ./coverage.html --text "Latest coverage report"
271
+
272
+ # Upload as a threaded reply
273
+ agent-webexbot file upload "$SPACE_ID" ./build.log --parent "$PARENT_ID"
274
+ ```
275
+
276
+ **Note**: Max file size is 100 MB, one file per message.
277
+
278
+ ### Pattern 12d: Download an Attachment
279
+
280
+ **Use case**: Save a file someone shared in a space
281
+
282
+ ```bash
283
+ #!/bin/bash
284
+
285
+ SPACE_ID="Y2lzY29zcGFyazovL..."
286
+
287
+ # Get the content URL from a message's "files" array
288
+ CONTENT_URL=$(agent-webexbot message list "$SPACE_ID" --max 20 \
289
+ | jq -r 'first(.messages[].files[]? // empty)')
290
+
291
+ # Download (defaults to the original filename in the current directory)
292
+ agent-webexbot file download "$CONTENT_URL"
293
+
294
+ # Or choose an output path explicitly
295
+ agent-webexbot file download "$CONTENT_URL" ./downloaded-report.html
296
+ ```
297
+
298
+ **Security note**: Downloads are restricted to `https://webexapis.com/v1/contents/*` URLs — the bot token is never sent to other hosts. Server-provided filenames are reduced to their base name, so the default output always stays in the current directory.
299
+
300
+ ## People Patterns
301
+
302
+ ### Pattern 12e: Look Up a Person by Email
303
+
304
+ **Use case**: Resolve a person ID or display name from an email address
305
+
306
+ ```bash
307
+ #!/bin/bash
308
+
309
+ agent-webexbot user list --email alice@example.com \
310
+ | jq -r '.users[] | "\(.displayName) — \(.id)"'
311
+ ```
312
+
313
+ ### Pattern 12f: Get Person Details
314
+
315
+ **Use case**: Fetch full profile details for a known person ID
316
+
317
+ ```bash
318
+ #!/bin/bash
319
+
320
+ PERSON_ID="Y2lzY29zcGFyazovL..."
321
+
322
+ agent-webexbot user info "$PERSON_ID" | jq '{displayName, emails, type}'
323
+ ```
324
+
325
+ ## Snapshot Patterns
326
+
327
+ ### Pattern 12g: Workspace Overview
328
+
329
+ **Use case**: Give an AI agent a quick picture of the bot's workspace
330
+
331
+ ```bash
332
+ #!/bin/bash
333
+
334
+ # Brief: bot identity + space IDs/titles
335
+ agent-webexbot snapshot
336
+
337
+ # Full: includes space type and last activity
338
+ agent-webexbot snapshot --full --max 50
339
+ ```
340
+
341
+ ## Member Patterns
342
+
343
+ ### Pattern 13: List Space Members
344
+
345
+ **Use case**: See who's in a space
346
+
347
+ ```bash
348
+ #!/bin/bash
349
+
350
+ SPACE_ID="Y2lzY29zcGFyazovL..."
351
+
352
+ MEMBERS=$(agent-webexbot member list "$SPACE_ID")
353
+ echo "$MEMBERS" | jq -r '.members[] | "\(.personDisplayName) (\(.personEmail))"'
354
+ ```
355
+
356
+ ### Pattern 14: Find a Specific Member
357
+
358
+ **Use case**: Look up a person in a space
359
+
360
+ ```bash
361
+ #!/bin/bash
362
+
363
+ SPACE_ID="Y2lzY29zcGFyazovL..."
364
+ SEARCH_NAME="alice"
365
+
366
+ MEMBERS=$(agent-webexbot member list "$SPACE_ID")
367
+ MATCH=$(echo "$MEMBERS" | jq -r --arg name "$SEARCH_NAME" \
368
+ 'first(.members[] | select(.personDisplayName | ascii_downcase | contains($name | ascii_downcase)))')
369
+
370
+ if [ -z "$MATCH" ] || [ "$MATCH" = "null" ]; then
371
+ echo "No member matching '$SEARCH_NAME'"
372
+ exit 1
373
+ fi
374
+
375
+ echo "Found: $(echo "$MATCH" | jq -r '.personDisplayName') ($(echo "$MATCH" | jq -r '.personEmail'))"
376
+ ```
377
+
378
+ ## Real-Time Event Patterns
379
+
380
+ ### Pattern 15: Stream All Events
381
+
382
+ **Use case**: Monitor a bot's activity in real time
383
+
384
+ ```bash
385
+ #!/bin/bash
386
+
387
+ # Stream events as NDJSON (Ctrl+C to stop)
388
+ agent-webexbot listen
389
+ ```
390
+
391
+ ### Pattern 16: Filter to Specific Events
392
+
393
+ **Use case**: Only care about new messages
394
+
395
+ ```bash
396
+ #!/bin/bash
397
+
398
+ agent-webexbot listen --events message_created
399
+ ```
400
+
401
+ ### Pattern 17: React to Messages
402
+
403
+ **Use case**: Respond to keywords in real time
404
+
405
+ ```bash
406
+ #!/bin/bash
407
+
408
+ agent-webexbot listen --events message_created | while read -r line; do
409
+ TEXT=$(echo "$line" | jq -r '.payload.text // ""')
410
+ SPACE=$(echo "$line" | jq -r '.payload.roomId // ""')
411
+
412
+ if echo "$TEXT" | grep -qi "status"; then
413
+ agent-webexbot message send "$SPACE" "All systems operational."
414
+ fi
415
+
416
+ if echo "$TEXT" | grep -qi "help"; then
417
+ agent-webexbot message send "$SPACE" "Available commands: \`status\`, \`help\`"
418
+ fi
419
+ done
420
+ ```
421
+
422
+ ### Pattern 18: Log Events to File
423
+
424
+ **Use case**: Audit trail of bot activity
425
+
426
+ ```bash
427
+ #!/bin/bash
428
+
429
+ LOG_FILE="/var/log/webexbot-events.ndjson"
430
+
431
+ agent-webexbot listen >> "$LOG_FILE"
432
+ ```
433
+
434
+ ## Pipeline Patterns
435
+
436
+ ### Pattern 19: Send to Multiple Spaces
437
+
438
+ **Use case**: Broadcast a message across spaces
439
+
440
+ ```bash
441
+ #!/bin/bash
442
+
443
+ MESSAGE="System maintenance in 30 minutes"
444
+ SPACE_NAMES=("Engineering" "Product" "General")
445
+
446
+ # Get all spaces once
447
+ SPACES=$(agent-webexbot space list)
448
+
449
+ for name in "${SPACE_NAMES[@]}"; do
450
+ SPACE_ID=$(echo "$SPACES" | jq -r --arg t "$name" '.spaces[] | select(.title==$t) | .id')
451
+
452
+ if [ -z "$SPACE_ID" ]; then
453
+ echo "Space '$name' not found, skipping"
454
+ continue
455
+ fi
456
+
457
+ echo "Posting to $name..."
458
+ RESULT=$(agent-webexbot message send "$SPACE_ID" "$MESSAGE")
459
+
460
+ if echo "$RESULT" | jq -e '.id' > /dev/null 2>&1; then
461
+ echo " Sent to $name"
462
+ else
463
+ echo " Failed: $(echo "$RESULT" | jq -r '.error')"
464
+ fi
465
+
466
+ # Rate limit: don't spam the API
467
+ sleep 1
468
+ done
469
+ ```
470
+
471
+ ### Pattern 20: Conditional Messaging
472
+
473
+ **Use case**: Send different messages based on conditions
474
+
475
+ ```bash
476
+ #!/bin/bash
477
+
478
+ SPACE_ID="Y2lzY29zcGFyazovL..."
479
+ BUILD_STATUS=$1 # "success" or "failure"
480
+
481
+ if [ "$BUILD_STATUS" = "success" ]; then
482
+ agent-webexbot message send "$SPACE_ID" "Build passed. All tests green." --markdown
483
+ else
484
+ agent-webexbot message send "$SPACE_ID" "**Build failed.** Check CI logs for details." --markdown
485
+ fi
486
+ ```
487
+
488
+ ### Pattern 21: Error Handling with Retry
489
+
490
+ **Use case**: Robust message sending for production scripts
491
+
492
+ ```bash
493
+ #!/bin/bash
494
+
495
+ send_with_retry() {
496
+ local space_id=$1
497
+ local message=$2
498
+ local max_attempts=3
499
+ local attempt=1
500
+
501
+ while [ $attempt -le $max_attempts ]; do
502
+ RESULT=$(agent-webexbot message send "$space_id" "$message")
503
+
504
+ if echo "$RESULT" | jq -e '.id' > /dev/null 2>&1; then
505
+ echo "Message sent successfully!"
506
+ return 0
507
+ fi
508
+
509
+ ERROR=$(echo "$RESULT" | jq -r '.error // "Unknown error"')
510
+ echo "Attempt $attempt failed: $ERROR"
511
+
512
+ # Don't retry on auth errors
513
+ if echo "$ERROR" | grep -qi "401\|unauthorized\|not authenticated\|no credentials"; then
514
+ echo "Authentication error. Fix credentials and try again."
515
+ return 1
516
+ fi
517
+
518
+ # Don't retry on not-found errors
519
+ if echo "$ERROR" | grep -qi "not found\|404"; then
520
+ echo "Resource not found. Check your IDs."
521
+ return 1
522
+ fi
523
+
524
+ if [ $attempt -lt $max_attempts ]; then
525
+ SLEEP_TIME=$((attempt * 2))
526
+ echo "Retrying in ${SLEEP_TIME}s..."
527
+ sleep $SLEEP_TIME
528
+ fi
529
+
530
+ attempt=$((attempt + 1))
531
+ done
532
+
533
+ echo "Failed after $max_attempts attempts"
534
+ return 1
535
+ }
536
+
537
+ # Usage
538
+ SPACE_ID="Y2lzY29zcGFyazovL..."
539
+ send_with_retry "$SPACE_ID" "Important notification!"
540
+ ```
541
+
542
+ ### Pattern 22: Daily Summary Report
543
+
544
+ **Use case**: Generate a workspace activity summary
545
+
546
+ ```bash
547
+ #!/bin/bash
548
+
549
+ SPACE_ID="Y2lzY29zcGFyazovL..."
550
+
551
+ # Get recent messages
552
+ MESSAGES=$(agent-webexbot message list "$SPACE_ID" --max 50)
553
+ MSG_COUNT=$(echo "$MESSAGES" | jq '.messages | length')
554
+
555
+ # Get members
556
+ MEMBERS=$(agent-webexbot member list "$SPACE_ID")
557
+ MEMBER_COUNT=$(echo "$MEMBERS" | jq '.members | length')
558
+
559
+ # Get unique authors from recent messages
560
+ AUTHORS=$(echo "$MESSAGES" | jq -r '[.messages[].personEmail] | unique | length')
561
+
562
+ SUMMARY="**Daily Summary**
563
+ - Messages (last 50): $MSG_COUNT
564
+ - Active authors: $AUTHORS
565
+ - Total members: $MEMBER_COUNT"
566
+
567
+ agent-webexbot message send "$SPACE_ID" "$SUMMARY" --markdown
568
+ ```
569
+
570
+ ### Pattern 23: Multi-Bot Deployment Workflow
571
+
572
+ **Use case**: Use different bots for different environments
573
+
574
+ ```bash
575
+ #!/bin/bash
576
+
577
+ ENVIRONMENT=$1 # "staging" or "production"
578
+ SPACE_ID="Y2lzY29zcGFyazovL..."
579
+
580
+ if [ "$ENVIRONMENT" = "production" ]; then
581
+ agent-webexbot --bot prod-alerts message send "$SPACE_ID" "Production deploy started"
582
+ else
583
+ agent-webexbot --bot staging-alerts message send "$SPACE_ID" "Staging deploy started"
584
+ fi
585
+ ```
586
+
587
+ ## Best Practices
588
+
589
+ ### 1. Always Check for Success
590
+
591
+ ```bash
592
+ # Good
593
+ RESULT=$(agent-webexbot message send "$SPACE_ID" "Hello")
594
+ if echo "$RESULT" | jq -e '.id' > /dev/null 2>&1; then
595
+ echo "Success!"
596
+ else
597
+ echo "Failed: $(echo "$RESULT" | jq -r '.error')"
598
+ fi
599
+
600
+ # Bad
601
+ agent-webexbot message send "$SPACE_ID" "Hello" # No error checking
602
+ ```
603
+
604
+ ### 2. Cache Space Lists
605
+
606
+ ```bash
607
+ # Good - fetch once, reuse
608
+ SPACES=$(agent-webexbot space list)
609
+ for title in "${SPACE_TITLES[@]}"; do
610
+ id=$(echo "$SPACES" | jq -r --arg t "$title" '.spaces[] | select(.title==$t) | .id')
611
+ agent-webexbot message send "$id" "$MESSAGE"
612
+ done
613
+
614
+ # Bad - fetch repeatedly
615
+ for title in "${SPACE_TITLES[@]}"; do
616
+ SPACES=$(agent-webexbot space list) # Wasteful!
617
+ id=$(echo "$SPACES" | jq -r --arg t "$title" '.spaces[] | select(.title==$t) | .id')
618
+ agent-webexbot message send "$id" "$MESSAGE"
619
+ done
620
+ ```
621
+
622
+ ### 3. Rate Limit Your Requests
623
+
624
+ ```bash
625
+ # Good - respect Webex API limits (~600 req/min)
626
+ for space_id in "${SPACE_IDS[@]}"; do
627
+ agent-webexbot message send "$space_id" "$MESSAGE"
628
+ sleep 1
629
+ done
630
+
631
+ # Bad - rapid-fire requests
632
+ for space_id in "${SPACE_IDS[@]}"; do
633
+ agent-webexbot message send "$space_id" "$MESSAGE"
634
+ done
635
+ ```
636
+
637
+ ### 4. Use the Listen Command for Real-Time Needs
638
+
639
+ ```bash
640
+ # Good - event-driven, no polling
641
+ agent-webexbot listen --events message_created | while read -r line; do
642
+ # handle event
643
+ done
644
+
645
+ # Bad - polling wastes API quota and adds latency
646
+ while true; do
647
+ agent-webexbot message list "$SPACE_ID" --max 1
648
+ sleep 5
649
+ done
650
+ ```
651
+
652
+ ### 5. Don't Spam Spaces
653
+
654
+ ```bash
655
+ # Bad - sends 100 messages
656
+ for i in {1..100}; do
657
+ agent-webexbot message send "$SPACE_ID" "Item $i"
658
+ done
659
+
660
+ # Good - batch into single message
661
+ MESSAGE="Updates:"
662
+ for i in {1..100}; do
663
+ MESSAGE="$MESSAGE\n$i. Item $i"
664
+ done
665
+ agent-webexbot message send "$SPACE_ID" "$MESSAGE"
666
+ ```
667
+
668
+ ## Anti-Patterns
669
+
670
+ ### Don't Ignore Auth Errors
671
+
672
+ ```bash
673
+ # Bad
674
+ agent-webexbot message send "$SPACE_ID" "Hello"
675
+ # Continues even if not authenticated
676
+
677
+ # Good
678
+ RESULT=$(agent-webexbot message send "$SPACE_ID" "Hello")
679
+ if echo "$RESULT" | grep -qi "401\|unauthorized\|no credentials"; then
680
+ echo "Auth failed. Run 'auth set <token>' to re-authenticate."
681
+ exit 1
682
+ fi
683
+ ```
684
+
685
+ ### Don't Hardcode IDs Without Context
686
+
687
+ ```bash
688
+ # Bad - mystery ID
689
+ agent-webexbot message send "Y2lzY29zcGFyazovL..." "Hello"
690
+
691
+ # Good - document what the ID refers to
692
+ ENGINEERING_SPACE="Y2lzY29zcGFyazovL..." # Engineering space
693
+ agent-webexbot message send "$ENGINEERING_SPACE" "Hello"
694
+ ```
695
+
696
+ ### Don't Use agent-webexbot for User-Level Access
697
+
698
+ ```bash
699
+ # Wrong tool for the job
700
+ agent-webexbot auth set YOUR_USER_TOKEN # Will fail - not a bot token
701
+
702
+ # Right tool
703
+ agent-webex auth login # For user-level access
704
+ ```
705
+
706
+ ## See Also
707
+
708
+ - [Authentication Guide](authentication.md) - Token types, storage, and troubleshooting
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: agent-wechatbot
3
3
  description: Interact with WeChat Official Account using API credentials - send messages, manage templates, list followers
4
- version: 2.20.5
4
+ version: 2.22.0
5
5
  allowed-tools: Bash(agent-wechatbot:*)
6
6
  metadata:
7
7
  openclaw:
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: agent-whatsapp
3
3
  description: Interact with WhatsApp - send messages, read chats, manage conversations
4
- version: 2.20.5
4
+ version: 2.22.0
5
5
  allowed-tools: Bash(agent-whatsapp:*)
6
6
  metadata:
7
7
  openclaw: