mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(Telegram Node): New operation sendAndWait (#12771)
This commit is contained in:
@@ -10,6 +10,8 @@ import type {
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
import { getSendAndWaitConfig } from '../../utils/sendAndWait/utils';
|
||||
|
||||
// Interface in n8n
|
||||
export interface IMarkupKeyboard {
|
||||
rows?: IMarkupKeyboardRow[];
|
||||
@@ -252,3 +254,36 @@ export function getSecretToken(this: IHookFunctions | IWebhookFunctions) {
|
||||
const secret_token = `${this.getWorkflow().id}_${this.getNode().id}`;
|
||||
return secret_token.replace(/[^a-zA-Z0-9\_\-]+/g, '');
|
||||
}
|
||||
|
||||
export function createSendAndWaitMessageBody(context: IExecuteFunctions) {
|
||||
const chat_id = context.getNodeParameter('chatId', 0) as string;
|
||||
|
||||
const config = getSendAndWaitConfig(context);
|
||||
let text = config.message;
|
||||
|
||||
const instanceId = context.getInstanceId();
|
||||
const attributionText = 'This message was sent automatically with ';
|
||||
const link = `https://n8n.io/?utm_source=n8n-internal&utm_medium=powered_by&utm_campaign=${encodeURIComponent(
|
||||
'n8n-nodes-base.telegram',
|
||||
)}${instanceId ? '_' + instanceId : ''}`;
|
||||
text = `${text}\n\n_${attributionText}_[n8n](${link})`;
|
||||
|
||||
const body = {
|
||||
chat_id,
|
||||
text,
|
||||
disable_web_page_preview: true,
|
||||
parse_mode: 'Markdown',
|
||||
reply_markup: {
|
||||
inline_keyboard: [
|
||||
config.options.map((option) => {
|
||||
return {
|
||||
text: option.label,
|
||||
url: `${config.url}?approved=${option.value}`,
|
||||
};
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user