Skip to content
// Shape the reply the way each platform expects.
// Vapi: { results: [{ toolCallId, result }] }  ·  Retell / plain: the result object itself
const items = $input.all().map((i) => i.json);
if (items[0]?.platform === 'vapi') {
  return [{ json: { results: items.map((i) => ({ toolCallId: i.tool_call_id, result: JSON.stringify(i.result) })) } }];
}
return [{ json: items.length === 1 ? items[0].result : { results: items.map((i) => i.result) } }];