-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhatsapp-hub.ts
More file actions
666 lines (634 loc) · 25.7 KB
/
Copy pathwhatsapp-hub.ts
File metadata and controls
666 lines (634 loc) · 25.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
/**
* WhatsApp Hub (NooviConnect) — NooviChat's native WhatsApp group/channel
* management layer on top of a NooviConnect-enabled API inbox.
*
* These tools expose the "Hub" surface of the dashboard: list connected
* sessions, browse WhatsApp groups and channels (newsletters), read the
* aggregated Hub report, create groups and manage participants.
*
* IMPORTANT — the inbox is the NooviConnect session: `inbox_id` here is the
* `:id` member param of the `noovi_connect` resource (the inbox that owns the
* NooviConnect WhatsApp channel), NOT a separate session id. Use
* `noovi_connect_list_sessions` first to discover which inbox to act on.
*
* Routes (Chatwoot/config/routes.rb 612-658):
* /api/v1/accounts/:account_id/noovi_connect
* - GET / (index — list sessions)
* - GET /:id/groups (list WhatsApp groups)
* - GET /:id/newsletters (list channels / newsletters)
* - POST /:id/unfollow_newsletter (newsletter_id)
* - GET /:id/hub_report (aggregated Hub report)
* - POST /:id/create_group (create a group)
* - GET /:id/group_participants (?group_jid=…)
* - GET /:id/group_invite_link (?group_jid=…) → { invite_link, invite_code }
* - POST /:id/add_participants (group_jid, phones[])
* - POST /:id/remove_participants (group_jid, phones[])
* - POST /:id/promote_participants (group_jid, phones[])
* - POST /:id/demote_participants (group_jid, phones[])
* - POST /:id/set_group_name (group_jid, name)
* - POST /:id/set_group_topic (group_jid, topic)
* - POST /:id/set_group_photo (group_jid, photo)
* - POST /:id/set_group_locked (group_jid, locked)
* - POST /:id/set_group_announce (group_jid, announce)
* - POST /:id/leave_group (group_jid)
* - POST /:id/send_poll (phone, question, options[], max_answer?)
* - POST /:id/send_location (phone, latitude, longitude, title?)
* - GET /:id/profile (connected account profile)
* - POST /:id/set_profile_status (status)
* - GET /:id/check_number (?phone=…)
* - GET /:id/labels (WhatsApp Business labels)
* - GET /:id/label_chats (?label_id=…)
* - GET /:id/group_picture (?group_jid=…)
* - GET /:id/group_info_from_link (?link=…)
* - POST /:id/join_group_with_link (link)
*/
import { z } from "zod";
import type { RegisterFn } from "../types.js";
import { inboxId, optionalAccountId, resolveAccountId, safeHandler } from "./_helpers.js";
const groupJid = z
.string()
.min(1)
.describe(
"WhatsApp group JID (e.g. '120363000000000000@g.us'). Obtain it from noovi_connect_list_groups.",
);
const phones = z
.array(z.string().min(1))
.min(1)
.describe("Phone numbers (E.164, digits only, e.g. '5511999999999')");
const phone = z
.string()
.min(1)
.describe("Destination phone number (E.164, digits only, e.g. '5511999999999')");
export const register: RegisterFn = (server, client) => {
// ── Sessions ───────────────────────────────────────────────────────────────
server.registerTool(
"noovi_connect_list_sessions",
{
title: "WhatsApp Hub: list NooviConnect sessions",
description:
"List all NooviConnect WhatsApp sessions of the account (one per NooviConnect-enabled inbox), with connection status, phone number and whether each is working. Use this first to find the inbox_id to act on in the other WhatsApp Hub tools.",
inputSchema: { account_id: optionalAccountId },
annotations: { readOnlyHint: true },
},
async ({ account_id }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.get(`/api/v1/accounts/${acc}/noovi_connect`);
}),
);
// ── Groups ───────────────────────────────────────────────────────────────────
server.registerTool(
"noovi_connect_list_groups",
{
title: "WhatsApp Hub: list groups",
description:
"List the WhatsApp groups of a NooviConnect inbox (each with its JID, name and participant count). Use the JID with noovi_connect_group_participants or noovi_connect_add_participants.",
inputSchema: { account_id: optionalAccountId, inbox_id: inboxId },
annotations: { readOnlyHint: true },
},
async ({ account_id, inbox_id }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.get(`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/groups`);
}),
);
server.registerTool(
"noovi_connect_list_channels",
{
title: "WhatsApp Hub: list channels",
description:
"List the WhatsApp channels (newsletters) the NooviConnect inbox follows or owns, with JID, name, role and subscriber count.",
inputSchema: { account_id: optionalAccountId, inbox_id: inboxId },
annotations: { readOnlyHint: true },
},
async ({ account_id, inbox_id }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.get(`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/newsletters`);
}),
);
server.registerTool(
"noovi_connect_hub_report",
{
title: "WhatsApp Hub: report",
description:
"Get the aggregated WhatsApp Hub report for a NooviConnect inbox: counts of groups, channels, participants and broadcasts (active/total). Degrades gracefully to zeros when the provider is unavailable.",
inputSchema: { account_id: optionalAccountId, inbox_id: inboxId },
annotations: { readOnlyHint: true },
},
async ({ account_id, inbox_id }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.get(`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/hub_report`);
}),
);
// ── Group management ─────────────────────────────────────────────────────────
server.registerTool(
"noovi_connect_create_group",
{
title: "WhatsApp Hub: create group",
description:
"Create a new WhatsApp group on a NooviConnect inbox with a title and an initial list of participant phone numbers (E.164, digits only).",
inputSchema: {
account_id: optionalAccountId,
inbox_id: inboxId,
title: z.string().min(1).describe("Group title / subject"),
participants: z
.array(z.string().min(1))
.min(1)
.describe("Initial participant phone numbers (E.164, e.g. '5511999999999')"),
},
},
async ({ account_id, inbox_id, ...body }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.post(`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/create_group`, body);
}),
);
server.registerTool(
"noovi_connect_group_participants",
{
title: "WhatsApp Hub: group participants",
description:
"List the participants of a WhatsApp group on a NooviConnect inbox. Requires the group JID (from noovi_connect_list_groups).",
inputSchema: { account_id: optionalAccountId, inbox_id: inboxId, group_jid: groupJid },
annotations: { readOnlyHint: true },
},
async ({ account_id, inbox_id, group_jid }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.get(`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/group_participants`, {
group_jid,
});
}),
);
server.registerTool(
"noovi_connect_group_invite_link",
{
title: "WhatsApp Hub: group invite link",
description:
"Get the invite link (and invite code) of a WhatsApp group on a NooviConnect inbox. Requires the group JID. Returns { invite_link, invite_code }.",
inputSchema: { account_id: optionalAccountId, inbox_id: inboxId, group_jid: groupJid },
annotations: { readOnlyHint: true },
},
async ({ account_id, inbox_id, group_jid }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.get(`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/group_invite_link`, {
group_jid,
});
}),
);
server.registerTool(
"noovi_connect_add_participants",
{
title: "WhatsApp Hub: add participants",
description:
"Add one or more phone numbers to an existing WhatsApp group on a NooviConnect inbox. Requires the group JID and the phone numbers (E.164, digits only).",
inputSchema: {
account_id: optionalAccountId,
inbox_id: inboxId,
group_jid: groupJid,
phones,
},
},
async ({ account_id, inbox_id, ...body }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.post(
`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/add_participants`,
body,
);
}),
);
server.registerTool(
"noovi_connect_remove_participants",
{
title: "WhatsApp Hub: remove participants",
description:
"Remove one or more phone numbers from a WhatsApp group on a NooviConnect inbox. Requires the group JID and the phone numbers (E.164, digits only). The session must be a group admin.",
inputSchema: {
account_id: optionalAccountId,
inbox_id: inboxId,
group_jid: groupJid,
phones,
},
annotations: { destructiveHint: true },
},
async ({ account_id, inbox_id, ...body }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.post(
`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/remove_participants`,
body,
);
}),
);
server.registerTool(
"noovi_connect_promote_participants",
{
title: "WhatsApp Hub: promote participants",
description:
"Promote one or more group members to admin on a WhatsApp group of a NooviConnect inbox. Requires the group JID and the phone numbers (E.164, digits only).",
inputSchema: {
account_id: optionalAccountId,
inbox_id: inboxId,
group_jid: groupJid,
phones,
},
},
async ({ account_id, inbox_id, ...body }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.post(
`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/promote_participants`,
body,
);
}),
);
server.registerTool(
"noovi_connect_demote_participants",
{
title: "WhatsApp Hub: demote participants",
description:
"Demote one or more admins back to regular member on a WhatsApp group of a NooviConnect inbox. Requires the group JID and the phone numbers (E.164, digits only).",
inputSchema: {
account_id: optionalAccountId,
inbox_id: inboxId,
group_jid: groupJid,
phones,
},
},
async ({ account_id, inbox_id, ...body }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.post(
`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/demote_participants`,
body,
);
}),
);
// ── Group settings ───────────────────────────────────────────────────────────
server.registerTool(
"noovi_connect_set_group_name",
{
title: "WhatsApp Hub: set group name",
description:
"Update the name (subject) of a WhatsApp group on a NooviConnect inbox. Requires the group JID and the new name.",
inputSchema: {
account_id: optionalAccountId,
inbox_id: inboxId,
group_jid: groupJid,
name: z.string().min(1).describe("New group name / subject"),
},
annotations: { idempotentHint: true },
},
async ({ account_id, inbox_id, ...body }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.post(
`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/set_group_name`,
body,
);
}),
);
server.registerTool(
"noovi_connect_set_group_topic",
{
title: "WhatsApp Hub: set group topic",
description:
"Update the topic (description) of a WhatsApp group on a NooviConnect inbox. Requires the group JID; pass an empty topic to clear it.",
inputSchema: {
account_id: optionalAccountId,
inbox_id: inboxId,
group_jid: groupJid,
topic: z.string().describe("New group topic / description (empty string clears it)"),
},
annotations: { idempotentHint: true },
},
async ({ account_id, inbox_id, ...body }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.post(
`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/set_group_topic`,
body,
);
}),
);
server.registerTool(
"noovi_connect_set_group_photo",
{
title: "WhatsApp Hub: set group photo",
description:
"Update the picture of a WhatsApp group on a NooviConnect inbox. Requires the group JID and a publicly reachable image URL (the WhatsApp engine fetches it).",
inputSchema: {
account_id: optionalAccountId,
inbox_id: inboxId,
group_jid: groupJid,
photo: z.string().min(1).describe("Public image URL for the new group picture"),
},
annotations: { idempotentHint: true },
},
async ({ account_id, inbox_id, ...body }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.post(
`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/set_group_photo`,
body,
);
}),
);
server.registerTool(
"noovi_connect_set_group_locked",
{
title: "WhatsApp Hub: set group locked",
description:
"Toggle the 'only admins can edit group info' setting on a WhatsApp group of a NooviConnect inbox. Requires the group JID and the locked flag.",
inputSchema: {
account_id: optionalAccountId,
inbox_id: inboxId,
group_jid: groupJid,
locked: z
.boolean()
.describe("true = only admins can edit the group's info (name/topic/photo)"),
},
annotations: { idempotentHint: true },
},
async ({ account_id, inbox_id, ...body }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.post(
`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/set_group_locked`,
body,
);
}),
);
server.registerTool(
"noovi_connect_set_group_announce",
{
title: "WhatsApp Hub: set group announce",
description:
"Toggle the 'only admins can send messages' (announcement) setting on a WhatsApp group of a NooviConnect inbox. Requires the group JID and the announce flag.",
inputSchema: {
account_id: optionalAccountId,
inbox_id: inboxId,
group_jid: groupJid,
announce: z.boolean().describe("true = only admins can send messages (announcement group)"),
},
annotations: { idempotentHint: true },
},
async ({ account_id, inbox_id, ...body }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.post(
`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/set_group_announce`,
body,
);
}),
);
server.registerTool(
"noovi_connect_leave_group",
{
title: "WhatsApp Hub: leave group",
description:
"Make the NooviConnect session leave a WhatsApp group. Requires the group JID. This removes the connected number from the group.",
inputSchema: { account_id: optionalAccountId, inbox_id: inboxId, group_jid: groupJid },
annotations: { destructiveHint: true },
},
async ({ account_id, inbox_id, group_jid }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.post(`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/leave_group`, {
group_jid,
});
}),
);
// ── Channels (newsletters) ─────────────────────────────────────────────────────
server.registerTool(
"noovi_connect_unfollow_newsletter",
{
title: "WhatsApp Hub: unfollow channel",
description:
"Unfollow a WhatsApp channel (newsletter) on a NooviConnect inbox. Requires the newsletter JID (from noovi_connect_list_channels).",
inputSchema: {
account_id: optionalAccountId,
inbox_id: inboxId,
newsletter_id: z
.string()
.min(1)
.describe("Channel (newsletter) JID, e.g. '1203630000000000@newsletter'"),
},
annotations: { destructiveHint: true },
},
async ({ account_id, inbox_id, ...body }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.post(
`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/unfollow_newsletter`,
body,
);
}),
);
// ── Rich messages ──────────────────────────────────────────────────────────────
server.registerTool(
"noovi_connect_send_poll",
{
title: "WhatsApp Hub: send poll",
description:
"Send a poll message from a NooviConnect inbox to a phone number. Requires the phone, a question and at least 2 options.",
inputSchema: {
account_id: optionalAccountId,
inbox_id: inboxId,
phone,
question: z.string().min(1).describe("Poll question"),
options: z.array(z.string().min(1)).min(2).describe("Poll options (at least 2)"),
max_answer: z
.number()
.int()
.positive()
.optional()
.describe(
"Max answers per voter (>1 enables multiple-choice; defaults to single-choice)",
),
},
},
async ({ account_id, inbox_id, ...body }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.post(`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/send_poll`, body);
}),
);
server.registerTool(
"noovi_connect_send_location",
{
title: "WhatsApp Hub: send location",
description:
"Send a location (map pin) message from a NooviConnect inbox to a phone number. Requires the phone, latitude and longitude (decimal degrees).",
inputSchema: {
account_id: optionalAccountId,
inbox_id: inboxId,
phone,
latitude: z.number().describe("Latitude in decimal degrees"),
longitude: z.number().describe("Longitude in decimal degrees"),
title: z.string().optional().describe("Optional location title / label"),
},
},
async ({ account_id, inbox_id, ...body }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.post(`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/send_location`, body);
}),
);
// ── Profile ──────────────────────────────────────────────────────────────────
server.registerTool(
"noovi_connect_get_profile",
{
title: "WhatsApp Hub: get profile",
description:
"Get the connected WhatsApp account profile of a NooviConnect inbox (id, name and picture URL).",
inputSchema: { account_id: optionalAccountId, inbox_id: inboxId },
annotations: { readOnlyHint: true },
},
async ({ account_id, inbox_id }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.get(`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/profile`);
}),
);
server.registerTool(
"noovi_connect_set_profile_status",
{
title: "WhatsApp Hub: set profile status",
description:
"Update the connected account's WhatsApp status/about text on a NooviConnect inbox.",
inputSchema: {
account_id: optionalAccountId,
inbox_id: inboxId,
status: z.string().describe("New status/about text"),
},
},
async ({ account_id, inbox_id, ...body }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.post(
`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/set_profile_status`,
body,
);
}),
);
// ── Validation ───────────────────────────────────────────────────────────────
server.registerTool(
"noovi_connect_check_number",
{
title: "WhatsApp Hub: check number",
description:
"Check whether a phone number has an active WhatsApp account, via a NooviConnect inbox. Useful before messaging or broadcasting.",
inputSchema: { account_id: optionalAccountId, inbox_id: inboxId, phone },
annotations: { readOnlyHint: true },
},
async ({ account_id, inbox_id, phone: phoneArg }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.get(`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/check_number`, {
phone: phoneArg,
});
}),
);
// ── Labels (WhatsApp Business) ───────────────────────────────────────────────
server.registerTool(
"noovi_connect_list_labels",
{
title: "WhatsApp Hub: list labels",
description:
"List the WhatsApp Business labels of a NooviConnect inbox (id, name, color). Business accounts only; personal accounts return an empty list. Distinct from NooviChat conversation labels.",
inputSchema: { account_id: optionalAccountId, inbox_id: inboxId },
annotations: { readOnlyHint: true },
},
async ({ account_id, inbox_id }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.get(`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/labels`);
}),
);
server.registerTool(
"noovi_connect_list_label_chats",
{
title: "WhatsApp Hub: chats by label",
description:
"List the chats tagged with a WhatsApp Business label on a NooviConnect inbox. Requires the label id (from noovi_connect_list_labels).",
inputSchema: {
account_id: optionalAccountId,
inbox_id: inboxId,
label_id: z.string().min(1).describe("Label id (from noovi_connect_list_labels)"),
},
annotations: { readOnlyHint: true },
},
async ({ account_id, inbox_id, label_id }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.get(`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/label_chats`, {
label_id,
});
}),
);
// ── Group extras ─────────────────────────────────────────────────────────────
server.registerTool(
"noovi_connect_group_picture",
{
title: "WhatsApp Hub: group picture",
description:
"Get the picture URL of a WhatsApp group on a NooviConnect inbox (null when none). Requires the group JID.",
inputSchema: { account_id: optionalAccountId, inbox_id: inboxId, group_jid: groupJid },
annotations: { readOnlyHint: true },
},
async ({ account_id, inbox_id, group_jid }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.get(`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/group_picture`, {
group_jid,
});
}),
);
server.registerTool(
"noovi_connect_group_info_from_link",
{
title: "WhatsApp Hub: group info from link",
description:
"Preview a WhatsApp group from an invite link (without joining), via a NooviConnect inbox. Requires the invite link.",
inputSchema: {
account_id: optionalAccountId,
inbox_id: inboxId,
link: z.string().min(1).describe("Group invite link (https://chat.whatsapp.com/…)"),
},
annotations: { readOnlyHint: true },
},
async ({ account_id, inbox_id, link }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.get(
`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/group_info_from_link`,
{ link },
);
}),
);
server.registerTool(
"noovi_connect_join_group_with_link",
{
title: "WhatsApp Hub: join group by link",
description: "Join a WhatsApp group from an invite link, via a NooviConnect inbox.",
inputSchema: {
account_id: optionalAccountId,
inbox_id: inboxId,
link: z.string().min(1).describe("Group invite link (https://chat.whatsapp.com/…)"),
},
},
async ({ account_id, inbox_id, ...body }) =>
safeHandler(() => {
const acc = resolveAccountId(account_id);
return client.post(
`/api/v1/accounts/${acc}/noovi_connect/${inbox_id}/join_group_with_link`,
body,
);
}),
);
};