/** * Schedule an outbound call that the platform will retry on failure. * * The host runs a single `defineScript` handler — there is no separate runtime * entry per `entry_point` like logic-executor Python `run_unit(entry_point=...)`. * Recall legs are the same script again with an incremented `context.attempt`. * * Do not combine recall options with `onFailedCall` on the same `platform.call()`. * When `onFailedCall` is configured, CMS recall is not auto-applied to the call row. * See README § "Failed outbound: automatic recall vs after-call continuation". */ import { defineScript } from '@voctiv/agent-sdk'; const RECALL_COUNT = 3; /** Delay between failed attempts, in seconds (5 minutes). */ const RECALL_DELAY_SEC = 300; export default defineScript(async ({ channel, context, logger, platform }) => { channel.sip.answer(); const msisdn = context.msisdn || context.callerId; if (!msisdn) { logger.error('No msisdn on context'); return; } await channel.audio.say( 'We will call you back shortly. If we cannot reach you, we will retry a few times.', ); await platform.call(msisdn, { recallCount: RECALL_COUNT, recallDelay: RECALL_DELAY_SEC, }); logger.log('Outbound scheduled with recall', { msisdn, recallCount: RECALL_COUNT, recallDelaySec: RECALL_DELAY_SEC, }); return { output: { scheduled: true } }; });