# 5. Empower your bot with Actions

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FmT40CAJcMQs3qHR3nJUi%2FChooChoo%20tutorial%20rework%20(2).jpg?alt=media&#x26;token=f5a3e272-b9b7-43d6-ba66-e507c6d696a9" alt=""><figcaption><p>What we will build in lesson 5.</p></figcaption></figure>

Action blocks empower chatbots to perform tasks beyond their built-in capabilities by leveraging the functionality of external tools and services, enhancing the overall user experience and utility of the bot.

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2Fv1QzXOyYXUg0vIfwcUzz%2FScreenshot%202024-02-16%20at%2015.21.52.png?alt=media&#x26;token=38aad9bb-afcf-4df3-8836-7b9242782467" alt="" width="156"><figcaption><p>The Action block type.</p></figcaption></figure>

## Step 9: Send an email with an Action block

Now that the bot asks the user info, let’s use the gathered info to send an email so that they receive their discount code.

### Send an email

To add a Send email Action:

1. From the canvas, open the **Send email returning user** block.
2. Go to its **Settings**.
3. Change its type to **Action**.
4. Back to the block content, scroll down to **Send mail**.

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2F9K7lHHbdbn8SUcUyBzoP%2FScreenshot%202024-03-12%20at%2010.11.55.png?alt=media&#x26;token=ea574da8-e155-4109-9513-53de68514b6a" alt="" width="335"><figcaption><p>Add a Send mail step in your Action block.</p></figcaption></figure>

5. Fill the text fields with the following:

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FlOY4O4jzV0LuXsyWjh7H%2FScreenshot%202024-03-12%20at%2010.16.27%20(1).png?alt=media&#x26;token=ade79de8-aab0-48ec-9bc0-15657ce916c2" alt=""><figcaption><p>Use the collected variables to send an email to a user who is already a client.</p></figcaption></figure>

6. Click **Save**.
7. Do the same process for the Send email new user block, and fill it in with the following content:

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2F1YVIN5LIOvflrvDNSCHv%2FScreenshot%202024-03-12%20at%2010.16.13.png?alt=media&#x26;token=9c0ef916-8167-42cb-9214-245733a547e6" alt=""><figcaption><p>Use the collected variables to send an email to a first-time user.</p></figcaption></figure>

8. **Save** your changes.

### Confirm the email to users

Let’s now wrap up the conversation by confirming users that their code has been send.

To add a confirmation message:

1. Drop a **Message** block to your canvas.
2. Go to the block **Settings**.
3. Change its name to *Thanks*.
4. Back to the block configuration, add a **Text** step.
5. Fill it with the following text: *Thanks {userName}, we just send you an email with the code!*
6. **Save** your changes.
7. Draw a Go-to connection from the two blocks that send email to the **Thanks** block.

Your canvas should look like so:

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FrqZ2mbF06dEPm1iA60iW%2FScreenshot%202024-03-12%20at%2011.27.41.png?alt=media&#x26;token=678a813e-3df6-4c1e-9c7a-c617d37cd207" alt=""><figcaption><p>What your canvas should look like at this point.</p></figcaption></figure>

### Test your bot

Make sure to test your bot. Is everything working as expected? If so, your conversation should like so:&#x20;

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2F7edPbN5ymT3XLQ6VuAVW%2FScreenshot%202024-03-12%20at%2011.29.45.png?alt=media&#x26;token=df73c0df-3aae-483e-9b61-c235738b28eb" alt=""><figcaption><p>Test your whole flow. </p></figcaption></figure>

And if you check your emails, you should have received something like this:

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2F13X1yqEGIWLhZRwFWO3H%2FScreenshot%202024-03-27%20at%2017.06.23.png?alt=media&#x26;token=9345c3d7-ebe3-47b5-9956-a7b2857e0b94" alt="" width="375"><figcaption><p>An email send with the chatbot.</p></figcaption></figure>

## Lesson 5 recap

In this lesson, you’ve learned how to:

* [ ] Add an Action block to your canvas so that you can integrate your bot with 3rd-party systems.
* [ ] Use collected variables from users inside a Send mail Action block.

## Coming next

You’ve just built your whole flow, congratulations! The final step in your bot building journey will be to publish your bot.

{% content-ref url="6.-set-up-a-channel-and-publish-your-bot" %}
[6.-set-up-a-channel-and-publish-your-bot](https://docs.chatlayer.ai/start-quickly/leadzy-tutorial/6.-set-up-a-channel-and-publish-your-bot)
{% endcontent-ref %}

## 💬 Feedback

{% hint style="warning" %}
Your feedback on the tutorial means the world to us! Please, let us know what you think through [this short form.](https://forms.office.com/Pages/ResponsePage.aspx?id=ropROyGJe0qEl2GddWziDlEYn6XpsIRDjnCtdRk8L21UMFZMMlAzN0tHOTI4UjMxVTgzTVAwTE5aOCQlQCN0PWcu)
{% endhint %}
