# Delete record

Deleting a record on your table means that you will delete a row on your table.&#x20;

This means that you'll go from this:&#x20;

| name   | email\_address    | is\_susbcribed |
| ------ | ----------------- | -------------- |
| Agatha | <agatha@test.com> | TRUE           |

To that: <br>

| name | email\_address | is\_susbcribed |
| ---- | -------------- | -------------- |
|      |                |                |

To delete a record from your table:&#x20;

1. Make sure that you already have a filled a table. For this example, we will use an opt in/opt out table that captures:
   * **name**: Captures customer's name.
   * **email\_address**: Store customer's email address.
   * **is\_subscribed**: Store customer's consent to be subscribed to a campain.&#x20;

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2Fr0GbeDuxJbVJs1Ag7A3j%2FScreenshot%202024-04-19%20at%2008.43.35.png?alt=media&#x26;token=42bd6c8f-a028-4d88-b123-50f9f2743105" alt=""><figcaption><p>An example of table for Opt in/opt out. </p></figcaption></figure>

2. Make sure that you capture the relevant variables in your conversation. In our example, we capture `{userName}` in Collect input blocks. This is the variable that we will use as a filter to target certain row to be deleted.&#x20;
3. [Add a Table operation](https://docs.chatlayer.ai/bot-answers/tables-beta/operate-on-your-records#add-a-table-operation-to-your-flow) to your flow.&#x20;
4. Select **Delete record.**
5. Select the table that you'd like to work on. For this example, we called our table **Subscriptions.**&#x20;
6. Click on **+ Add filter** to define a selection criteria. For this example, we filter out by looking at the 'name' column. If the name equals `{userName}`, it means that the row will be deleted once the opt out flow is triggered.&#x20;

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2Fc4xSY8ZH5629hSNILtZX%2FScreenshot%202024-04-19%20at%2008.48.10.png?alt=media&#x26;token=c9936b00-c9ec-483b-a3f7-71370262cb6b" alt=""><figcaption><p>Delete a record from your Table.</p></figcaption></figure>

7. Click **Save**.&#x20;
8. Add a **Message** block as a Go to to let your customer know that they are successfully opted out.&#x20;

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FfzQmRJvPgAVKOD66oJIu%2FScreenshot%202024-04-19%20at%2008.58.21.png?alt=media&#x26;token=27c63034-c35e-4884-8690-cad6a9176bdb" alt=""><figcaption><p>Example of opt out flow.</p></figcaption></figure>

9. It's crucial to check the functionality of your Delete record operation to ensure that the correct row is deleted. Test your bot in the emulator. Run through your bot flow within the emulator to simulate the user experience and trigger the **Delete record** action.

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FEDRCriNwqhGVXnLfvLEP%2FScreenshot%202024-04-19%20at%2009.20.37.png?alt=media&#x26;token=5b6863a4-3310-49f4-8572-63fd9f64ac1b" alt="" width="375"><figcaption><p>Test your flow.</p></figcaption></figure>

10. Open your table, and verify that the bot deleted the correct row.

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FVM5MmnlpdidnWH6gWBmY%2FScreenshot%202024-04-19%20at%2009.22.42.png?alt=media&#x26;token=6f3b9567-05ae-401b-878b-b74af20be79c" alt=""><figcaption><p>Check that the bot deleted the correct flow.</p></figcaption></figure>

{% hint style="success" %}
Looking for a quick and easy bot template to play with Tables? The [Gym bot](https://docs.chatlayer.ai/tutorials/bot-templates/gym) is a representative use case.
{% endhint %}
