diff --git a/packages/nodes-base/nodes/Telegram/Telegram.node.ts b/packages/nodes-base/nodes/Telegram/Telegram.node.ts index fb9b37d816..962762be10 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', @@ -333,6 +339,7 @@ export class Telegram implements INodeType { 'setTitle', 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendChatAction', 'sendDocument', 'sendLocation', @@ -706,7 +713,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 // ---------------------------------- { @@ -720,6 +727,7 @@ export class Telegram implements INodeType { operation: [ 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendDocument', 'sendPhoto', 'sendVideo', @@ -742,6 +750,7 @@ export class Telegram implements INodeType { operation: [ 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendDocument', 'sendPhoto', 'sendVideo', @@ -845,6 +854,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 +897,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', @@ -1159,6 +1191,7 @@ export class Telegram implements INodeType { 'sendSticker', 'sendVideo', 'sendAudio', + 'sendVoice', 'sendLocation', ], resource: ['message'], @@ -1515,6 +1548,7 @@ export class Telegram implements INodeType { 'editMessageText', 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendDocument', 'sendLocation', 'sendMessage', @@ -1547,6 +1581,7 @@ export class Telegram implements INodeType { '/operation': [ 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendDocument', 'sendPhoto', 'sendVideo', @@ -1590,7 +1625,7 @@ export class Telegram implements INodeType { }, displayOptions: { show: { - '/operation': ['sendAnimation', 'sendAudio', 'sendVideo'], + '/operation': ['sendAnimation', 'sendAudio', 'sendVoice', 'sendVideo'], }, }, default: 0, @@ -1606,6 +1641,7 @@ export class Telegram implements INodeType { '/operation': [ 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendDocument', 'sendPhoto', 'sendVideo', @@ -1656,6 +1692,7 @@ export class Telegram implements INodeType { 'editMessageText', 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendMessage', 'sendPhoto', 'sendVideo', @@ -1699,6 +1736,7 @@ export class Telegram implements INodeType { '/operation': [ 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendChatAction', 'sendDocument', 'sendLocation', @@ -1989,6 +2027,18 @@ export class Telegram implements INodeType { // 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') { // ---------------------------------- // message:sendChatAction 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); });