> For the complete documentation index, see [llms.txt](https://docs.lidistat67.eu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lidistat67.eu/installing-and-configuring-modmail.md).

# Installing and configuring Modmail

## Installing Modmail

In order to install Modmail start by running:

```
git clone https://github.com/kyb3r/modmail
```

Go to the Modmail folder by running:

```
cd modmail
```

## Configuring Modmail

{% hint style="info" %}
To paste text in PuTTY, right click or press Shift+Insert.
{% endhint %}

Start by renaming the .env.example file by running:

```
mv .env.example .env
```

Edit your .env file by running:

```
nano .env
```

In `TOKEN` paste your bot token that you created in [Making Bot Application](/making-bot-application.md)\
In `OWNERS` paste the ID of all the users that will have owner privileges.\
In `GUILD_ID` paste the ID of your server\
In `CONNECTION_URI` enter your MongoDB connection URI\
In `LOG_URL` enter your logviewer link

To save your changes press Ctrl+X. On save modified buffer press Y. When File Name to Write: appears press enter.

## Starting Modmail

### Using Pipenv

Install dependencies by running:

```
pipenv install
```

Finally run it by using

```
pipenv run bot
```

### Using PM2 (recommended)

{% hint style="warning" %}
You need to use pipenv at least once before using PM2.
{% endhint %}

To start your bot using PM2 run

```
pm2 start modmail.sh --name "modmail" && pm2 save && pm2 startup
```

Once you run this command, you should see a command below "\[PM2] To setup the Startup Script, copy/paste the following command:". Copy and run the command. The command should look like this:

```
sudo env PATH=$PATH:/usr/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup systemd -u ubuntu --hp /home/ubuntu
```

Congratulations! You now have a working Modmail. If you'd like to set up logviewer, continue to [Installing dependencies (logviewer)](/installing-dependencies-logviewer.md)

{% hint style="danger" %}
For any issues before the Installing dependencies step, please contact me (lidistat67). You can ping me in the server and I'll reply ASAP. For any issues during or after the Installing dependencies step, you may also contact the Modmail support team.
{% endhint %}


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.lidistat67.eu/installing-and-configuring-modmail.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
