> For the complete documentation index, see [llms.txt](https://docs-convai.wavy.global/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-convai.wavy.global/tips-and-best-practices/how-to-recognize-a-returning-bot-user.md).

# How to recognize a returning bot user

A good bot can make users feel they're talking to a real 'artificial intelligence', with a distinct personality. However, when it starts the next conversation as if you've never met before, the illusion is gone.

Chatlayer.ai enables you to treat returning users differently, using saved variables from previous sessions.

{% hint style="info" %}
Note that not all channels save variables the same way!

Facebook Messenger saves them indefinitely, but by default, the Webwidget only keeps variables for the duration of the session - unless authentication of unique users is built in.
{% endhint %}

## Change the introduction to a *Go to*

Every conversation starts with the *introduction* dialog:

![](/files/-MFgECfquAJdZqX_WV7_)

By default, this is a `Bot message`:

![](/files/-MFgECfra5WisOALXV-n)

However, instead of greeting the user right away, we can first check whether the bot has talked to him before by converting the *introduction* into a `Go to`:

![](/files/-MFgECfskjJ2TIBEsdk6)

## Identify returning users with a 'known\_user\_flag' variable

Using a variable 'known\_user\_flag' (feel free to rename in line with your naming conventions), the bot can check whether it has talked to the user before, and redirect to the right dialogs accordingly.

Build an If-statement as follows:

* If 'known\_user\_flag' is equal to 1, we know for certain that there has been a conversation before - else the variable would be empty - so the user can be directed to an introduction dialog appropriate for returning users.
* Else, if 'known\_user\_flag' is not defined, the user must be new, and can be redirected to an introduction for new users. At the same time, you can already set the 'known\_user\_flag' to 1, as the user is not new anymore. Alternatively, you can only change this value later on in the conversation, but changing it here is the most simple option.

![](/files/-MFgECftsaVpEHwHLbXJ)

![](/files/-MFgECfuKXunf_c11anm)

## Modify flow for returning users, leveraging saved variables

Simply having a modified introduction for returning users is already of great value:

![](/files/-MFgECfvXygTwaxu5NPB)

However, you can really take the bot to the next level by also using other saved variables from previous encounters.

For example, the Choo-choo bot can use previous 'origin' and 'destination' values to suggest a new journey.

You'll first want to check whether any values have been saved:

![](/files/-MFgECfwRHKEEOD5Cxs2)

...and if so, direct to a dialog using these variables:

![](/files/-MFgECfx0-zT2UnkTCEo)

Used this way, saved variables can provide returning users are more personalized and efficient experience!


---

# 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 dynamically by asking a question.

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

```
GET https://docs-convai.wavy.global/tips-and-best-practices/how-to-recognize-a-returning-bot-user.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.
