AI-Powered Automated Email Responder Automated Email Responder Craft the perfect email reply in seconds. Just provide the context and let AI do the rest. Email Context Paste the original email here: Desired Tone for Reply: Professional & Formal Friendly & Casual Grateful & Appreciative Assertive & Direct Apologetic & Understanding Key points to include in your reply: Generate Email Response Your email drafts will appear here Provide the context on the left to start. Drafting perfect responses... Generation Failed! The AI could not generate a response. Please adjust your input and try again. Generated Responses Download Responses as PDF Subject: ${email.subject} ${email.body} `; resultsContainer.innerHTML += cardHTML; }); // Prepare content for PDF let pdfHTML = ` Generated Email Responses`; emailVariants.forEach((email, index) => { pdfHTML += ` Option ${index + 1} Subject: ${email.subject} ${email.body} `; }); pdfHTML += ``; pdfDownloadContainer.innerHTML = pdfHTML; document.querySelectorAll('.copy-btn').forEach(button => { button.addEventListener('click', handleCopyClick); }); showState('results'); } catch (error) { console.error("Error generating email response:", error); showState('error'); } finally { setButtonLoading(false); } }; const handleCopyClick = (event) => { const button = event.target; const subject = button.dataset.subject; const body = button.dataset.body; const fullEmail = `Subject: ${subject}\n\n${body}`; const textarea = document.createElement('textarea'); textarea.value = fullEmail; document.body.appendChild(textarea); textarea.select(); try { document.execCommand('copy'); const originalText = button.textContent; button.textContent = 'Copied!'; setTimeout(() => { button.textContent = originalText; }, 2000); } catch (err) { console.error('Failed to copy text: ', err); button.textContent = 'Failed!'; } document.body.removeChild(textarea); }; const handlePdfDownload = () => { const { jsPDF } = window.jspdf; if (!window.html2canvas || !jsPDF) { console.error("jsPDF or html2canvas library not loaded."); return; } const contentToPrint = document.getElementById('pdfDownloadContainerForRender'); contentToPrint.classList.remove('hidden'); html2canvas(contentToPrint, { scale: 2, useCORS: true }) .then(canvas => { const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF('p', 'pt', 'a4'); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = (canvas.height * pdfWidth) / canvas.width; pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight); pdf.save('email_responses.pdf'); contentToPrint.classList.add('hidden'); }).catch(err => { console.error("PDF generation failed:", err); contentToPrint.classList.add('hidden'); }); }; // --- Event Listeners --- generateBtn.addEventListener('click', generateEmailResponse); downloadPdfBtn.addEventListener('click', handlePdfDownload); });