Skip to content
// Pair each AI draft with its deal (same order as Find Stale Deals → Use AI?).
const deals = $('Find Stale Deals').all();
return $input.all().map((item, i) => ({
  json: {
    ...deals[i].json,
    draft_subject: item.json.output?.subject ?? `Following up: ${deals[i].json.name}`,
    draft_body: item.json.output?.body ?? '',
    draft_source: 'ai',
  },
}));