Reply to received emails directly through the mail API:
Copy
// Reply to an emailawait inbound.mail.reply({ emailId: 'email_abc123', to: 'customer@example.com', subject: 'Re: Your inquiry', textBody: 'Thank you for your message. We will get back to you soon.', htmlBody: '<p>Thank you for your message. We will get back to you soon.</p>'})
// Search for unprocessed ordersconst orderEmails = await inbound.mail.list({ search: 'order', timeRange: '24h', status: 'processed'})for (const email of orderEmails.emails) { // Get full email details const details = await inbound.mail.get(email.id) // Process order const orderNumber = extractOrderNumber(details.textBody) await processOrder(orderNumber) // Reply to confirm await inbound.mail.reply({ emailId: email.id, to: email.from, subject: `Order ${orderNumber} Confirmed`, textBody: `Your order ${orderNumber} has been received and is being processed.` })}