# GitLab Integration

Enable Optibot to analyze your GitLab repositories, automate code reviews, and generate contextual summaries.

**Setup time:** ~12–15 minutes

**Required permissions:** Maintainer or Admin on the GitLab group or repository.

## Sign Up and Access the Integration Page

1. Go to the [Optimal AI signup page](https://agents.getoptimal.ai/signup).
2. Select **“Sign Up with GitLab.”**
3. Complete your account details and verify your email address.
4. After verification, you’ll be redirected to the GitLab Integration Setup page.

## Create a GitLab Access Token

Optibot requires a GitLab Access Token from a bot or service account with specific permissions to interact with your repositories.

### Steps

1. In GitLab, navigate to your group or repository’s **Settings → Access Tokens**. (Group tokens are recommended for multi-repository installations.)
2. Click **“Add new token.”**
3. Enter a Token name, e.g., `Optibot-code-review` or `Optibot Reviewer`.
4. Add a short description, and set the expiration date to the maximum allowed.
5. Assign the role as **Maintainer**.
6. Under Scopes, select all of the following:
   - `api` — Full API access
   - `read_repository` — Clone and read repositories
   - `write_repository` — Create merge request comments
   - `read_user` — Access user information

## Continue Your Setup on Optimal

1. If you’re on a self-hosted instance, replace your URL from `gitlab.com` to your self-hosted domain.
2. Insert your GitLab token in the field provided.
3. Grab your Bot/User ID from the Admin page at `gitlab.com/admin/users` (or your GitLab URL `/admin/users`).
4. Click **“Connect GitLab.”**
5. You’ll be taken to a screen to select your repos. Select the repos you want Optibot installed on — this will create webhooks automatically.
6. Your install of Optibot is finished. Manage it from [https://agents.getoptimal.ai/dashboard/gitlab-integration](https://agents.getoptimal.ai/dashboard/gitlab-integration).

## Verify Installation

Once setup completes:

- Optibot will begin analyzing merge requests automatically.
- Confirm installation by checking your **GitLab Repository → Settings → Webhooks**. There should be an entry for `agents.getoptimal.ai`.

## Optibot Features on GitLab

Once integrated, Optibot enables:

- 🧠 **Automated Code Reviews** — Reviews each new merge request and provides detailed feedback directly in GitLab comments.
- 🧾 **AI-Generated Summaries** — Generates structured summaries and line-by-line breakdowns of code changes for every MR.
- ⚙️ **Contextual Recommendations** — Highlights potential issues, security concerns, or missing documentation based on code patterns.
- 🔗 **Cross-Tool Integration** — Works seamlessly with Jira, Bitbucket, and other tools for compliance and reporting.

For additional configuration options, visit the [Advanced Configuration page](https://agents.getoptimal.ai/dashboard/advanced-config).

✅ Your Optibot GitLab integration is now complete. Monitor and manage your integrations at: [https://agents.getoptimal.ai/dashboard/gitlab-integration](https://agents.getoptimal.ai/dashboard/gitlab-integration).
