# <%= className %> Bot

A modern Botonic bot application built with TypeScript, Vite, and React.

## 🚀 Getting Started

### Development

```bash
# Start webchat development server
pnpm run serve:webchat

# Start webviews development server
pnpm run serve:webviews

# Start Lambda development server
pnpm run serve:lambda

# Start all development servers
pnpm run serve

# Build for production
pnpm run build

# Build for Node.js (Lambda)
pnpm run build:node

# Run tests
pnpm run test

# Type checking
pnpm run typecheck
```

## 📁 Project Structure

```
src/
├── client/           # Client-side applications
│   ├── webchat/     # Webchat interface
│   └── webviews/    # Webview interfaces
├── server/          # Server-side bot logic
│   ├── bot/         # Bot configuration and actions
│   └── lambda/      # AWS Lambda handler
└── shared/          # Shared utilities and config
```

## 🔧 Configuration

### Bot Configuration

The main bot configuration is in `src/server/bot/index.ts`. This includes:

- **Routes**: Define conversation flows
- **Actions**: Handle user interactions
- **Locales**: Multi-language support
- **Plugins**: Extend bot functionality
- **Theme**: Customize appearance

### Environment Variables

Copy the example environment file and customize for your setup:

```bash
# Copy example environment file
cp .env.example .env.local

# Edit with your values
vim .env.local
```

> **Note**: `.env.local` is gitignored and should contain your personal/local values. Never commit this file.

## 🎯 Development Targets

### Webchat (`serve:webchat`)
- Develops the webchat interface
- Hot reload enabled
- React-based UI

### Webviews (`serve:webviews`)
- Develops custom webview interfaces
- Interactive forms and displays
- React-based UI

### Lambda (`serve:lambda`)
- Local Lambda development with SAM
- Simulates AWS Lambda environment
- Automatic rebuild on changes

## 🏗️ Build Process

The project uses **Vite** for fast building and development:

- **TypeScript**: Full type safety
- **Project References**: Optimized compilation
- **Tree Shaking**: Minimal bundle size
- **Hot Module Replacement**: Fast development

## 🔌 Adding Features

### New Action
1. Create action in `src/server/bot/actions/`
2. Add route in `src/server/bot/routes.ts`
3. Update locales if needed

### New Plugin
1. Install plugin: `pnpm install @botonic/plugin-xyz`
2. Add to `src/server/bot/plugins.ts`
3. Configure in bot config

### New Webview
1. Create component in `src/client/webviews/`
2. Add routing if needed
3. Style with CSS modules

## 📚 Learn More

- [Botonic Documentation](https://botonic.io/docs/)
- [Vite Documentation](https://vitejs.dev/)
- [TypeScript Project References](https://www.typescriptlang.org/docs/handbook/project-references.html)
- [Nx Documentation](https://nx.dev/)

## 🚀 Deployment

### AWS Lambda

```bash
# Build for Lambda
pnpm run build:node

# Deploy with SAM
cd src/server/lambda
sam build
sam deploy --guided
```

### Production Build

```bash
# Build all targets
pnpm run build

# The built files will be in:
# - dist/client/webchat/   (webchat interface)
# - dist/client/webviews/  (webview interfaces)
# - dist/server/           (Lambda function)
```
