Siclaire.fr

Contact

Contact Us

Procuring education on consulted assurance in do. Is sympathize he expression mr no travelling. Preference he he at travelling in resolution. So striking at of to welcomed resolved. Northward by described up household. 

Procuring education on consulted assurance in do. Is sympathize he expression mr no travelling. Preference he he at travelling in resolution. So striking at of to welcomed resolved. Northward by described up household therefore attention. Excellence decisively nay man yet impression for contrasted remarkably. 

US, Indiana

370 Santa Clara Dr.
Indiana, PA 15701

US, New York

87 NW. Military St.
Lindenhurst, NY 11757

const express = require('express'); const axios = require('axios'); const bodyParser = require('body-parser'); const app = express(); app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); // Tes identifiants API Aircall const AIRCALL_API_ID = "098dbad72a34e56440a3032291bb19aa"; const AIRCALL_API_TOKEN = "71f4f1a4f1f9e1e9f5e9c9f690d28ff7"; // Route qui reçoit le formulaire de rappel app.post('/callback_request', async (req, res) => { const { name, email, phone_number } = req.body; try { // Récupérer les agents disponibles const availableAgents = await getAvailableAgents(); if (!availableAgents.length) { return res.status(503).send("Aucun agent disponible actuellement, veuillez réessayer plus tard."); } // Sélectionner un agent disponible aléatoirement const agentSelected = availableAgents[Math.floor(Math.random() * availableAgents.length)]; // Lancer automatiquement l’appel sortant via Aircall await startOutboundCall(agentId = agentSelected.id, phoneNumber = phone_number); return res.status(200).send("Votre demande a été prise en compte, vous allez recevoir un appel rapidement."); } catch (error) { console.error(error); res.status(500).send("Erreur serveur lors de l'exécution du rappel automatique."); } }); // Fonction pour obtenir la disponibilité des agents Aircall async function getAvailableAgents() { const apiUrl = "https://api.aircall.io/v1/users/availabilities"; const response = await axios.get(apiUrl, { headers: { 'Authorization': 'Basic ' + Buffer.from(`${AIRCALL_API_ID}:${AIRCALL_API_TOKEN}`).toString('base64'), } }); return response.data.users.filter(agent => agent.availability === 'available'); } // Fonction pour déclencher l'appel automatique sortant via Aircall async function startOutboundCall(agentId, phoneNumber) { const apiUrl = `https://api.aircall.io/v1/users/${agentId}/calls`; const data = { number: phoneNumber }; const config = { headers: { 'Authorization': 'Basic ' + Buffer.from(`${AIRCALL_API_ID}:${AIRCALL_API_TOKEN}`).toString('base64'), 'Content-Type': 'application/json' } }; await axios.post(apiUrl, data, config); } // Lancer le serveur sur un port choisi (ex : 5000) const PORT = process.env.PORT || 5000; app.listen(PORT, () => { console.log(`Serveur actif sur : http://localhost:${PORT}`); });
..... ..... .....
..... ..... .....
...... ......