AI Content Repurposer
Module 10 · ai · intermediate
Solutions 10 · AI Content Repurposer
Exercise 1
Insert before ARTICLE: in the prompt:
{{ $('Repurpose API').item.json.body.voice_samples
? 'VOICE SAMPLES (match this tone, sentence length and formatting; do not reuse their content):\n' + [].concat($('Repurpose API').item.json.body.voice_samples).join('\n---\n') + '\n'
: '' }}
[].concat(...) accepts either a single string or an array.
Exercise 2
After Write Content, add a Code node (Run Once for All Items):
const out = $input.first().json.output;
const start = DateTime.now().plus({ days: 1 }).startOf('day');
const rows = [];
out.shorts.forEach((s, i) => rows.push({ channel: 'short', angle: s.angle, hook: s.hook, text: s.script, day: i * 2 }));
rows.push({ channel: 'linkedin', angle: '', hook: out.linkedin_post.split('\n')[0], text: out.linkedin_post, day: 1 });
rows.push({ channel: 'x', angle: '', hook: out.x_thread[0], text: out.x_thread.join('\n\n'), day: 3 });
rows.push({ channel: 'newsletter', angle: '', hook: out.newsletter.subject, text: out.newsletter.blurb, day: 5 });
return rows.map(r => ({ json: { date: start.plus({ days: r.day }).toISODate(), channel: r.channel, angle: r.angle, hook: r.hook, text: r.text, status: 'draft' } }));
→ Google Sheets Append Row to a Content sheet. Keep the Respond node on a separate branch from Write Content so the API still returns the JSON.
Exercise 3
- On
Content Format, enable Auto-Fix Format and connect the same OpenAI model to its Model input. This fixes malformed JSON. - For rule violations, after
Write Contentadd IFValid?:{{ $json.output.shorts.length === 3 && $json.output.x_thread.every(p => p.length <= 280) && $json.output.x_thread.length >= 4 }}is true.- true → Respond
- false → Edit Fields
Add Fix Note(source_text= original text,fix_note= "Your previous answer broke the rules: … Fix them.",attempt={{ ($json.attempt ?? 0) + 1 }}) → back intoWrite Content, with{{ $json.fix_note ?? '' }}appended to the prompt.
- Guard the loop: in
Valid?also treatattempt >= 1as "respond anyway", so it retries at most once.