> For the complete documentation index, see [llms.txt](https://docs.chatlayer.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chatlayer.ai/~/changes/zWOY8fNiBBrqneKkuGvA/tutorials-1/gathering-user-feedback.md). Agents can also search and read this documentation through its [MCP server](https://docs.chatlayer.ai/~gitbook/mcp).

# 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:

![](https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LLTwFwbOqJj4dDhg8Ju%2F-M9TBr-8jEkVktaDL2qK%2F-M9TNm46NmxW-x983cfG%2Fimage.png?alt=media\&token=6f3ebb75-dca9-4e67-ac88-27965b3f1b30)

* 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"

![](https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LLTwFwbOqJj4dDhg8Ju%2F-M9TBr-8jEkVktaDL2qK%2F-M9TOX_icGdSiSnyntaF%2Fimage.png?alt=media\&token=d6aacf5a-b693-4f83-bc55-4dc6c85cfc90)

* 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:

![](https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LLTwFwbOqJj4dDhg8Ju%2F-M9TBr-8jEkVktaDL2qK%2F-M9TXk6Ejd_RWlu04hWE%2Fimage.png?alt=media\&token=e2cc614f-3ba4-42a9-82d1-cee2ce4b9b7c)

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

![](https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LLTwFwbOqJj4dDhg8Ju%2F-M9TBr-8jEkVktaDL2qK%2F-M9TXqruKOmsYHQZDaPI%2Fimage.png?alt=media\&token=92d88cef-8e3b-4013-a114-e075aa31bbb5)

{% 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

![](https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LLTwFwbOqJj4dDhg8Ju%2F-M9TBr-8jEkVktaDL2qK%2F-M9TW8oyxbZntfISrXR8%2Fimage.png?alt=media\&token=711a7208-72c9-4c90-9543-63dacb26f0f3)

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

![](https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LLTwFwbOqJj4dDhg8Ju%2F-M9TBr-8jEkVktaDL2qK%2F-M9TY-JI9GZLiLlC3qdB%2Fimage.png?alt=media\&token=7cb401a4-b101-43d7-a1b0-b0c957661192)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
