# AI Assistant

## Overview

**UI Bakery AI Assistant** is an AI-based chatbot that can quickly help you with technical questions and code generation. The chatbot window is flexible - you can easily resize it and drag to any place on the screen. It also remembers you current settings - so next time you open it, window size and place will be the same. You can toggle AI Assistant with `Cmd + I/Ctrl + I`*.*

### Chats and chat history

You can also access **chat history** to browse through, search, or select any chat you want to pick up right where you left off.\
Or if you prefer, you can start a **new chat** - once your first message is sent, the chat will automatically rename itself based on the conversation topic. Any chat you don't need any more can be deleted from the chat window as well.

{% @arcade/embed flowId="lH0V2hCEafyzbaN42BxY" url="<https://app.arcade.software/share/lH0V2hCEafyzbaN42BxY>" %}

### Context and modes

AI Assistant also understands your current context - whether you're creating an action, writing an SQL query, or checking the Logs. The chat context will vary accordingly, and AI Assistant will offer tailored solutions to help you move forward with building your app.

The AI Assistant works in two modes - [Documentation](#documentation-mode) and [Code generation](#code-generation-mode).

{% @arcade/embed flowId="NjaSc548ixYNWc0ym3pw" url="<https://app.arcade.software/share/NjaSc548ixYNWc0ym3pw>" %}

#### Documentation mode

In this mode, the AI Assistant refers to UI Bakery documentation. When you ask a technical question, it explores the docs and gets back to you with an answer.&#x20;

The Assistant also has access to the currently used *action context* and, based on that, can troubleshoot the action. Simply click the **Debug with AI** button in the action's *Result* section if you need chatbot's assistance in troubleshooting an action.

<figure><img src="/files/lyhtwet2DK5IgWNYhKWI" alt=""><figcaption></figcaption></figure>

The Assistant's answer can be rated with **Like/Dislike** buttons. This allows to educate the chatbot in the best way possible so we highly encourage you to use these rating options.

{% hint style="info" %}
If you notice that the Assistant's reply is not correct, contact us in the live chat or via email at <support@uibakery.io>.
{% endhint %}

#### Code generation mode

Code generation mode can help with generating SQL queries or JavaScript code. This is especially useful for the execution of repetitive code, data transformations, or simply handling the not-so-well-known programming language.

To activate the Assistant in this mode, simply click on the chatbot's icon in the code field, specify the details of the query, and hit *Enter*. The AI Assistant has access to the current action context making code generation easier.

<figure><img src="/files/DlgdG23vWLHoy4QLB5xm" alt=""><figcaption></figcaption></figure>

## Activating AI Assistant on a self-hosted version

The AI assistant is hidden under a feature flag on a self-hosted version. To activate it on your instance, follow these steps:

1. Activate the `UI_BAKERY_ENABLED_FEATURE_FLAGS=chat` and `UI_BAKERY_CHAT_API_URL=`[`https://chat2.uibakery.io`](https://chat2.uibakery.io/) variables in the .env file.
2. Restart your instance `docker compose up -d`.


---

# 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.uibakery.io/reference/ai-assistant.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.
