Skip to content

Commit 6629800

Browse files
authored
Merge pull request #15 from priyanshuharshbodhi1/Feat-change_llm_provider
[FEAT]: Add workspace and personal LLM settings for admin & user
2 parents db40cc1 + 2a151b7 commit 6629800

36 files changed

+2556
-361
lines changed

AUTH_&_LLM_SETUP.md

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
# Authentication & API Configuration Guide
2+
3+
This guide helps administrators obtain all necessary API keys and configure authentication for the EmailBridge NLP app.
4+
5+
## 📧 Email Provider Configuration
6+
7+
### Gmail / Google Workspace Setup
8+
9+
#### 1. Create Google Cloud Project
10+
1. Go to [Google Cloud Console](https://console.cloud.google.com/)
11+
2. Create a new project or select existing one
12+
3. Enable the **Gmail API**:
13+
- Go to "APIs & Services" > "Library"
14+
- Search for "Gmail API"
15+
- Click "Enable"
16+
17+
#### 2. Configure OAuth 2.0
18+
1. Go to "APIs & Services" > "Credentials"
19+
2. Click "Create Credentials" > "OAuth 2.0 Client IDs"
20+
3. Configure OAuth consent screen if prompted:
21+
- User Type: External (for general use) or Internal (for workspace)
22+
- Fill required fields (App name, User support email, Developer email)
23+
- Add scopes: `https://www.googleapis.com/auth/gmail.readonly`, `https://www.googleapis.com/auth/gmail.send`
24+
4. Create OAuth 2.0 Client ID:
25+
- Application type: **Web application**
26+
- Name: "EmailBridge NLP - Gmail"
27+
- Authorized redirect URIs: `https://your-rocketchat-server.com/api/apps/public/[app-id]/google-oauth-callback`
28+
29+
#### 3. Get Credentials
30+
- Copy **Client ID** and **Client Secret**
31+
- Configure these in Rocket.Chat App Settings under "Google OAuth"
32+
33+
### Outlook / Microsoft 365 Setup
34+
35+
#### 1. Register Application in Azure Portal
36+
1. Go to [Azure Portal](https://portal.azure.com/)
37+
2. Navigate to "App registrations"
38+
3. Click "New registration"
39+
4. Configure:
40+
- Name: "EmailBridge NLP - Outlook"
41+
- Supported account types: "Accounts in any organizational directory and personal Microsoft accounts"
42+
- Redirect URI: Web - `https://your-rocketchat-server.com/api/apps/public/[app-id]/outlook-oauth-callback`
43+
44+
#### 2. Configure API Permissions
45+
1. Go to "API permissions" in your app registration
46+
2. Add permissions:
47+
- **Microsoft Graph** > **Delegated permissions**:
48+
- `Mail.Read` - Read user mail
49+
- `Mail.Send` - Send mail as a user
50+
- `User.Read` - Sign in and read user profile
51+
3. Click "Grant admin consent" (if you're an admin)
52+
53+
#### 3. Create Client Secret
54+
1. Go to "Certificates & secrets"
55+
2. Click "New client secret"
56+
3. Add description and set expiration
57+
4. Copy the **Value** (not the Secret ID)
58+
59+
#### 4. Get Application Details
60+
- Copy **Application (client) ID** from "Overview" page
61+
- Copy **Client Secret** from previous step
62+
- Configure these in Rocket.Chat App Settings under "Outlook OAuth"
63+
64+
## 🤖 LLM Provider Configuration
65+
66+
### OpenAI Setup
67+
68+
#### 1. Create OpenAI Account
69+
1. Go to [OpenAI Platform](https://platform.openai.com/)
70+
2. Sign up or sign in to your account
71+
3. Go to [API Keys page](https://platform.openai.com/api-keys)
72+
73+
#### 2. Generate API Key
74+
1. Click "Create new secret key"
75+
2. Give it a name (e.g., "EmailBridge NLP")
76+
3. Copy the API key (starts with `sk-`)
77+
4. **Important**: Store this key securely - you won't be able to see it again
78+
79+
#### 3. Configure Billing (Required)
80+
1. Go to [Billing page](https://platform.openai.com/account/billing)
81+
2. Add payment method
82+
3. Set usage limits if desired
83+
84+
#### 4. App Configuration
85+
- Configure the API key in Rocket.Chat App Settings under "LLM Configuration"
86+
- Or users can configure personal API keys via `/email llm-config`
87+
88+
### Google Gemini Setup
89+
90+
#### 1. Get Gemini API Key
91+
1. Go to [Google AI Studio](https://aistudio.google.com/)
92+
2. Sign in with your Google account
93+
3. Click "Get API key"
94+
4. Create new API key or use existing project
95+
5. Copy the API key
96+
97+
#### 2. App Configuration
98+
- Configure the API key in Rocket.Chat App Settings under "LLM Configuration"
99+
- Or users can configure personal API keys via `/email llm-config`
100+
101+
### Groq Setup
102+
103+
#### 1. Create Groq Account
104+
1. Go to [Groq Console](https://console.groq.com/)
105+
2. Sign up with your account
106+
3. Go to API Keys section
107+
108+
#### 2. Generate API Key
109+
1. Click "Create API Key"
110+
2. Give it a name
111+
3. Copy the generated key
112+
4. Store securely
113+
114+
#### 3. App Configuration
115+
- Configure the API key in Rocket.Chat App Settings under "LLM Configuration"
116+
- Or users can configure personal API keys via `/email llm-config`
117+
118+
### Self-Hosted LLM Setup
119+
120+
#### 1. Supported Formats
121+
The app supports OpenAI-compatible APIs, including:
122+
- **Ollama** (with OpenAI compatibility layer)
123+
- **LocalAI**
124+
- **OpenAI-compatible servers**
125+
- **Custom LLM APIs**
126+
127+
#### 2. Requirements
128+
- Your LLM server must support OpenAI-compatible chat completions endpoint
129+
- Endpoint format: `POST /v1/chat/completions`
130+
- JSON request/response format matching OpenAI specification
131+
132+
#### 3. Configuration
133+
1. In app settings or via `/email llm-config`, set:
134+
- **Provider**: Self-hosted
135+
- **URL**: Your LLM server URL (e.g., `http://localhost:11434` for Ollama)
136+
2. The app will automatically append `/v1/chat/completions` if needed
137+
138+
#### 4. Example URLs
139+
- **Ollama**: `http://localhost:11434`
140+
- **LocalAI**: `http://localhost:8080`
141+
- **Custom server**: `https://your-llm-server.com:8000`
142+
143+
## 🔧 Rocket.Chat App Configuration
144+
145+
### Admin Settings
146+
1. Go to Administration > Apps > EmailBridge NLP > Settings
147+
2. Configure global settings:
148+
- **Google OAuth Client ID & Secret**
149+
- **Outlook OAuth Client ID & Secret**
150+
- **Default LLM Provider**
151+
- **Default LLM API Keys**
152+
153+
### User Settings
154+
Users can override admin settings with personal configurations:
155+
- Use `/email config` for email provider preferences
156+
- Use `/email llm-config` for personal LLM settings
157+
158+
## 🔒 Security Best Practices
159+
160+
### API Key Management
161+
- **Never commit API keys to version control**
162+
- Use environment variables or secure storage
163+
- Rotate keys regularly
164+
- Monitor API usage and costs
165+
- Set usage limits where possible
166+
167+
### OAuth Configuration
168+
- Use HTTPS for all redirect URIs
169+
- Verify redirect URI matches exactly
170+
- Configure appropriate scopes (minimum required)
171+
- Review and audit OAuth permissions regularly
172+
173+
### App Permissions
174+
- Grant minimum required permissions
175+
- Review user access regularly
176+
- Monitor API usage logs
177+
- Configure rate limiting if available
178+
179+
## 🆘 Troubleshooting
180+
181+
### Common Issues
182+
183+
#### "Invalid API Key" Errors
184+
- Verify API key is correct and not expired
185+
- Check if billing is configured (OpenAI)
186+
- Ensure API key has required permissions
187+
188+
#### OAuth Redirect Errors
189+
- Verify redirect URI matches exactly (including http/https)
190+
- Check app ID in the callback URL
191+
- Ensure OAuth app is approved/published
192+
193+
#### "Rate Limit Exceeded"
194+
- Check API usage limits
195+
- Upgrade plan if needed
196+
- Implement usage monitoring
197+
198+
#### Self-hosted LLM Connection Issues
199+
- Verify server is running and accessible
200+
- Check URL format and endpoint availability
201+
- Test with curl/Postman first
202+
- Review server logs for errors
203+
204+
### Getting Help
205+
- Check Rocket.Chat app logs in Administration > View Logs
206+
- Enable debug logging in app settings
207+
- Review provider-specific documentation
208+
- Open GitHub issue with detailed error information
209+
210+
## 📋 Quick Setup Checklist
211+
212+
### For Gmail Integration:
213+
- [ ] Google Cloud project created
214+
- [ ] Gmail API enabled
215+
- [ ] OAuth 2.0 credentials configured
216+
- [ ] Redirect URI added with correct app ID
217+
- [ ] Client ID & Secret added to app settings
218+
219+
### For Outlook Integration:
220+
- [ ] Azure app registration created
221+
- [ ] Microsoft Graph permissions configured
222+
- [ ] Client secret generated
223+
- [ ] Application ID & Secret added to app settings
224+
225+
### For LLM Integration:
226+
- [ ] LLM provider account created
227+
- [ ] API key generated
228+
- [ ] Billing configured (if required)
229+
- [ ] API key added to app settings or user config
230+
- [ ] Test query executed successfully
231+
232+
## 🔗 Useful Links
233+
234+
- [Google Cloud Console](https://console.cloud.google.com/)
235+
- [Azure Portal](https://portal.azure.com/)
236+
- [OpenAI Platform](https://platform.openai.com/)
237+
- [Google AI Studio](https://aistudio.google.com/)
238+
- [Groq Console](https://console.groq.com/)
239+
- [Rocket.Chat Apps Documentation](https://docs.rocket.chat/extend-rocket.chat/rocket.chat-marketplace/rocket.chat-public-apps-guides)

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ Say goodbye to context switching between your email client and team chat! With *
5656
```sh
5757
npm ci
5858
```
59-
4. Deploy app using:
59+
4. **Configure API Keys & Authentication** (Administrators)
60+
📖 **See [AUTH_&_LLM_SETUP.md](AUTH_&_LLM_SETUP.md) for detailed setup instructions** on how to obtain:
61+
- Gmail/Google OAuth credentials
62+
- Outlook/Microsoft OAuth credentials
63+
- OpenAI, Gemini, Groq, or self-hosted LLM API keys
64+
65+
5. Deploy app using:
6066

6167
```sh
6268
rc-apps deploy --url <server_url> --username <username> --password <password>

i18n/de.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,19 @@
103103
"Outlook_Get_Email_Failed": "E-Mail konnte nicht abgerufen werden",
104104
"Config_No_Trigger": "Konfigurationsmodal kann nicht geöffnet werden. Bitte erneut versuchen.",
105105
"Config_Modal_Error": "Fehler beim Öffnen des Konfigurationsmodals. Bitte erneut versuchen.",
106-
"Config_Error": "Konfigurationsfehler: __error__"
106+
"Config_Error": "Konfigurationsfehler: __error__",
107+
"LLM_Provider_Label": "LLM-Anbieter",
108+
"LLM_Provider_Description": "Wählen Sie den KI-Sprachmodell-Anbieter für die Verarbeitung von E-Mail-Befehlen",
109+
"LLM_Provider_SelfHosted_Label": "Selbst gehostet",
110+
"LLM_Provider_OpenAI_Label": "OpenAI",
111+
"LLM_Provider_Gemini_Label": "Google Gemini",
112+
"LLM_Provider_Groq_Label": "Groq",
113+
"SelfHosted_LLM_URL_Label": "Selbst gehostete LLM-URL",
114+
"SelfHosted_LLM_URL_Description": "URL für Ihren selbst gehosteten LLM-Endpunkt",
115+
"OpenAI_API_Key_Label": "OpenAI API-Schlüssel",
116+
"OpenAI_API_Key_Description": "Ihr OpenAI API-Schlüssel für den Zugriff auf GPT-Modelle (nur bei Verwendung des OpenAI-Anbieters erforderlich)",
117+
"Gemini_API_Key_Label": "Google Gemini API-Schlüssel",
118+
"Gemini_API_Key_Description": "Ihr Google AI Studio API-Schlüssel für den Zugriff auf Gemini-Modelle (nur bei Verwendung des Gemini-Anbieters erforderlich)",
119+
"Groq_API_Key_Label": "Groq API-Schlüssel",
120+
"Groq_API_Key_Description": "Ihr Groq API-Schlüssel für den Zugriff auf Llama-Modelle (nur bei Verwendung des Groq-Anbieters erforderlich)"
107121
}

i18n/en.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,19 @@
103103
"Outlook_Get_Email_Failed": "Failed to get email",
104104
"Config_No_Trigger": "❌ Unable to open configuration modal. Please try again.",
105105
"Config_Modal_Error": "❌ Error opening configuration modal. Please try again.",
106-
"Config_Error": "❌ Configuration error: __error__"
106+
"Config_Error": "❌ Configuration error: __error__",
107+
"LLM_Provider_Label": "LLM Provider",
108+
"LLM_Provider_Description": "Select the AI language model provider to use for processing email commands",
109+
"LLM_Provider_SelfHosted_Label": "Self-hosted",
110+
"LLM_Provider_OpenAI_Label": "OpenAI",
111+
"LLM_Provider_Gemini_Label": "Google Gemini",
112+
"LLM_Provider_Groq_Label": "Groq",
113+
"SelfHosted_LLM_URL_Label": "Self-hosted LLM URL",
114+
"SelfHosted_LLM_URL_Description": "URL for your self-hosted LLM endpoint",
115+
"OpenAI_API_Key_Label": "OpenAI API Key",
116+
"OpenAI_API_Key_Description": "Your OpenAI API key for accessing GPT models (required only when using OpenAI provider)",
117+
"Gemini_API_Key_Label": "Google Gemini API Key",
118+
"Gemini_API_Key_Description": "Your Google AI Studio API key for accessing Gemini models (required only when using Gemini provider)",
119+
"Groq_API_Key_Label": "Groq API Key",
120+
"Groq_API_Key_Description": "Your Groq API key for accessing Llama models (required only when using Groq provider)"
107121
}

i18n/es.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,19 @@
103103
"Outlook_Get_Email_Failed": "No se pudo obtener el correo",
104104
"Config_No_Trigger": "❌ No se puede abrir el modal de configuración. Inténtelo de nuevo.",
105105
"Config_Modal_Error": "❌ Error al abrir el modal de configuración. Inténtelo de nuevo.",
106-
"Config_Error": "❌ Error de configuración: __error__"
106+
"Config_Error": "❌ Error de configuración: __error__",
107+
"LLM_Provider_Label": "Proveedor de LLM",
108+
"LLM_Provider_Description": "Selecciona el proveedor de modelo de lenguaje IA para procesar comandos de correo electrónico",
109+
"LLM_Provider_SelfHosted_Label": "Auto-hospedado",
110+
"LLM_Provider_OpenAI_Label": "OpenAI",
111+
"LLM_Provider_Gemini_Label": "Google Gemini",
112+
"LLM_Provider_Groq_Label": "Groq",
113+
"SelfHosted_LLM_URL_Label": "URL de LLM Auto-hospedado",
114+
"SelfHosted_LLM_URL_Description": "URL para su endpoint LLM auto-hospedado",
115+
"OpenAI_API_Key_Label": "Clave API de OpenAI",
116+
"OpenAI_API_Key_Description": "Tu clave API de OpenAI para acceder a modelos GPT (requerido solo al usar el proveedor OpenAI)",
117+
"Gemini_API_Key_Label": "Clave API de Google Gemini",
118+
"Gemini_API_Key_Description": "Tu clave API de Google AI Studio para acceder a modelos Gemini (requerido solo al usar el proveedor Gemini)",
119+
"Groq_API_Key_Label": "Clave API de Groq",
120+
"Groq_API_Key_Description": "Tu clave API de Groq para acceder a modelos Llama (requerido solo al usar el proveedor Groq)"
107121
}

i18n/pl.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,19 @@
103103
"Outlook_Get_Email_Failed": "Nie udało się pobrać e-maila",
104104
"Config_No_Trigger": "❌ Nie można otworzyć modalu konfiguracji. Spróbuj ponownie.",
105105
"Config_Modal_Error": "❌ Błąd podczas otwierania modalu konfiguracji. Spróbuj ponownie.",
106-
"Config_Error": "❌ Błąd konfiguracji: __error__"
106+
"Config_Error": "❌ Błąd konfiguracji: __error__",
107+
"LLM_Provider_Label": "Dostawca LLM",
108+
"LLM_Provider_Description": "Wybierz dostawcę modelu językowego AI do przetwarzania poleceń e-mail",
109+
"LLM_Provider_SelfHosted_Label": "Własny hosting",
110+
"LLM_Provider_OpenAI_Label": "OpenAI",
111+
"LLM_Provider_Gemini_Label": "Google Gemini",
112+
"LLM_Provider_Groq_Label": "Groq",
113+
"SelfHosted_LLM_URL_Label": "URL LLM własnego hostingu",
114+
"SelfHosted_LLM_URL_Description": "URL dla Twojego punktu końcowego LLM własnego hostingu",
115+
"OpenAI_API_Key_Label": "Klucz API OpenAI",
116+
"OpenAI_API_Key_Description": "Twój klucz API OpenAI do dostępu do modeli GPT (wymagany tylko przy używaniu dostawcy OpenAI)",
117+
"Gemini_API_Key_Label": "Klucz API Google Gemini",
118+
"Gemini_API_Key_Description": "Twój klucz API Google AI Studio do dostępu do modeli Gemini (wymagany tylko przy używaniu dostawcy Gemini)",
119+
"Groq_API_Key_Label": "Klucz API Groq",
120+
"Groq_API_Key_Description": "Twój klucz API Groq do dostępu do modeli Llama (wymagany tylko przy używaniu dostawcy Groq)"
107121
}

i18n/pt.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,19 @@
103103
"Outlook_Get_Email_Failed": "Falha ao obter e-mail",
104104
"Config_No_Trigger": "❌ Não é possível abrir o modal de configuração. Tente novamente.",
105105
"Config_Modal_Error": "❌ Erro ao abrir o modal de configuração. Tente novamente.",
106-
"Config_Error": "❌ Erro de configuração: __error__"
106+
"Config_Error": "❌ Erro de configuração: __error__",
107+
"LLM_Provider_Label": "Provedor de LLM",
108+
"LLM_Provider_Description": "Selecione o provedor de modelo de linguagem IA para processar comandos de e-mail",
109+
"LLM_Provider_SelfHosted_Label": "Auto-hospedado",
110+
"LLM_Provider_OpenAI_Label": "OpenAI",
111+
"LLM_Provider_Gemini_Label": "Google Gemini",
112+
"LLM_Provider_Groq_Label": "Groq",
113+
"SelfHosted_LLM_URL_Label": "URL do LLM Auto-hospedado",
114+
"SelfHosted_LLM_URL_Description": "URL para seu endpoint LLM auto-hospedado",
115+
"OpenAI_API_Key_Label": "Chave API do OpenAI",
116+
"OpenAI_API_Key_Description": "Sua chave API do OpenAI para acessar modelos GPT (necessário apenas ao usar o provedor OpenAI)",
117+
"Gemini_API_Key_Label": "Chave API do Google Gemini",
118+
"Gemini_API_Key_Description": "Sua chave API do Google AI Studio para acessar modelos Gemini (necessário apenas ao usar o provedor Gemini)",
119+
"Groq_API_Key_Label": "Chave API do Groq",
120+
"Groq_API_Key_Description": "Sua chave API do Groq para acessar modelos Llama (necessário apenas ao usar o provedor Groq)"
107121
}

i18n/ru.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,19 @@
103103
"Outlook_Get_Email_Failed": "Не удалось получить электронное письмо",
104104
"Config_No_Trigger": "❌ Невозможно открыть модальное окно конфигурации. Повторите попытку.",
105105
"Config_Modal_Error": "❌ Ошибка при открытии модального окна конфигурации. Повторите попытку.",
106-
"Config_Error": "❌ Ошибка конфигурации: __error__"
106+
"Config_Error": "❌ Ошибка конфигурации: __error__",
107+
"LLM_Provider_Label": "Провайдер LLM",
108+
"LLM_Provider_Description": "Выберите провайдера языковой модели ИИ для обработки команд электронной почты",
109+
"LLM_Provider_SelfHosted_Label": "Самостоятельно размещенный",
110+
"LLM_Provider_OpenAI_Label": "OpenAI",
111+
"LLM_Provider_Gemini_Label": "Google Gemini",
112+
"LLM_Provider_Groq_Label": "Groq",
113+
"SelfHosted_LLM_URL_Label": "URL самостоятельно размещенного LLM",
114+
"SelfHosted_LLM_URL_Description": "URL для вашего самостоятельно размещенного эндпоинта LLM",
115+
"OpenAI_API_Key_Label": "API-ключ OpenAI",
116+
"OpenAI_API_Key_Description": "Ваш API-ключ OpenAI для доступа к моделям GPT (требуется только при использовании провайдера OpenAI)",
117+
"Gemini_API_Key_Label": "API-ключ Google Gemini",
118+
"Gemini_API_Key_Description": "Ваш API-ключ Google AI Studio для доступа к моделям Gemini (требуется только при использовании провайдера Gemini)",
119+
"Groq_API_Key_Label": "API-ключ Groq",
120+
"Groq_API_Key_Description": "Ваш API-ключ Groq для доступа к моделям Llama (требуется только при использовании провайдера Groq)"
107121
}

0 commit comments

Comments
 (0)