n8n auto-hébergé | automatisation sécurisée et évolutive
100 formations en marketing digital et Intelligence Artificielle

Telegram – a new era of messaging
Telegram credentials | n8n Docs
// Parse Telegram message
const messageText = $input.item.json.message.text;
const lines = messageText.split('\n');
// Extract first line as yt_url and second line as user_desc
const yt_url = lines[0] || '';
const user_desc = lines[1] || '';
// Return the parsed data
return {
json: {
yt_url: yt_url.trim(),
user_desc: user_desc.trim()
}
};
// Extract video ID from YouTube URL
const url = $input.item.json.Url;
let videoId = null;
if (url) {
// youtu.be format
const youtuBeMatch = url.match(/youtu\.be\/([^?&]+)/);
if (youtuBeMatch) {
videoId = youtuBeMatch[1];
} else {
// youtube.com/watch?v=
const youtubeMatch = url.match(/[?&]v=([^?&]+)/);
if (youtubeMatch) {
videoId = youtubeMatch[1];
}
}
}
return {
json: {
videoId
}
};