Membership Matters · Participation Matters
Facebook X Gmail YouTube LinkedIn
Eco-friendly Light Bulbs

Welcome to the Illinois Recycling Foundation

Promoting Recycling and Sustainability Across Illinois

Latest News

News Image 1

Call for Presentation Abstracts

ILCSWMA, IRF, and SWANA request proposals for the 2025 Joint Conference & Trade Show.

Read More
Legislative Update

Legislative Update

The Illinois Recycling Association unveiled sweeping legislative proposals at a public forum, aiming to modernize recycling, waste management, and environmental protections.

Read More
News Image 3

Upcoming Webinar Explores Illinois Large Event Facilities Act

The Illinois Recycling Foundation, in partnership with the Illinois Food Scrap & Composting Coalition and Chicago Sustainability Task Force, has announced a free webinar scheduled for April 10 from 1:30 to 3:00 PM. The session will focus on the recently implemented Illinois Large Event Facilities Act.

Read More

Thank You to Our 2025 Benefactors

// Add these endpoints to your existing Express server const express = require('express'); const bodyParser = require('body-parser'); const twilio = require('twilio'); // Replace with your Twilio credentials const accountSid = process.env.TWILIO_ACCOUNT_SID; const authToken = process.env.TWILIO_AUTH_TOKEN; const twilioPhoneNumber = process.env.TWILIO_PHONE_NUMBER; const client = twilio(accountSid, authToken); // In-memory storage for conversations (replace with database in production) const conversations = []; // Middleware for parsing JSON app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); // Serve static files (including admin.html) app.use(express.static('public')); // Endpoint to receive SMS from Twilio app.post('/sms', (req, res) => { const twiml = new twilio.twiml.MessagingResponse(); const incomingMessage = req.body.Body; const from = req.body.From; console.log(`Received message from ${from}: ${incomingMessage}`); // Store the incoming message in our conversations saveMessage(from, incomingMessage, 'inbound'); // Your chatbot logic here const replyMessage = "Thanks for your message! We'll get back to you soon."; // Send the reply via TwiML twiml.message(replyMessage); // Store the outbound message in our conversations saveMessage(from, replyMessage, 'outbound'); res.writeHead(200, {'Content-Type': 'text/xml'}); res.end(twiml.toString()); }); // API endpoint to get all conversations app.get('/api/sms/conversations', (req, res) => { res.json({ conversations }); }); // API endpoint to send a reply app.post('/api/sms/reply', async (req, res) => { try { const { conversationId, message } = req.body; if (!conversationId || !message) { return res.status(400).json({ success: false, error: 'Conversation ID and message are required' }); } // Find the conversation const conversation = conversations.find(c => c.conversation_id === conversationId); if (!conversation) { return res.status(404).json({ success: false, error: 'Conversation not found' }); } // Send SMS via Twilio API await client.messages.create({ body: message, from: twilioPhoneNumber, to: conversation.phone_number }); // Update the conversation with the outbound message saveMessage(conversation.phone_number, message, 'outbound'); res.json({ success: true }); } catch (error) { console.error('Error sending reply:', error); res.status(500).json({ success: false, error: error.message }); } }); // Helper function to save messages to conversations function saveMessage(phoneNumber, message, direction) { const timestamp = new Date(); // Find existing conversation or create new one let conversation = conversations.find(c => c.phone_number === phoneNumber); if (!conversation) { conversation = { conversation_id: generateId(), phone_number: phoneNumber, contact_name: null, // You can add contact name lookup logic here messages: [], latest_message: message, latest_message_direction: direction, latest_message_time: timestamp }; conversations.push(conversation); } else { conversation.latest_message = message; conversation.latest_message_direction = direction; conversation.latest_message_time = timestamp; } // Add message to the conversation conversation.messages.push({ message, direction, timestamp }); } // Helper function to generate simple IDs function generateId() { return Math.random().toString(36).substring(2, 15); } // Add this route to serve the admin page app.get('/admin', (req, res) => { res.sendFile(__dirname + '/public/admin.html'); });