feat: complete telegram cms system with workflows and deployment guide
- Add ULTIMATE-Telegram-CMS-COMPLETE.json with all commands - Add Docker Event workflows with Gitea integration - Add comprehensive deployment guide for fresh installs - Add quick reference and testing checklist - Include all n8n workflow exports Commands: /start, /list, /search, /stats, /preview, /publish, /delete, .review Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
120
n8n-review-separate-calls.js
Normal file
120
n8n-review-separate-calls.js
Normal file
@@ -0,0 +1,120 @@
|
||||
var d = $input.first().json;
|
||||
|
||||
// GET book from CMS
|
||||
var book;
|
||||
try {
|
||||
var check = await this.helpers.httpRequest({
|
||||
method: "GET",
|
||||
url: "https://cms.dk0.dev/items/book_reviews",
|
||||
headers: { Authorization: "Bearer RF2QytqhcLXuVy6FO3PzWlsoR-ysCTwB" },
|
||||
qs: {
|
||||
"filter[hardcover_id][_eq]": d.hardcoverId,
|
||||
"fields": "id,book_title,book_author",
|
||||
"limit": 1
|
||||
}
|
||||
});
|
||||
book = check.data?.[0];
|
||||
} catch (e) {
|
||||
var errmsg = "❌ GET Fehler: " + e.message;
|
||||
return [{ json: { msg: errmsg, chatId: d.chatId } }];
|
||||
}
|
||||
|
||||
if (!book) {
|
||||
var errmsg = "❌ Buch mit Hardcover ID " + d.hardcoverId + " nicht gefunden.";
|
||||
return [{ json: { msg: errmsg, chatId: d.chatId } }];
|
||||
}
|
||||
|
||||
console.log("Book found:", book.book_title);
|
||||
|
||||
// Generate German review
|
||||
var promptDe = "Schreibe eine persönliche Buchrezension (4-6 Sätze, Ich-Perspektive, nur Deutsch) zu '" + book.book_title + "' von " + book.book_author + ". Rating: " + d.rating + "/5. Meine Gedanken: " + d.answers + ". Formuliere professionell aber authentisch. NUR der Review-Text, kein JSON, kein Titel, keine Anführungszeichen drumherum.";
|
||||
|
||||
var reviewDe;
|
||||
try {
|
||||
console.log("Generating German review...");
|
||||
var aiDe = await this.helpers.httpRequest({
|
||||
method: "POST",
|
||||
url: "https://openrouter.ai/api/v1/chat/completions",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: "Bearer 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"
|
||||
},
|
||||
body: {
|
||||
model: "google/gemini-2.5-flash",
|
||||
messages: [{ role: "user", content: promptDe }],
|
||||
temperature: 0.7
|
||||
}
|
||||
});
|
||||
reviewDe = aiDe.choices?.[0]?.message?.content?.trim() || d.answers;
|
||||
console.log("German review generated:", reviewDe.substring(0, 100) + "...");
|
||||
} catch (e) {
|
||||
console.log("German AI error:", e.message);
|
||||
reviewDe = d.answers;
|
||||
}
|
||||
|
||||
// Generate English review
|
||||
var promptEn = "You are a professional book critic writing in ENGLISH ONLY. Write a personal book review (4-6 sentences, first person perspective) of '" + book.book_title + "' by " + book.book_author + ". Rating: " + d.rating + "/5 stars. Reader notes: " + d.answers + ". Write professionally but authentically. OUTPUT ONLY THE REVIEW TEXT IN ENGLISH, no JSON, no title, no quotes.";
|
||||
|
||||
var reviewEn;
|
||||
try {
|
||||
console.log("Generating English review...");
|
||||
var aiEn = await this.helpers.httpRequest({
|
||||
method: "POST",
|
||||
url: "https://openrouter.ai/api/v1/chat/completions",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: "Bearer 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"
|
||||
},
|
||||
body: {
|
||||
model: "openrouter/free",
|
||||
messages: [
|
||||
{ role: "system", content: "You are a book critic. You ALWAYS write in English, never in German." },
|
||||
{ role: "user", content: promptEn }
|
||||
],
|
||||
temperature: 0.7
|
||||
}
|
||||
});
|
||||
reviewEn = aiEn.choices?.[0]?.message?.content?.trim() || d.answers;
|
||||
console.log("English review generated:", reviewEn.substring(0, 100) + "...");
|
||||
} catch (e) {
|
||||
console.log("English AI error:", e.message);
|
||||
reviewEn = d.answers;
|
||||
}
|
||||
|
||||
// PATCH book with reviews
|
||||
try {
|
||||
console.log("Patching book #" + book.id);
|
||||
await this.helpers.httpRequest({
|
||||
method: "PATCH",
|
||||
url: "https://cms.dk0.dev/items/book_reviews/" + book.id,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: "Bearer RF2QytqhcLXuVy6FO3PzWlsoR-ysCTwB"
|
||||
},
|
||||
body: {
|
||||
rating: d.rating,
|
||||
status: "draft",
|
||||
translations: {
|
||||
create: [
|
||||
{ languages_code: "en-US", review: reviewEn },
|
||||
{ languages_code: "de-DE", review: reviewDe }
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
console.log("PATCH success");
|
||||
} catch (e) {
|
||||
console.log("PATCH ERROR:", e.message);
|
||||
var errmsg = "❌ PATCH Fehler: " + e.message;
|
||||
return [{ json: { msg: errmsg, chatId: d.chatId } }];
|
||||
}
|
||||
|
||||
// Build Telegram message (no emojis for better encoding)
|
||||
var msg = "REVIEW: " + book.book_title + " - " + d.rating + "/5 Sterne";
|
||||
msg = msg + "\n\n--- DEUTSCH ---\n" + reviewDe;
|
||||
msg = msg + "\n\n--- ENGLISH ---\n" + reviewEn;
|
||||
msg = msg + "\n\n==================";
|
||||
msg = msg + "\n/publishbook" + book.id + " - Veroeffentlichen";
|
||||
msg = msg + "\n/deletereview" + book.id + " - Loeschen und nochmal";
|
||||
|
||||
return [{ json: { msg: msg, chatId: d.chatId } }];
|
||||
Reference in New Issue
Block a user