Auto-Reply
Set up automatic replies with pattern-matching rules:
suspend fun autoReplyExample() {
val client = AgentMailClient()
val job = client.autoReply("inbox-id") {
pollInterval = 10.seconds
// Match specific messages with rules
rule(
match = { it.subject?.contains("pricing", ignoreCase = true) == true },
reply = {
text = "Thanks for your interest! Our pricing page is at https://example.com/pricing"
}
)
rule(
match = { it.subject?.contains("support", ignoreCase = true) == true },
reply = {
text = "We've received your support request and will get back to you shortly."
}
)
// Default reply for unmatched messages
default {
text = "Thank you for your message. We'll respond soon."
}
}
delay(1.minutes)
job.cancel()
client.close()
}
Rules are evaluated in order. The first matching rule handles the message. If no rule matches, the default reply is used (if defined).
Next Steps
- Bulk Operations — send to multiple inboxes at once
- Webhooks — receive and verify webhook events
- Pods — group inboxes into isolated pods