@zerodot/telegram 1.1.0 → 1.2.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.
- package/README.md +36 -0
- package/dist/index.cjs +46 -22
- package/package.json +9 -5
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# @zerodot/telegram
|
|
2
|
+
|
|
3
|
+
<img src="https://raw.githubusercontent.com/zerodot-io/nodes/main/packages/telegram/telegram.svg" alt="Telegram logo" width="48" height="48">
|
|
4
|
+
|
|
5
|
+
Send messages and files with a Telegram bot, and start a workflow when the bot gets a message or other update. Use it to build chat bots and notifications.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
In zerodot, go to **System > Nodes** and install **Telegram**.
|
|
10
|
+
|
|
11
|
+
Manual: install `@zerodot/telegram` where the web app and the worker run, and add it to `ZERODOT_NODE_PACKAGES`.
|
|
12
|
+
|
|
13
|
+
## Nodes
|
|
14
|
+
|
|
15
|
+
### Telegram (`telegram.bot`)
|
|
16
|
+
|
|
17
|
+
- **Message**: send, edit, delete, pin, unpin, send a chat action
|
|
18
|
+
- **Media**: send a photo, video, audio file, document, animation, sticker, location, or media group
|
|
19
|
+
- **Wait for response**: send a message and wait for an approval, a free text, or a form
|
|
20
|
+
- **Chat**: get information, get the administrators, get a member, leave, set the title, set the description
|
|
21
|
+
- **Callback and inline query**: answer
|
|
22
|
+
- **File**: get a file, and download it to binary data
|
|
23
|
+
|
|
24
|
+
Messages can have inline keyboards and reply keyboards. Files can come from a URL, a `file_id`, or binary data of the input.
|
|
25
|
+
|
|
26
|
+
### Telegram Trigger (`trigger.telegram`)
|
|
27
|
+
|
|
28
|
+
Starts a run on a bot update, for example a message, a callback query, or an inline query. You can accept updates only from some chats or users. The trigger sets the webhook of the bot, so Telegram must be able to reach your zerodot instance. A bot has one webhook only.
|
|
29
|
+
|
|
30
|
+
## Credential
|
|
31
|
+
|
|
32
|
+
**Telegram bot** (`telegram.bot`): `accessToken` from [@BotFather](https://t.me/BotFather), and an optional `baseUrl` for a local Bot API server. The token is secret.
|
|
33
|
+
|
|
34
|
+
## License
|
|
35
|
+
|
|
36
|
+
AGPL-3.0-only
|
package/dist/index.cjs
CHANGED
|
@@ -56,7 +56,7 @@ const telegramCredential = {
|
|
|
56
56
|
baseUrl: zod.z.url().optional().meta({ placeholder: "https://api.telegram.org" })
|
|
57
57
|
}),
|
|
58
58
|
secretFields: ["accessToken"],
|
|
59
|
-
icon: "
|
|
59
|
+
icon: "SentIcon",
|
|
60
60
|
iconUrl: TELEGRAM_ICON,
|
|
61
61
|
async test({ data }) {
|
|
62
62
|
const token = text(data.accessToken);
|
|
@@ -185,6 +185,16 @@ const additionalFields = zod.z.object({
|
|
|
185
185
|
mimeType: zod.z.string()
|
|
186
186
|
}).partial().catchall(zod.z.unknown());
|
|
187
187
|
const forOperations = (...operations) => ({ showWhen: { operation: operations } });
|
|
188
|
+
/** The field is necessary at run time when it shows. */
|
|
189
|
+
const requiredFor = (...operations) => ({
|
|
190
|
+
...forOperations(...operations),
|
|
191
|
+
requiredWhenShown: true
|
|
192
|
+
});
|
|
193
|
+
/** An edit of an inline message uses `inlineMessageId`, not a chat and a message. */
|
|
194
|
+
const NOT_FOR_INLINE = { hideWhen: {
|
|
195
|
+
operation: ["editMessageText"],
|
|
196
|
+
messageType: ["inlineMessage"]
|
|
197
|
+
} };
|
|
188
198
|
const SEND_FILE = [
|
|
189
199
|
"sendPhoto",
|
|
190
200
|
"sendVideo",
|
|
@@ -276,7 +286,6 @@ const telegramConfig = zod.z.object({
|
|
|
276
286
|
}
|
|
277
287
|
}),
|
|
278
288
|
chatId: id.optional().meta({
|
|
279
|
-
...forOperations("sendMessage", "editMessageText", "deleteMessage", "pinChatMessage", "unpinChatMessage", ...SEND_FILE, "sendLocation", "sendMediaGroup", "sendChatAction", "sendAndWait", "get", "administrators", "member", "leave", "setTitle", "setDescription"),
|
|
280
289
|
showWhen: {
|
|
281
290
|
resource: ["message", "chat"],
|
|
282
291
|
operation: [
|
|
@@ -298,9 +307,14 @@ const telegramConfig = zod.z.object({
|
|
|
298
307
|
"setDescription"
|
|
299
308
|
]
|
|
300
309
|
},
|
|
310
|
+
...NOT_FOR_INLINE,
|
|
311
|
+
requiredWhenShown: true,
|
|
301
312
|
description: "Unique identifier of the target chat, or @channelusername"
|
|
302
313
|
}),
|
|
303
|
-
messageId: id.optional().meta(
|
|
314
|
+
messageId: id.optional().meta({
|
|
315
|
+
...requiredFor("editMessageText", "deleteMessage", "pinChatMessage", "unpinChatMessage"),
|
|
316
|
+
...NOT_FOR_INLINE
|
|
317
|
+
}),
|
|
304
318
|
messageType: zod.z.enum(["message", "inlineMessage"]).optional().meta({
|
|
305
319
|
...forOperations("editMessageText"),
|
|
306
320
|
labels: {
|
|
@@ -312,19 +326,28 @@ const telegramConfig = zod.z.object({
|
|
|
312
326
|
inlineMessage: "A message that was sent through inline mode"
|
|
313
327
|
}
|
|
314
328
|
}),
|
|
315
|
-
inlineMessageId: zod.z.string().optional().meta(
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
329
|
+
inlineMessageId: zod.z.string().optional().meta({
|
|
330
|
+
showWhen: {
|
|
331
|
+
operation: ["editMessageText"],
|
|
332
|
+
messageType: ["inlineMessage"]
|
|
333
|
+
},
|
|
334
|
+
requiredWhenShown: true
|
|
335
|
+
}),
|
|
336
|
+
userId: id.optional().meta(requiredFor("member")),
|
|
337
|
+
title: zod.z.string().optional().meta(requiredFor("setTitle")),
|
|
338
|
+
description: zod.z.string().optional().meta(requiredFor("setDescription")),
|
|
339
|
+
queryId: zod.z.string().optional().meta(requiredFor("answerQuery", "answerInlineQuery")),
|
|
320
340
|
results: zod.z.string().optional().meta({
|
|
321
|
-
...
|
|
341
|
+
...requiredFor("answerInlineQuery"),
|
|
322
342
|
description: "A JSON array of results for the inline query"
|
|
323
343
|
}),
|
|
324
|
-
fileId: zod.z.string().optional().meta({
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
344
|
+
fileId: zod.z.string().optional().meta({
|
|
345
|
+
showWhen: {
|
|
346
|
+
resource: ["file"],
|
|
347
|
+
operation: ["get"]
|
|
348
|
+
},
|
|
349
|
+
requiredWhenShown: true
|
|
350
|
+
}),
|
|
328
351
|
download: zod.z.boolean().default(false).meta({
|
|
329
352
|
showWhen: {
|
|
330
353
|
resource: ["file"],
|
|
@@ -341,7 +364,7 @@ const telegramConfig = zod.z.object({
|
|
|
341
364
|
description: "The property of `binary` in the input that holds the file"
|
|
342
365
|
}),
|
|
343
366
|
message: zod.z.string().optional().meta({
|
|
344
|
-
...
|
|
367
|
+
...requiredFor("sendAndWait"),
|
|
345
368
|
description: "The message to send, with the buttons"
|
|
346
369
|
}),
|
|
347
370
|
responseType: zod.z.enum([
|
|
@@ -391,15 +414,16 @@ const telegramConfig = zod.z.object({
|
|
|
391
414
|
description: "limitWaitTimeHours: how long to wait for an answer. Default 168 (7 days)."
|
|
392
415
|
}),
|
|
393
416
|
text: zod.z.string().optional().meta({
|
|
394
|
-
...
|
|
417
|
+
...requiredFor("sendMessage", "editMessageText"),
|
|
395
418
|
ui: "textarea"
|
|
396
419
|
}),
|
|
397
420
|
file: zod.z.string().optional().meta({
|
|
398
|
-
...
|
|
421
|
+
...requiredFor(...SEND_FILE),
|
|
422
|
+
hideWhen: { binaryData: [true] },
|
|
399
423
|
description: "A public URL, or the file_id of a file that Telegram has"
|
|
400
424
|
}),
|
|
401
425
|
action: zod.z.enum(CHAT_ACTIONS).optional().meta({
|
|
402
|
-
...
|
|
426
|
+
...requiredFor("sendChatAction"),
|
|
403
427
|
labels: {
|
|
404
428
|
typing: "Typing a Message",
|
|
405
429
|
find_location: "Selecting a Location",
|
|
@@ -425,9 +449,9 @@ const telegramConfig = zod.z.object({
|
|
|
425
449
|
upload_video_note: "Show that the bot sends a round video"
|
|
426
450
|
}
|
|
427
451
|
}),
|
|
428
|
-
latitude: zod.z.number().optional().meta(
|
|
429
|
-
longitude: zod.z.number().optional().meta(
|
|
430
|
-
media: zod.z.object({ media: zod.z.array(mediaItem) }).optional().meta(
|
|
452
|
+
latitude: zod.z.number().optional().meta(requiredFor("sendLocation")),
|
|
453
|
+
longitude: zod.z.number().optional().meta(requiredFor("sendLocation")),
|
|
454
|
+
media: zod.z.object({ media: zod.z.array(mediaItem) }).optional().meta(requiredFor("sendMediaGroup")),
|
|
431
455
|
replyMarkup: zod.z.enum([
|
|
432
456
|
"none",
|
|
433
457
|
"inlineKeyboard",
|
|
@@ -904,7 +928,7 @@ var node_default = (0, _zerodot_node_sdk.defineNode)({
|
|
|
904
928
|
}
|
|
905
929
|
}
|
|
906
930
|
],
|
|
907
|
-
icon: "
|
|
931
|
+
icon: "SentIcon",
|
|
908
932
|
iconUrl: TELEGRAM_ICON,
|
|
909
933
|
config: telegramConfig,
|
|
910
934
|
defaultConfig: {
|
|
@@ -1112,7 +1136,7 @@ const nodes = [(0, _zerodot_node_sdk.defineNode)({
|
|
|
1112
1136
|
description: "Start the workflow on a Telegram bot update",
|
|
1113
1137
|
category: "trigger",
|
|
1114
1138
|
app: "Telegram",
|
|
1115
|
-
icon: "
|
|
1139
|
+
icon: "SentIcon",
|
|
1116
1140
|
iconUrl: TELEGRAM_ICON,
|
|
1117
1141
|
config: triggerConfig,
|
|
1118
1142
|
defaultConfig: {
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerodot/telegram",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Send messages and files with a Telegram bot, and start a workflow when the bot gets a message or other update. Use it to build chat bots and notifications.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/zerodot-io/
|
|
8
|
+
"url": "git+https://github.com/zerodot-io/nodes.git",
|
|
9
9
|
"directory": "packages/telegram"
|
|
10
10
|
},
|
|
11
11
|
"keywords": [
|
|
12
|
-
"zerodot-node-package"
|
|
12
|
+
"zerodot-node-package",
|
|
13
|
+
"communication"
|
|
13
14
|
],
|
|
14
15
|
"type": "module",
|
|
15
16
|
"main": "./dist/index.cjs",
|
|
@@ -23,7 +24,10 @@
|
|
|
23
24
|
"zerodot": {
|
|
24
25
|
"sdk": "^1.2",
|
|
25
26
|
"label": "Telegram",
|
|
26
|
-
"summary": "Send messages and react to bot updates"
|
|
27
|
+
"summary": "Send messages and react to bot updates",
|
|
28
|
+
"categories": [
|
|
29
|
+
"communication"
|
|
30
|
+
]
|
|
27
31
|
},
|
|
28
32
|
"publishConfig": {
|
|
29
33
|
"access": "public"
|
|
@@ -35,7 +39,7 @@
|
|
|
35
39
|
},
|
|
36
40
|
"devDependencies": {
|
|
37
41
|
"@types/node": "26.6.5",
|
|
38
|
-
"@zerodot/node-sdk": "^1.2.
|
|
42
|
+
"@zerodot/node-sdk": "^1.2.1",
|
|
39
43
|
"tsdown": "0.23.2",
|
|
40
44
|
"tsx": "4.23.15",
|
|
41
45
|
"typescript": "7.0.2",
|