Untitled
unknown
javascript
a year ago
1.2 kB
4
Indexable
static async outbondCallTwillioRetell(req, res) { const accountSid = 'YOUR_ACCOUNT_SID'; const authToken = 'YOUR_AUTH_TOKEN'; const twilioClient = twilio(accountSid, authToken); try { await twilioClient.calls.create({ machineDetection: "Enable", // mendeteksi jika pihak lain adalah IVR machineDetectionTimeout: 8, asyncAmd: "true", // memanggil webhook ketika status deteksi diketahui asyncAmdStatusCallback: `${process.env.NGROK_IP_ADDRESS}/twilio-voice-webhook/${agentId}`, // URL webhook untuk deteksi mesin url: `${process.env.NGROK_IP_ADDRESS}/twilio-voice-webhook/${agentId}`, // URL webhook untuk mendaftarkan panggilan to: toNumber, from: fromNumber, }); console.log(`Panggilan dari: ${fromNumber} ke: ${toNumber}`); // Kirimkan respons sukses jika fungsi dipanggil dari rute Express.js if (res) { res.status(200).json({ message: 'Panggilan berhasil dibuat.' }); } } catch (error) { console.error('Fail to make call:', error); res.json(400).json({ message: 'Error Found', data: error.message }) } }
Editor is loading...
Leave a Comment