Code-based Actions: Send a confirmation email
Using the bot, you can send emails to the end users. In some cases, you might want to send an automated email to your customer for the confirmation of email receipt. For example, the bot creates a ticket in a CRM tool like Salesforce, Zendesk, or Hubspot and you need to acknowledge that the ticket has been received.
To send a confirmation email, check if you have the customer's email address. If you do not have the email address, ask the user to provide the email address and extract the email address.
Check if we have the customer's email address
The first step is to check if we have the customer's email address. We can do that by using the Condition trigger. Drag and drop it onto your canvas. With the condition trigger, create the if/ else branches. If param 'email' exists continue with the first branch, else, follow with the second branch.
For more info regarding conditions, have a look here.
If not, ask and extract the email address
Let's say we don't have the customers' email addresses yet, the bot will continue with the second branch.
Read more about 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.
If the customer doesn't provide a valid email address, ask again
Drag and drop a second Any text trigger should be an email. This parameter will be filled whenever the user input is not a valid email address. From this step, we can loop back to the event on top.
Tip: Provide an option to go to main menu to prevent customers from being stuck the flow.
Send confirmation of receipt by email to the customer
Use an Action to send an e-mail from the Flow Action.
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 window. You should receive an email in your inbox.
Updated 11 months ago