import { RelayClient } from '@signalwire/sdk';
const client = new RelayClient({
project: process.env.SIGNALWIRE_PROJECT_ID!,
token: process.env.SIGNALWIRE_API_TOKEN!,
contexts: ['default']
});
client.onCall(async (call) => {
await call.answer();
await call.play([{ type: 'tts', text: 'Please hold while I look that up.' }]);
// Put the call on hold
await call.hold();
// Do some processing...
await new Promise((resolve) => setTimeout(resolve, 5000));
const result = await call.unhold();
console.log(`Call resumed from hold: ${JSON.stringify(result)}`);
await call.play([{ type: 'tts', text: 'Thanks for holding. I have your answer.' }]);
});
await client.run();