# Zoom Meeting Integration Setup for Backend

This guide explains how to set up Zoom meeting scheduling in the backend API.

## Environment Variables

The backend uses the same Zoom credentials as the `aibit_soft` frontend project. 

### Option 1: Copy from aibit_soft (Recommended)

If you already have Zoom credentials configured in `aibit_soft`, simply copy them to the Backend `.env` file:

1. Open `aibit_soft/.env.local` (or `.env`)
2. Find these variables:
   ```env
   ZOOM_ACCOUNT_ID=your_zoom_account_id
   ZOOM_CLIENT_ID=your_zoom_client_id
   ZOOM_CLIENT_SECRET=your_zoom_client_secret
   ZOOM_HOST_USER_ID=me
   ```
3. Copy them to `Backend/.env`:
   ```env
   ZOOM_ACCOUNT_ID=your_zoom_account_id
   ZOOM_CLIENT_ID=your_zoom_client_id
   ZOOM_CLIENT_SECRET=your_zoom_client_secret
   ZOOM_HOST_USER_ID=me
   ```
4. Restart the backend server

### Option 2: Set Up New Credentials

If you don't have Zoom credentials yet:

1. Go to [Zoom Marketplace](https://marketplace.zoom.us/)
2. Sign in with your Zoom account
3. Click "Develop" → "Build App"
4. Choose "Server-to-Server OAuth" app type
5. Fill in the app details
6. After creation, copy the credentials to `Backend/.env`:
   ```env
   ZOOM_ACCOUNT_ID=your_zoom_account_id
   ZOOM_CLIENT_ID=your_zoom_client_id
   ZOOM_CLIENT_SECRET=your_zoom_client_secret
   ZOOM_HOST_USER_ID=me
   ```

## Email Configuration (Optional but Recommended)

To send email notifications when meetings are scheduled, also add these to `Backend/.env`:

```env
SMTP_HOST=smtp.gmail.com
SMTP_PORT=465
SMTP_USER=your_email@gmail.com
SMTP_PASS=your_app_password
ADMIN_EMAIL=admin@yourcompany.com
COMPANY_EMAIL=contact@yourcompany.com
```

## Testing

1. Make sure all environment variables are set in `Backend/.env`
2. Restart the backend server: `npm run dev`
3. Test the endpoint: `POST /api/create-meeting`
4. Check the server logs for any errors

## Troubleshooting

### Error: "Zoom credentials are not configured"
- Make sure `Backend/.env` file exists
- Verify all three Zoom environment variables are set
- Restart the backend server after adding variables
- Check that there are no extra spaces or quotes around the values

### Error: "Failed to create meeting"
- Verify your Zoom API credentials are correct
- Check that your Zoom app has the necessary permissions
- Ensure the Zoom account has an active subscription
- Check server logs for detailed error messages

### Emails not sending
- Verify SMTP credentials are correct in `Backend/.env`
- Check that SMTP_PORT matches your email provider (465 for Gmail with SSL)
- Ensure ADMIN_EMAIL and COMPANY_EMAIL are set

## Important Notes

- The `.env` file should be in the `Backend` folder (same level as `package.json`)
- Never commit `.env` files to version control
- Restart the server after changing environment variables
- Use the same credentials as `aibit_soft` to keep everything in sync

