> For the complete documentation index, see [llms.txt](https://fb-scripts.gitbook.io/fb-scripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fb-scripts.gitbook.io/fb-scripts/scripts/fb-chat/installation.md).

# Installation

{% stepper %}
{% step %}
Download and extract the `fb-chat` folder.
{% endstep %}

{% step %}
Move the `fb-chat` folder into your server's `resources` directory.
{% endstep %}

{% step %}
Open your `server.cfg` and add the following line:

```cfg
ensure fb-chat
```

{% endstep %}

{% step %}
Restart your server or type `refresh` and `ensure fb-chat` in your server console
{% endstep %}
{% endstepper %}

***

### Database *<mark style="color:$info;">Optional</mark>*

#### Automatic Setup (Default)

fb-chat **automatically creates all required database tables** when the resource starts. No manual SQL import needed!

By default, data is stored in `database.json` (zero dependencies). To switch to MySQL, just set in `config.lua`:

```lua
Config.Database = {
    mode       = 'mysql',
    table_name = 'fb_chat_data',
}
```

When you start your server, you'll see in console:

```
[fb-chat] MySQL driver detected: oxmysql
[fb-chat] Database table verified: fb_chat_data (1/1 tables ready)
```

#### How It Works

* Auto-detects your MySQL driver (oxmysql, mysql-async, or ghmattimysql)
* Uses `CREATE TABLE IF NOT EXISTS` — safe to run every restart
* If you already have data in JSON, it will be migrated to MySQL automatically
* If no MySQL driver is found, it prints a warning and falls back to JSON
* Even in MySQL mode, a periodic JSON backup is created for safety

#### Supported MySQL Drivers

| Driver           | Detection Method                 | Status      |
| ---------------- | -------------------------------- | ----------- |
| **oxmysql**      | `exports.oxmysql:execute()`      | ✅ Supported |
| **mysql-async**  | `MySQL.Async.execute()`          | ✅ Supported |
| **ghmattimysql** | `exports.ghmattimysql:execute()` | ✅ Supported |

{% hint style="warning" %}
You only need **one** of the above drivers installed. fb-chat auto-detects which one is running.
{% endhint %}

***

### GIF Support *<mark style="color:$info;">Optional</mark>*

Get a free key from [Tenor Developers](https://developers.google.com/tenor/guides/quickstart) and paste it in `editable/keys.lua`:

```lua
Keys.TenorApiKey = 'YOUR_TENOR_API_KEY'
```
