forked from getmaxun/maxun
-
Notifications
You must be signed in to change notification settings - Fork 0
Add Browser Automation for Chat Interfaces with API-based Workflows #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
codegen-sh
wants to merge
1
commit into
develop
Choose a base branch
from
codegen-bot/browser-automation-chat-integration-959ee7ef
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,320 @@ | ||
| #!/bin/bash | ||
|
|
||
| ############################################################################## | ||
| # Maxun Chat Automation Quick Deploy Script | ||
| ############################################################################## | ||
| # | ||
| # This script helps you quickly deploy Maxun for chat automation use cases. | ||
| # | ||
| # Usage: | ||
| # ./deploy_chat_automation.sh | ||
| # | ||
| ############################################################################## | ||
|
|
||
| set -e | ||
|
|
||
| # Colors | ||
| RED='\033[0;31m' | ||
| GREEN='\033[0;32m' | ||
| YELLOW='\033[1;33m' | ||
| BLUE='\033[0;34m' | ||
| NC='\033[0m' | ||
|
|
||
| # Print banner | ||
| print_banner() { | ||
| echo -e "${BLUE}" | ||
| cat << "EOF" | ||
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
| β β | ||
| β __ __ β | ||
| β | \/ | __ ___ ___ _ _ __ β | ||
| β | |\/| |/ _` \ \/ / | | | '_ \ β | ||
| β | | | | (_| |> <| |_| | | | | β | ||
| β |_| |_|\__,_/_/\_\\__,_|_| |_| β | ||
| β β | ||
| β Chat Automation Quick Deploy β | ||
| β β | ||
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
| EOF | ||
| echo -e "${NC}" | ||
| } | ||
|
|
||
| # Check dependencies | ||
| check_dependencies() { | ||
| echo -e "${BLUE}Checking dependencies...${NC}" | ||
|
|
||
| if ! command -v docker &> /dev/null; then | ||
| echo -e "${RED}β Docker is not installed${NC}" | ||
| echo "Please install Docker: https://docs.docker.com/get-docker/" | ||
| exit 1 | ||
| fi | ||
| echo -e "${GREEN}β Docker found${NC}" | ||
|
|
||
| if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then | ||
| echo -e "${RED}β Docker Compose is not installed${NC}" | ||
| echo "Please install Docker Compose: https://docs.docker.com/compose/install/" | ||
| exit 1 | ||
| fi | ||
| echo -e "${GREEN}β Docker Compose found${NC}" | ||
|
|
||
| if ! command -v openssl &> /dev/null; then | ||
| echo -e "${YELLOW}β OpenSSL not found (optional but recommended)${NC}" | ||
| else | ||
| echo -e "${GREEN}β OpenSSL found${NC}" | ||
| fi | ||
|
|
||
| echo "" | ||
| } | ||
|
|
||
| # Generate secure random string | ||
| generate_secret() { | ||
| if command -v openssl &> /dev/null; then | ||
| openssl rand -hex 32 | ||
| else | ||
| # Fallback if openssl not available | ||
| cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1 | ||
| fi | ||
| } | ||
|
|
||
| # Setup environment file | ||
| setup_env() { | ||
| echo -e "${BLUE}Setting up environment configuration...${NC}" | ||
|
|
||
| if [ -f .env ]; then | ||
| echo -e "${YELLOW}β .env file already exists${NC}" | ||
| read -p "Overwrite? (y/N): " -n 1 -r | ||
| echo | ||
| if [[ ! $REPLY =~ ^[Yy]$ ]]; then | ||
| echo -e "${YELLOW}Using existing .env file${NC}" | ||
| return | ||
| fi | ||
| fi | ||
|
|
||
| echo -e "${BLUE}Generating secure secrets...${NC}" | ||
|
|
||
| JWT_SECRET=$(generate_secret) | ||
| ENCRYPTION_KEY=$(generate_secret) | ||
| SESSION_SECRET=$(generate_secret) | ||
| MINIO_ACCESS=$(generate_secret | cut -c1-20) | ||
| MINIO_SECRET=$(generate_secret) | ||
|
|
||
| cat > .env << EOF | ||
| # Maxun Configuration - Auto-generated by deploy_chat_automation.sh | ||
| # Generated on: $(date) | ||
|
|
||
| # App Setup | ||
| NODE_ENV=production | ||
| JWT_SECRET=${JWT_SECRET} | ||
| ENCRYPTION_KEY=${ENCRYPTION_KEY} | ||
| SESSION_SECRET=${SESSION_SECRET} | ||
|
|
||
| # Database Configuration | ||
| DB_NAME=maxun | ||
| DB_USER=postgres | ||
| DB_PASSWORD=postgres | ||
| DB_HOST=postgres | ||
| DB_PORT=5432 | ||
|
|
||
| # MinIO Object Storage | ||
| MINIO_ENDPOINT=minio | ||
| MINIO_PORT=9000 | ||
| MINIO_CONSOLE_PORT=9001 | ||
| MINIO_ACCESS_KEY=${MINIO_ACCESS} | ||
| MINIO_SECRET_KEY=${MINIO_SECRET} | ||
|
|
||
| # Redis Configuration | ||
| REDIS_HOST=redis | ||
| REDIS_PORT=6379 | ||
| REDIS_PASSWORD= | ||
|
|
||
| # Backend and Frontend URLs and Ports | ||
| BACKEND_PORT=8080 | ||
| FRONTEND_PORT=5173 | ||
| BACKEND_URL=http://localhost:8080 | ||
| PUBLIC_URL=http://localhost:5173 | ||
| VITE_BACKEND_URL=http://localhost:8080 | ||
| VITE_PUBLIC_URL=http://localhost:5173 | ||
|
|
||
| # Optional: Google OAuth (for Google Sheets integration) | ||
| # GOOGLE_CLIENT_ID= | ||
| # GOOGLE_CLIENT_SECRET= | ||
| # GOOGLE_REDIRECT_URI= | ||
|
|
||
| # Optional: Airtable OAuth | ||
| # AIRTABLE_CLIENT_ID= | ||
| # AIRTABLE_REDIRECT_URI= | ||
|
|
||
| # Telemetry (helps improve Maxun) | ||
| MAXUN_TELEMETRY=true | ||
| EOF | ||
|
|
||
| echo -e "${GREEN}β Environment file created${NC}" | ||
| echo -e "${YELLOW}Note: Review .env file to customize settings if needed${NC}" | ||
| echo "" | ||
| } | ||
|
|
||
| # Pull and start services | ||
| start_services() { | ||
| echo -e "${BLUE}Starting Maxun services...${NC}" | ||
|
|
||
| echo -e "${YELLOW}Pulling latest Docker images...${NC}" | ||
| docker-compose pull | ||
|
|
||
| echo -e "${YELLOW}Starting containers...${NC}" | ||
| docker-compose up -d | ||
|
|
||
| echo -e "${GREEN}β Services started${NC}" | ||
| echo "" | ||
| } | ||
|
|
||
| # Wait for services to be ready | ||
| wait_for_services() { | ||
| echo -e "${BLUE}Waiting for services to be ready...${NC}" | ||
|
|
||
| local max_attempts=30 | ||
| local attempt=0 | ||
|
|
||
| while [ $attempt -lt $max_attempts ]; do | ||
| if curl -sf http://localhost:8080/health > /dev/null 2>&1; then | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Prompt for AI agents |
||
| echo -e "${GREEN}β Backend is ready${NC}" | ||
| break | ||
| fi | ||
|
|
||
| echo -e "${YELLOW}Waiting for backend... (attempt $((attempt + 1))/${max_attempts})${NC}" | ||
| sleep 2 | ||
| ((attempt++)) | ||
| done | ||
|
|
||
| if [ $attempt -eq $max_attempts ]; then | ||
| echo -e "${RED}β Backend failed to start${NC}" | ||
| echo -e "${YELLOW}Check logs with: docker-compose logs backend${NC}" | ||
| return 1 | ||
| fi | ||
|
|
||
| echo "" | ||
| } | ||
|
|
||
| # Print access information | ||
| print_access_info() { | ||
| echo -e "${GREEN}" | ||
| cat << "EOF" | ||
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
| β Deployment Complete! β | ||
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
| EOF | ||
| echo -e "${NC}" | ||
|
|
||
| echo -e "${BLUE}Access URLs:${NC}" | ||
| echo -e " β’ Frontend: ${GREEN}http://localhost:5173${NC}" | ||
| echo -e " β’ Backend API: ${GREEN}http://localhost:8080${NC}" | ||
| echo -e " β’ MinIO Console: ${GREEN}http://localhost:9001${NC}" | ||
| echo "" | ||
|
|
||
| echo -e "${BLUE}Next Steps:${NC}" | ||
| echo -e " 1. Open ${GREEN}http://localhost:5173${NC} in your browser" | ||
| echo -e " 2. Create an account" | ||
| echo -e " 3. Generate an API key in Settings β API Keys" | ||
| echo -e " 4. Create your first robot by recording a workflow" | ||
| echo -e " 5. Use the examples in ${GREEN}./examples/${NC} directory" | ||
| echo "" | ||
|
|
||
| echo -e "${BLUE}Quick Start Commands:${NC}" | ||
| echo -e " ${YELLOW}# View logs${NC}" | ||
| echo -e " docker-compose logs -f" | ||
| echo "" | ||
| echo -e " ${YELLOW}# Stop services${NC}" | ||
| echo -e " docker-compose down" | ||
| echo "" | ||
| echo -e " ${YELLOW}# Restart services${NC}" | ||
| echo -e " docker-compose restart" | ||
| echo "" | ||
| echo -e " ${YELLOW}# Run Python example${NC}" | ||
| echo -e " cd examples && python chat_automation_python.py" | ||
| echo "" | ||
| echo -e " ${YELLOW}# Run Node.js example${NC}" | ||
| echo -e " cd examples && node chat_automation_node.js" | ||
| echo "" | ||
|
|
||
| echo -e "${BLUE}Documentation:${NC}" | ||
| echo -e " β’ Full Guide: ${GREEN}./docs/BROWSER_AUTOMATION_CHAT.md${NC}" | ||
| echo -e " β’ Examples: ${GREEN}./examples/README.md${NC}" | ||
| echo -e " β’ Official Docs: ${GREEN}https://docs.maxun.dev${NC}" | ||
| echo "" | ||
|
|
||
| echo -e "${BLUE}Support:${NC}" | ||
| echo -e " β’ Discord: ${GREEN}https://discord.gg/5GbPjBUkws${NC}" | ||
| echo -e " β’ GitHub: ${GREEN}https://github.com/getmaxun/maxun${NC}" | ||
| echo "" | ||
| } | ||
|
|
||
| # Setup example environment | ||
| setup_examples() { | ||
| echo -e "${BLUE}Setting up examples...${NC}" | ||
|
|
||
| if [ ! -d examples ]; then | ||
| echo -e "${YELLOW}Examples directory not found${NC}" | ||
| return | ||
| fi | ||
|
|
||
| cd examples | ||
|
|
||
| if [ ! -f .env ]; then | ||
| cat > .env << 'EOF' | ||
| # Maxun API Configuration | ||
| MAXUN_API_URL=http://localhost:8080/api | ||
| MAXUN_API_KEY= | ||
| MAXUN_ROBOT_ID= | ||
|
|
||
| # Chat Interface Credentials | ||
| CHAT_USERNAME= | ||
| CHAT_PASSWORD= | ||
| EOF | ||
| echo -e "${GREEN}β Created examples/.env template${NC}" | ||
| echo -e "${YELLOW} Please edit examples/.env with your credentials${NC}" | ||
| else | ||
| echo -e "${YELLOW}examples/.env already exists${NC}" | ||
| fi | ||
|
|
||
| # Make bash script executable | ||
| if [ -f chat_automation_bash.sh ]; then | ||
| chmod +x chat_automation_bash.sh | ||
| echo -e "${GREEN}β Made bash script executable${NC}" | ||
| fi | ||
|
|
||
| cd .. | ||
| echo "" | ||
| } | ||
|
|
||
| # Main deployment function | ||
| main() { | ||
| print_banner | ||
|
|
||
| echo -e "${BLUE}This script will:${NC}" | ||
| echo " 1. Check for Docker and Docker Compose" | ||
| echo " 2. Generate secure configuration" | ||
| echo " 3. Start Maxun services" | ||
| echo " 4. Set up example scripts" | ||
| echo "" | ||
|
|
||
| read -p "Continue? (Y/n): " -n 1 -r | ||
| echo | ||
| if [[ $REPLY =~ ^[Nn]$ ]]; then | ||
| echo -e "${YELLOW}Deployment cancelled${NC}" | ||
| exit 0 | ||
| fi | ||
|
|
||
| check_dependencies | ||
| setup_env | ||
| start_services | ||
| wait_for_services || exit 1 | ||
| setup_examples | ||
| print_access_info | ||
|
|
||
| echo -e "${GREEN}βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}" | ||
| echo -e "${GREEN}β Happy Automating with Maxun! π β${NC}" | ||
| echo -e "${GREEN}βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}" | ||
| } | ||
|
|
||
| # Run main function | ||
| main "$@" | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script validates environments that only have the Docker Compose plugin, but later calls
docker-compose pull, which will fail when the plugin is the only available option. Please use a command that works for both cases (e.g., detect once and set a variable) before invoking pull/up.Prompt for AI agents