-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·83 lines (72 loc) · 2.22 KB
/
deploy.sh
File metadata and controls
executable file
·83 lines (72 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# ChatGPT WhatsApp Bot - Final Deployment Script
# This script helps validate and deploy the PHP chatbot
echo "🤖 ChatGPT WhatsApp Bot - Deployment Validation"
echo "================================================="
echo ""
# Check PHP version
echo "📋 Checking PHP requirements..."
PHP_VERSION=$(php -r "echo PHP_VERSION;")
echo "✓ PHP Version: $PHP_VERSION"
# Check if PHP version is 8.1+
if php -r "exit(version_compare(PHP_VERSION, '8.1.0', '<') ? 1 : 0);"; then
echo "❌ PHP 8.1+ is required. Current version: $PHP_VERSION"
exit 1
fi
# Check Composer
if ! command -v composer &> /dev/null; then
echo "❌ Composer is not installed"
echo " Install from: https://getcomposer.org/"
exit 1
fi
echo "✓ Composer is available"
# Check if dependencies are installed
if [ ! -d "vendor" ]; then
echo "📦 Installing dependencies..."
composer install
fi
echo "✓ Dependencies installed"
# Check environment file
if [ ! -f ".env" ]; then
echo "⚠️ No .env file found. Creating from example..."
cp .env.example .env
echo "📝 Please edit .env file with your API keys:"
echo " - API_KEY: Get from https://app.wassenger.com/developers/apikeys"
echo " - OPENAI_API_KEY: Get from https://platform.openai.com/account/api-keys"
echo " - NGROK_TOKEN: Get from https://ngrok.com/signup"
echo ""
fi
# Run configuration test
echo "🧪 Running configuration tests..."
php tests/config-test.php
if [ $? -ne 0 ]; then
echo "❌ Configuration test failed"
exit 1
fi
# Run API tests if keys are configured
echo ""
echo "🌐 Testing API connections..."
php tests/api-test.php
# Check webhook test
echo ""
echo "🔗 Testing webhook processing..."
php tests/webhook-test.php
if [ $? -ne 0 ]; then
echo "❌ Webhook test failed"
exit 1
fi
echo ""
echo "✅ All tests completed!"
echo ""
echo "🚀 Ready to deploy! Choose your deployment option:"
echo ""
echo "1. Development (with Ngrok tunnel):"
echo " composer run dev"
echo ""
echo "2. Production (set WEBHOOK_URL in .env first):"
echo " NODE_ENV=production php public/index.php"
echo ""
echo "3. With built-in PHP server:"
echo " php -S localhost:8080 -t public/"
echo ""
echo "📚 For more information, see README.md"