# Gathering user feedback

This tutorial will show you how to gather feedback from your users about the quality of the bot and send that feedback to an external database for further analysis. In this example, we will send the feedback data to Airtable – a tool that allows you to create a spreadsheet that you can talk to using an API.

* Start by creating a flow in your Chatlayer.ai bot that contains rating options, for example:

![](/files/-M9TNm46NmxW-x983cfG)

* Make sure you save the rating of the user as a variable "star\_rating" with a number value
* As a Go To, create a new input validation called "long text feedback"

![](/files/-M9TOX_icGdSiSnyntaF)

* Save the additional comments under the "comment" variable, and Go To a newly created Action "send feedback to Airtable"
* In the newly created Action, add a "Code" plugin that contains the following header:

![](/files/-M9TXk6Ejd_RWlu04hWE)

* The "nextDialogState" is where your bot will go after saving the feedback to Airtable
* Create a new Airtable with these columns:

![](/files/-M9TXqruKOmsYHQZDaPI)

{% hint style="info" %}
In this tutorial, we will be using [this Airtable](https://airtable.com/shrip6vQuFSy5z7Tz). Feel free to reuse it!
{% endhint %}

* Add the following code to your Code plugin in Chatlayer.ai

```javascript
const body = {
    "records": [{
        "fields": {
            "star_rating": args.star_rating,
            "comment": args.comment,
            "sessionId": args.sessionId
        }
    }]
}
const airtableResult = await fetch('https://api.airtable.com/v0/(insert app name here)/(insert table name here)', {
    method: 'POST',
    body: JSON.stringify(body),
    headers: {
        'Authorization': 'Bearer (insert your bearer token here)',
        'Content-Type': 'application/json'
    }
}).then(r => r.json())

ChatlayerResponseBuilder()
    .setNextDialogState(args.nextDialogState)
    .send()
```

{% hint style="warning" %}
Remember to get the right app id, table name and bearer token for your Airtable. You can find it [here](https://airtable.com/api).
{% endhint %}

* Add a small confirmation to the "feedback recorded" bot dialog
* Ready to test

![](/files/-M9TW8oyxbZntfISrXR8)

* The feedback data from the user shows up in the Airtable, ready for analysis!

![](/files/-M9TY-JI9GZLiLlC3qdB)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.chatlayer.ai/~/changes/zWOY8fNiBBrqneKkuGvA/tutorials-1/gathering-user-feedback.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
