diff --git a/packages/nodes-base/nodes/Telegram/Telegram.node.ts b/packages/nodes-base/nodes/Telegram/Telegram.node.ts index fb9b37d816..ef8973cb8b 100644 --- a/packages/nodes-base/nodes/Telegram/Telegram.node.ts +++ b/packages/nodes-base/nodes/Telegram/Telegram.node.ts @@ -244,9 +244,15 @@ export class Telegram implements INodeType { { name: 'Send Audio', value: 'sendAudio', - description: 'Send a audio file', + description: 'Send an audio file', action: 'Send an audio file', }, + { + name: 'Send Voice', + value: 'sendVoice', + description: 'Send a voice message', + action: 'Send a voice message', + }, { name: 'Send Chat Action', value: 'sendChatAction', @@ -301,6 +307,12 @@ export class Telegram implements INodeType { description: 'Send a video', action: 'Send a video', }, + { + name: 'Send Video Note', + value: 'sendVideoNote', + description: 'Send a video note', + action: 'Send a video note', + }, { name: 'Unpin Chat Message', value: 'unpinChatMessage', @@ -333,6 +345,7 @@ export class Telegram implements INodeType { 'setTitle', 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendChatAction', 'sendDocument', 'sendLocation', @@ -341,6 +354,7 @@ export class Telegram implements INodeType { 'sendPhoto', 'sendSticker', 'sendVideo', + 'sendVideoNote', 'unpinChatMessage', ], resource: ['chat', 'message'], @@ -706,7 +720,7 @@ export class Telegram implements INodeType { 'Unique identifier for the target chat or username, To find your chat ID ask @get_id_bot', }, // ---------------------------------- - // message:sendAnimation/sendAudio/sendDocument/sendPhoto/sendSticker/sendVideo + // message:sendAnimation/sendAudio/sendVoice/sendDocument/sendPhoto/sendSticker/sendVideo/sendVideoNote // ---------------------------------- { @@ -720,9 +734,11 @@ export class Telegram implements INodeType { operation: [ 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendDocument', 'sendPhoto', 'sendVideo', + 'sendVideoNote', 'sendSticker', ], resource: ['message'], @@ -742,9 +758,11 @@ export class Telegram implements INodeType { operation: [ 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendDocument', 'sendPhoto', 'sendVideo', + 'sendVideoNote', 'sendSticker', ], resource: ['message'], @@ -845,6 +863,24 @@ export class Telegram implements INodeType { description: 'Audio file to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a file from the Internet.', }, + // ---------------------------------- + // message:sendVoice + // ---------------------------------- + { + displayName: 'Voice', + name: 'file', + type: 'string', + default: '', + displayOptions: { + show: { + operation: ['sendVoice'], + resource: ['message'], + binaryData: [false], + }, + }, + description: + 'Voice message to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a file from the Internet.', + }, // ---------------------------------- // message:sendChatAction @@ -870,6 +906,11 @@ export class Telegram implements INodeType { value: 'record_audio', action: 'Record audio', }, + { + name: 'Record Voice', + value: 'record_voice', + action: 'Record voice', + }, { name: 'Record Video', value: 'record_video', @@ -1141,11 +1182,27 @@ export class Telegram implements INodeType { description: 'Video file to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a file from the Internet.', }, - // ---------------------------------- - // message:editMessageText/sendAnimation/sendAudio/sendLocation/sendMessage/sendPhoto/sendSticker/sendVideo + // message:sendVideoNote + // ---------------------------------- + { + displayName: 'VideoNote', + name: 'file', + type: 'string', + default: '', + displayOptions: { + show: { + operation: ['sendVideoNote'], + resource: ['message'], + binaryData: [false], + }, + }, + description: + 'VideoNote file to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a file from the Internet.', + }, + // ---------------------------------- + // message:editMessageText/sendAnimation/sendAudio/sendLocation/sendMessage/sendPhoto/sendSticker/sendVideo/SendVideoNote // ---------------------------------- - { displayName: 'Reply Markup', name: 'replyMarkup', @@ -1158,7 +1215,9 @@ export class Telegram implements INodeType { 'sendPhoto', 'sendSticker', 'sendVideo', + 'sendVideoNote', 'sendAudio', + 'sendVoice', 'sendLocation', ], resource: ['message'], @@ -1190,7 +1249,6 @@ export class Telegram implements INodeType { default: 'none', description: 'Additional interface options', }, - { displayName: 'Force Reply', name: 'forceReply', @@ -1221,7 +1279,6 @@ export class Telegram implements INodeType { }, ], }, - { displayName: 'Inline Keyboard', name: 'inlineKeyboard', @@ -1515,6 +1572,7 @@ export class Telegram implements INodeType { 'editMessageText', 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendDocument', 'sendLocation', 'sendMessage', @@ -1522,6 +1580,7 @@ export class Telegram implements INodeType { 'sendPhoto', 'sendSticker', 'sendVideo', + 'sendVideoNote', ], resource: ['message'], }, @@ -1547,9 +1606,11 @@ export class Telegram implements INodeType { '/operation': [ 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendDocument', 'sendPhoto', 'sendVideo', + 'sendVideoNote', ], }, }, @@ -1590,7 +1651,7 @@ export class Telegram implements INodeType { }, displayOptions: { show: { - '/operation': ['sendAnimation', 'sendAudio', 'sendVideo'], + '/operation': ['sendAnimation', 'sendAudio', 'sendVoice', 'sendVideo'], }, }, default: 0, @@ -1606,9 +1667,11 @@ export class Telegram implements INodeType { '/operation': [ 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendDocument', 'sendPhoto', 'sendVideo', + 'sendVideoNote', 'sendSticker', ], '/resource': ['message'], @@ -1656,9 +1719,11 @@ export class Telegram implements INodeType { 'editMessageText', 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendMessage', 'sendPhoto', 'sendVideo', + 'sendVideoNote', 'sendDocument', ], }, @@ -1699,6 +1764,7 @@ export class Telegram implements INodeType { '/operation': [ 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendChatAction', 'sendDocument', 'sendLocation', @@ -1707,6 +1773,7 @@ export class Telegram implements INodeType { 'sendPhoto', 'sendSticker', 'sendVideo', + 'sendVideoNote', ], }, }, @@ -1731,7 +1798,13 @@ export class Telegram implements INodeType { type: 'string', displayOptions: { show: { - '/operation': ['sendAnimation', 'sendAudio', 'sendDocument', 'sendVideo'], + '/operation': [ + 'sendAnimation', + 'sendAudio', + 'sendDocument', + 'sendVideo', + 'sendVideoNote', + ], }, }, default: '', @@ -1987,6 +2060,18 @@ export class Telegram implements INodeType { body.chat_id = this.getNodeParameter('chatId', i) as string; body.audio = this.getNodeParameter('file', i, '') as string; + // Add additional fields and replyMarkup + addAdditionalFields.call(this, body, i); + } else if (operation === 'sendVoice') { + // ---------------------------------- + // message:sendVoice + // ---------------------------------- + + endpoint = 'sendVoice'; + + body.chat_id = this.getNodeParameter('chatId', i) as string; + body.audio = this.getNodeParameter('file', i, '') as string; + // Add additional fields and replyMarkup addAdditionalFields.call(this, body, i); } else if (operation === 'sendChatAction') { @@ -2090,6 +2175,18 @@ export class Telegram implements INodeType { body.chat_id = this.getNodeParameter('chatId', i) as string; body.video = this.getNodeParameter('file', i, '') as string; + // Add additional fields and replyMarkup + addAdditionalFields.call(this, body, i); + } else if (operation === 'sendVideoNote') { + // ---------------------------------- + // message:sendVideoNote + // ---------------------------------- + + endpoint = 'sendVideoNote'; + + body.chat_id = this.getNodeParameter('chatId', i) as string; + body.video = this.getNodeParameter('file', i, '') as string; + // Add additional fields and replyMarkup addAdditionalFields.call(this, body, i); } diff --git a/packages/nodes-base/nodes/Telegram/__schema__/v1.2.0/message/sendVideoNote.json b/packages/nodes-base/nodes/Telegram/__schema__/v1.2.0/message/sendVideoNote.json new file mode 100644 index 0000000000..3bf2683bd1 --- /dev/null +++ b/packages/nodes-base/nodes/Telegram/__schema__/v1.2.0/message/sendVideoNote.json @@ -0,0 +1,140 @@ +{ + "type": "object", + "properties": { + "ok": { + "type": "boolean" + }, + "result": { + "type": "object", + "properties": { + "message_id": { + "type": "integer" + }, + "from": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "is_bot": { + "type": "boolean" + }, + "first_name": { + "type": "string" + }, + "username": { + "type": "string" + } + }, + "required": ["id", "is_bot", "first_name", "username"] + }, + "chat": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "type": { + "type": "string" + }, + "first_name": { + "type": "string" + }, + "username": { + "type": "string" + } + }, + "required": ["id", "type"] + }, + "date": { + "type": "integer" + }, + "caption": { + "type": "string" + }, + "video_note": { + "type": "object", + "properties": { + "duration": { + "type": "integer" + }, + "width": { + "type": "integer" + }, + "height": { + "type": "integer" + }, + "file_name": { + "type": "string" + }, + "mime_type": { + "type": "string" + }, + "thumbnail": { + "type": "object", + "properties": { + "file_id": { + "type": "string" + }, + "file_unique_id": { + "type": "string" + }, + "file_size": { + "type": "integer" + }, + "width": { + "type": "integer" + }, + "height": { + "type": "integer" + } + }, + "required": ["file_id", "file_unique_id", "file_size", "width", "height"] + }, + "thumb": { + "type": "object", + "properties": { + "file_id": { + "type": "string" + }, + "file_unique_id": { + "type": "string" + }, + "file_size": { + "type": "integer" + }, + "width": { + "type": "integer" + }, + "height": { + "type": "integer" + } + }, + "required": ["file_id", "file_unique_id", "file_size", "width", "height"] + }, + "file_id": { + "type": "string" + }, + "file_unique_id": { + "type": "string" + }, + "file_size": { + "type": "integer" + } + }, + "required": [ + "duration", + "width", + "height", + "mime_type", + "file_id", + "file_unique_id", + "file_size" + ] + } + }, + "required": ["message_id", "chat", "date"] + } + }, + "required": ["ok", "result"] +} diff --git a/packages/nodes-base/nodes/Telegram/__schema__/v1.2.0/message/sendVoice.json b/packages/nodes-base/nodes/Telegram/__schema__/v1.2.0/message/sendVoice.json new file mode 100644 index 0000000000..6942ca47ee --- /dev/null +++ b/packages/nodes-base/nodes/Telegram/__schema__/v1.2.0/message/sendVoice.json @@ -0,0 +1,104 @@ +{ + "type": "object", + "properties": { + "ok": { + "type": "boolean" + }, + "result": { + "type": "object", + "properties": { + "message_id": { + "type": "integer" + }, + "from": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "is_bot": { + "type": "boolean" + }, + "first_name": { + "type": "string" + }, + "username": { + "type": "string" + } + }, + "required": [ + "id", + "is_bot", + "first_name", + "username" + ] + }, + "chat": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "first_name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "last_name": { + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + "date": { + "type": "integer" + }, + "voice": { + "type": "object", + "properties": { + "duration": { + "type": "integer" + }, + "file_name": { + "type": "string" + }, + "mime_type": { + "type": "string" + }, + "file_id": { + "type": "string" + }, + "file_unique_id": { + "type": "string" + }, + "file_size": { + "type": "integer" + } + }, + "required": [ + "duration", + "file_name", + "mime_type", + "file_id", + "file_unique_id", + "file_size" + ] + } + }, + "required": [ + "message_id", + "from", + "chat", + "date" + ] + } + }, + "required": [ + "ok", + "result" + ] +} diff --git a/packages/nodes-base/nodes/Telegram/tests/Workflow/apiResponses.ts b/packages/nodes-base/nodes/Telegram/tests/Workflow/apiResponses.ts index d0befde80c..c68c24d0a4 100644 --- a/packages/nodes-base/nodes/Telegram/tests/Workflow/apiResponses.ts +++ b/packages/nodes-base/nodes/Telegram/tests/Workflow/apiResponses.ts @@ -381,6 +381,34 @@ export const sendAudioResponse = { }, }, }; +export const sendVoiceResponse = { + ok: true, + result: { + message_id: 47, + from: { + id: 9876543210, + is_bot: true, + first_name: '@n8n', + username: 'n8n_test_bot', + }, + chat: { + id: 123456789, + first_name: 'Nathan', + last_name: 'W', + username: 'n8n', + type: 'private', + }, + date: 1732969291, + audio: { + duration: 3, + file_name: 'sample-3s.mp3', + mime_type: 'audio/mpeg', + file_id: 'CQACAgQAAxkDAAMuZ0sDSxCh3hW89NQa-eTpxKioqGAAAjsEAAIBCU1SGtsPA4N9TSo2BA', + file_unique_id: 'AgADOwQAAgEJTVI', + file_size: 52079, + }, + }, +}; export const getMemberResponse = { ok: true, diff --git a/packages/nodes-base/nodes/Telegram/tests/Workflow/workflow.test.ts b/packages/nodes-base/nodes/Telegram/tests/Workflow/workflow.test.ts index c752eba158..1ffa109024 100644 --- a/packages/nodes-base/nodes/Telegram/tests/Workflow/workflow.test.ts +++ b/packages/nodes-base/nodes/Telegram/tests/Workflow/workflow.test.ts @@ -11,6 +11,7 @@ import { chatAdministratorsResponse, sendAnimationMessageResponse, sendAudioResponse, + sendVoiceResponse, getMemberResponse, } from './apiResponses'; import { FAKE_CREDENTIALS_DATA } from '../../../../test/nodes/FakeCredentialsMap'; @@ -38,6 +39,7 @@ describe('Telegram', () => { mock.post('/bottestToken/getChatAdministrators').reply(200, chatAdministratorsResponse); mock.post('/bottestToken/sendAnimation').reply(200, sendAnimationMessageResponse); mock.post('/bottestToken/sendAudio').reply(200, sendAudioResponse); + mock.post('/bottestToken/sendVoice').reply(200, sendVoiceResponse); mock.post('/bottestToken/getChatMember').reply(200, getMemberResponse); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a341dbc522..6adab48798 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7014,6 +7014,7 @@ packages: bson@6.10.0: resolution: {integrity: sha512-ROchNosXMJD2cbQGm84KoP7vOGPO6/bOAW0veMMbzhXLqoZptcaYRVLitwvuhwhjjpU1qP4YZRWLhgETdgqUQw==} engines: {node: '>=16.20.1'} + deprecated: a critical bug affecting only useBigInt64=true deserialization usage is fixed in bson@6.10.3 buffer-crc32@0.2.13: resolution: {integrity: sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==} @@ -7847,10 +7848,6 @@ packages: resolution: {integrity: sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==} engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16} - detect-libc@2.0.1: - resolution: {integrity: sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w==} - engines: {node: '>=8'} - detect-libc@2.0.3: resolution: {integrity: sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==} engines: {node: '>=8'} @@ -8861,6 +8858,7 @@ packages: gm@1.25.0: resolution: {integrity: sha512-4kKdWXTtgQ4biIo7hZA396HT062nDVVHPjQcurNZ3o/voYN+o5FUC5kOwuORbpExp3XbTJ3SU7iRipiIhQtovw==} engines: {node: '>=14'} + deprecated: The gm module has been sunset. Please migrate to an alternative. https://github.com/aheckmann/gm?tab=readme-ov-file#2025-02-24-this-project-is-not-maintained google-auth-library@8.9.0: resolution: {integrity: sha512-f7aQCJODJFmYWN6PeNKzgvy9LI2tYmXnzpNDHEjG5sDNPgGb2FXQyTBnXeSH+PAtpKESFD+LmHw3Ox3mN7e1Fg==} @@ -8883,9 +8881,6 @@ packages: gopd@1.0.1: resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} - graceful-fs@4.2.10: - resolution: {integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==} - graceful-fs@4.2.11: resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} @@ -20955,8 +20950,6 @@ snapshots: destroy@1.2.0: {} - detect-libc@2.0.1: {} - detect-libc@2.0.3: {} detect-newline@3.1.0: {} @@ -22351,9 +22344,6 @@ snapshots: dependencies: get-intrinsic: 1.2.4 - graceful-fs@4.2.10: - optional: true - graceful-fs@4.2.11: {} graphemer@1.4.0: {} @@ -24696,7 +24686,7 @@ snapshots: dependencies: env-paths: 2.2.1 glob: 7.2.3 - graceful-fs: 4.2.10 + graceful-fs: 4.2.11 make-fetch-happen: 9.1.0 nopt: 5.0.0 npmlog: 6.0.2 @@ -25373,7 +25363,7 @@ snapshots: prebuild-install@7.1.1: dependencies: - detect-libc: 2.0.1 + detect-libc: 2.0.3 expand-template: 2.0.3 github-from-package: 0.0.0 minimist: 1.2.8