Skip to content

Auto reply

repliers

An inbox replier lets you define automated responses when matching emails are received by an inbox.

Configuration

Repliers can be added to inboxes. When the inbox receives an email the email will be checked against any matching rules on the replier. If it matches then an automated response will be sent using the replier's body or template.

// send email from inbox2 to inbox1 and expect an auto-reply
log('Send email');
const sent = await mailslurp.inboxController.sendEmailAndConfirm({
  inboxId: inbox2.id!!,
  sendEmailOptions: {
    to: [inbox1.emailAddress!!],
    subject: 'Hello',
    body: 'Are you home?'
  },
});
expect(sent.to).toContain(inbox1.emailAddress);

// see that inbox2 gets a reply
const receivedEmail = await mailslurp.waitController.waitForLatestEmail({
  inboxId: inbox2.id,
  timeout: 60000,
  unreadOnly: true,
});
expect(receivedEmail.subject).toContain('Hello');
expect(receivedEmail.body).toContain('We are not home right now');

Events

You can use event endpoints to measure the quantity and success or failure of responses.

// get events for inbox replier
const events = await mailslurp.inboxReplierController.getInboxReplierEvents({
  id: replier.id
})
expect(events.totalElements).toEqual(1)
expect(events.content![0].status).toEqual(InboxReplierEventProjectionStatusEnum.SUCCESS)