Files
alighasami 3d5eaf9445
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
first commit
2026-03-17 16:22:57 +03:30

46 lines
1.5 KiB
TypeScript

import type { INodeProperties, IExecuteFunctions } from 'n8n-workflow';
import {
getSendAndWaitConfig,
getSendAndWaitProperties,
} from '../../../../../../utils/sendAndWait/utils';
import { createUtmCampaignLink } from '../../../../../../utils/utilities';
import { chatRLC } from '../../descriptions';
import { microsoftApiRequest } from '../../transport';
export const description: INodeProperties[] = getSendAndWaitProperties(
[chatRLC],
'chatMessage',
undefined,
{
noButtonStyle: true,
defaultApproveLabel: '✓ Approve',
defaultDisapproveLabel: '✗ Decline',
},
).filter((p) => p.name !== 'subject');
export async function execute(this: IExecuteFunctions, i: number, instanceId: string) {
const chatId = this.getNodeParameter('chatId', i, '', { extractValue: true }) as string;
const config = getSendAndWaitConfig(this);
const buttons = config.options.map((option) => `<a href="${option.url}">${option.label}</a>`);
let content = `${config.message}<br><br>${buttons.join(' ')}`;
if (config.appendAttribution !== false) {
const attributionText = 'This message was sent automatically with';
const link = createUtmCampaignLink('n8n-nodes-base.microsoftTeams', instanceId);
const attribution = `<em>${attributionText} <a href="${link}">n8n</a></em>`;
content += `<br><br>${attribution}`;
}
const body = {
body: {
contentType: 'html',
content,
},
};
return await microsoftApiRequest.call(this, 'POST', `/v1.0/chats/${chatId}/messages`, body);
}