From f1f6b36e7d9a117a12a0b672c5073ddd3f1a7191 Mon Sep 17 00:00:00 2001 From: Ria <123465523+riascho@users.noreply.github.com> Date: Wed, 5 Mar 2025 07:49:19 +0100 Subject: [PATCH 1/3] adds option to UI --- packages/nodes-base/nodes/Telegram/Telegram.node.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Telegram/Telegram.node.ts b/packages/nodes-base/nodes/Telegram/Telegram.node.ts index fb9b37d816..f2cdb59e99 100644 --- a/packages/nodes-base/nodes/Telegram/Telegram.node.ts +++ b/packages/nodes-base/nodes/Telegram/Telegram.node.ts @@ -1768,7 +1768,18 @@ export class Telegram implements INodeType { }, ], 'message', - undefined, + [ + { + ...appendAttributionOption, + description: + 'Whether to include the phrase "This message was sent automatically with n8n" to the end of the message', + displayOptions: { + show: { + '/operation': [SEND_AND_WAIT_OPERATION], + }, + }, + }, + ], { noButtonStyle: true, defaultApproveLabel: '✅ Approve', From 3d460a7b760251ab820e4f24110e09299003dcfb Mon Sep 17 00:00:00 2001 From: Ria <123465523+riascho@users.noreply.github.com> Date: Wed, 5 Mar 2025 14:09:58 +0100 Subject: [PATCH 2/3] makes the append n8n attribution option work --- .../nodes/Telegram/GenericFunctions.ts | 12 +++++--- .../nodes/Telegram/Telegram.node.ts | 19 ++++++++----- .../nodes-base/utils/sendAndWait/utils.ts | 28 ++++++++++++++++++- 3 files changed, 47 insertions(+), 12 deletions(-) diff --git a/packages/nodes-base/nodes/Telegram/GenericFunctions.ts b/packages/nodes-base/nodes/Telegram/GenericFunctions.ts index bbfeb6dbbd..a70935b70a 100644 --- a/packages/nodes-base/nodes/Telegram/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Telegram/GenericFunctions.ts @@ -80,6 +80,7 @@ export function addAdditionalFields( const additionalFields = this.getNodeParameter('additionalFields', index); if (operation === 'sendMessage') { + // [ria] && SEND_AND_WAIT ? const attributionText = 'This message was sent automatically with '; const link = createUtmCampaignLink('n8n-nodes-base.telegram', instanceId); @@ -260,14 +261,17 @@ export function createSendAndWaitMessageBody(context: IExecuteFunctions) { const config = getSendAndWaitConfig(context); let text = config.message; - const instanceId = context.getInstanceId(); - const attributionText = 'This message was sent automatically with '; - const link = createUtmCampaignLink('n8n-nodes-base.telegram', instanceId); - text = `${text}\n\n_${attributionText}_[n8n](${link})`; + if (config.appendAttribution) { + const instanceId = context.getInstanceId(); + const attributionText = 'This message was sent automatically with '; + const link = createUtmCampaignLink('n8n-nodes-base.telegram', instanceId); + text = `${text}\n\n_${attributionText}_[n8n](${link})`; + } const body = { chat_id, text, + disable_web_page_preview: true, parse_mode: 'Markdown', reply_markup: { diff --git a/packages/nodes-base/nodes/Telegram/Telegram.node.ts b/packages/nodes-base/nodes/Telegram/Telegram.node.ts index f2cdb59e99..e530b6cee1 100644 --- a/packages/nodes-base/nodes/Telegram/Telegram.node.ts +++ b/packages/nodes-base/nodes/Telegram/Telegram.node.ts @@ -1768,16 +1768,21 @@ export class Telegram implements INodeType { }, ], 'message', + // [ria] needs to be in options! [ { - ...appendAttributionOption, - description: - 'Whether to include the phrase "This message was sent automatically with n8n" to the end of the message', - displayOptions: { - show: { - '/operation': [SEND_AND_WAIT_OPERATION], + displayName: 'Options', + name: 'options', + type: 'collection', + placeholder: 'Add option', + default: {}, + options: [ + { + ...appendAttributionOption, + description: + 'Whether to include the phrase “This email was sent automatically with n8n” to the end of the email', }, - }, + ], }, ], { diff --git a/packages/nodes-base/utils/sendAndWait/utils.ts b/packages/nodes-base/utils/sendAndWait/utils.ts index 6fe569825f..387f2e9c8b 100644 --- a/packages/nodes-base/utils/sendAndWait/utils.ts +++ b/packages/nodes-base/utils/sendAndWait/utils.ts @@ -29,6 +29,7 @@ export type SendAndWaitConfig = { message: string; url: string; options: Array<{ label: string; value: string; style: string }>; + appendAttribution?: boolean; }; type FormResponseTypeOptions = { @@ -231,7 +232,17 @@ export function getSendAndWaitProperties( type: 'collection', placeholder: 'Add option', default: {}, - options: [limitWaitTimeOption], + options: [ + limitWaitTimeOption, + { + displayName: 'Append n8n Attribution', + name: 'appendAttribution', + type: 'boolean', + default: true, + description: + 'Whether to include the phrase "This message was sent automatically with n8n" to the end of the message', + }, + ], displayOptions: { show: { responseType: ['approval'], @@ -272,6 +283,14 @@ export function getSendAndWaitProperties( default: 'Submit', }, limitWaitTimeOption, + { + displayName: 'Append n8n Attribution', + name: 'appendAttribution', + type: 'boolean', + default: true, + description: + 'Whether to include the phrase "This message was sent automatically with n8n" to the end of the message', + }, ], displayOptions: { show: { @@ -448,11 +467,18 @@ export function getSendAndWaitConfig(context: IExecuteFunctions): SendAndWaitCon buttonDisapprovalStyle?: string; }; + const appendAttribution = context.getNodeParameter( + 'options.appendAttribution', + 0, + true, + ) as boolean; + const config: SendAndWaitConfig = { title: subject, message, url: `${resumeUrl}/${nodeId}`, options: [], + appendAttribution, }; const responseType = context.getNodeParameter('responseType', 0, 'approval') as string; From 439fb29fa6c8bb70475f2326b5a5719383d80be2 Mon Sep 17 00:00:00 2001 From: Ria <123465523+riascho@users.noreply.github.com> Date: Wed, 5 Mar 2025 15:01:42 +0100 Subject: [PATCH 3/3] reverts unnecessary changes --- .../nodes-base/nodes/Telegram/Telegram.node.ts | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/packages/nodes-base/nodes/Telegram/Telegram.node.ts b/packages/nodes-base/nodes/Telegram/Telegram.node.ts index e530b6cee1..fb9b37d816 100644 --- a/packages/nodes-base/nodes/Telegram/Telegram.node.ts +++ b/packages/nodes-base/nodes/Telegram/Telegram.node.ts @@ -1768,23 +1768,7 @@ export class Telegram implements INodeType { }, ], 'message', - // [ria] needs to be in options! - [ - { - displayName: 'Options', - name: 'options', - type: 'collection', - placeholder: 'Add option', - default: {}, - options: [ - { - ...appendAttributionOption, - description: - 'Whether to include the phrase “This email was sent automatically with n8n” to the end of the email', - }, - ], - }, - ], + undefined, { noButtonStyle: true, defaultApproveLabel: '✅ Approve',