Back to Blog

How to send a confirmation of receipt by email

In some cases you might want to send an email to your customer of confirmation of receipt by email. A common example is when your chatbot creates a ticket in a CRM tool like Salesforce, Zendesk or Hubspot and you confirm that the ticket is received by email.

In this article we show you how to:

  1. Check if we have the customers email address
  2. If not, ask and extract the email address
  3. If the customer doesn’t provide a valid email address, ask again
  4. Send confirmation of receipt by email to the customer

1. Check if we have the customers email address

The first step is to check if we have the customers email address. We can do that by using the Condition trigger. Drag and drop it onto your canvas. The branch that you see will behave as an if/else statement.

If param email exists continue with the first branch, else, follow up with the second branch. For more info regarding conditions, have a look here.

Conditions chatbot

2. If not, ask and extract the email address

Let’s say we don’t have the customers’ email address yet and the bot will continue with the second branch. That is the moment to ask and extract the email address. We do that by using the Any Text trigger. In this example, the name of the parameter is “email”. In the right pane, you can select that this parameter should be an email address.

Conditions chatbot

3. If the customer doesn’t provide a valid email address, ask again

Drag and drop a second any text next to Any text that should be an email. This parameter will be filled whenever the user input is not a valid email address. From there on we can loop back to the event on top.

Tip: provide an option to head back to a menu or intro to prevent customers from being stuck the flow.

Loop for email

4. Send confirmation of receipt by email to the customer

Now, we’ve received the customer’s e-mail address and we can use an Action to send an e-mail from the Flow.ai Platform (supported at Pro and Enterprise Plans).

Loop for email

Drag and drop an Action onto your canvas. You can copy and paste the code below as an example.

async payload => {
  
  let emailadres = "-"
  
  if(Array.isArray(payload.params.email)) {
    emailadres = payload.params.email[0].value
  }
  
  //console.log(emailadres)

  toolbelt.email({
    to: emailadres,
    subject: 'Hello from Flow.ai', 
    message: `Hi and thank you for your message. Someone from flow.ai will get back to you as soon as possible. - Flow.ai Team`
  })
  
}

You can verify the process by using the try it out. You should receive an email in your inbox.

Email confirmation chatbot
Get StartedContact us