File size: 6,312 Bytes
22ebc27
 
36a486d
561ef55
36a486d
22ebc27
36a486d
22ebc27
36a486d
22ebc27
36a486d
 
 
 
 
 
 
 
 
22ebc27
36a486d
 
22ebc27
 
36a486d
 
 
 
 
22ebc27
36a486d
 
 
 
 
 
22ebc27
36a486d
22ebc27
36a486d
 
 
22ebc27
36a486d
 
 
 
4afad64
36a486d
22ebc27
36a486d
22ebc27
36a486d
22ebc27
 
36a486d
 
 
 
22ebc27
36a486d
22ebc27
821422c
22ebc27
821422c
 
 
 
 
28721de
821422c
 
 
 
 
28721de
821422c
36a486d
821422c
 
 
 
28721de
 
821422c
 
 
 
28721de
821422c
 
 
 
28721de
821422c
28721de
821422c
28721de
36a486d
 
 
28721de
 
 
 
 
 
 
36a486d
28721de
36a486d
 
28721de
 
 
821422c
28721de
36a486d
 
28721de
 
 
821422c
28721de
821422c
28721de
36a486d
 
 
 
 
 
 
 
 
 
 
 
 
 
28721de
 
821422c
28721de
36a486d
 
28721de
 
821422c
28721de
36a486d
28721de
36a486d
 
 
28721de
 
36a486d
28721de
36a486d
 
 
 
28721de
 
36a486d
28721de
36a486d
28721de
 
36a486d
 
 
28721de
36a486d
 
 
 
3bfc394
 
36a486d
 
 
 
3bfc394
36a486d
 
 
 
3bfc394
36a486d
 
 
 
 
3bfc394
36a486d
3bfc394
36a486d
 
821422c
36a486d
 
 
 
 
 
 
 
3bfc394
36a486d
3bfc394
36a486d
 
3bfc394
36a486d
 
3bfc394
 
36a486d
 
 
 
 
 
 
 
 
 
 
 
3bfc394
36a486d
3bfc394
36a486d
 
3bfc394
36a486d
 
 
 
 
 
 
 
 
3bfc394
821422c
36a486d
 
3bfc394
 
36a486d
3bfc394
36a486d
 
 
 
 
3bfc394
36a486d
3bfc394
36a486d
 
 
821422c
36a486d
 
 
 
 
 
 
 
 
 
821422c
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# vBot Setup Guide

## Overview

This guide provides detailed instructions for setting up both the central vBot server and customer infrastructure. The system is designed with a distributed architecture where the central server handles only transcription and analysis, while customers maintain their own infrastructure.

## Central Server Setup

### 1. Deploy to Hugging Face Space

1. Create a Hugging Face account if you don't have one
2. Create a new Space:
   - Go to https://huggingface.co/spaces
   - Click "New Space"
   - Choose "Gradio" as the SDK
   - Set the Space name (e.g., "vBot")
   - Set visibility (public/private)

3. Clone the repository:
   ```bash
   git clone https://huggingface.co/spaces/iajitpanday/vBot
   cd vBot
   ```

4. Configure environment variables:
   ```bash
   cp .env.example .env
   # Edit .env with your configuration
   ```

5. Push to Hugging Face:
   ```bash
   git add .
   git commit -m "Initial deployment"
   git push
   ```

### 2. Configure Admin Account

1. Access the admin interface:
   - URL: `https://your-space.huggingface.space/admin`
   - Default credentials: admin/admin

2. Change admin password:
   - Click "Change Password"
   - Enter new secure password
   - Save changes

### 3. Test System Health

1. Check health endpoint:
   ```bash
   curl https://your-space.huggingface.space/health
   ```

2. Verify logs:
   ```bash
   tail -f logs/app.log
   ```

## Customer Infrastructure Setup

### 1. FreePBX Setup

1. Install FreePBX:
   - Download FreePBX 16 or higher
   - Follow the installation guide
   - Complete the setup wizard
   - Ensure all components are properly configured

2. Configure FreePBX:
   - Enable call recording in FreePBX Admin
   - Set up recording paths
   - Configure recording formats
   - Set up SSL certificates

3. Install the customer webhook package:
   ```bash
   git clone https://huggingface.co/spaces/iajitpanday/vBot
   cd vBot/customer_webhook
   composer install
   cp config/config.example.php config/config.php
   ```

4. Configure the webhook package:
   - Update `config/config.php` with FreePBX database details
   - Set the vBot API URL and your API key
   - Configure the webhook endpoint

5. Set up FreePBX integration:
   - Configure FreePBX to use the webhook endpoint
   - Set up recording post-processing
   - Configure SSL for secure communication

### 2. Database Setup

1. Create database:
   ```sql
   CREATE DATABASE vbot_calls;
   USE vbot_calls;
   
   CREATE TABLE call_records (
       id VARCHAR(36) PRIMARY KEY,
       customer_id INT NOT NULL,
       caller_number VARCHAR(20) NOT NULL,
       called_number VARCHAR(20) NOT NULL,
       transcription TEXT,
       summary TEXT,
       sentiment VARCHAR(50),
       keywords TEXT,
       created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
       updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
   );
   ```

2. Create database user:
   ```sql
   CREATE USER 'vbot_user'@'localhost' IDENTIFIED BY 'your_password';
   GRANT ALL PRIVILEGES ON vbot_calls.* TO 'vbot_user'@'localhost';
   FLUSH PRIVILEGES;
   ```

### 3. Webhook Handler Setup

1. Configure webhook handler:
   ```bash
   sudo cp /var/www/html/vbot-webhook/config/config.example.php /var/www/html/vbot-webhook/config/config.php
   sudo nano /var/www/html/vbot-webhook/config/config.php
   ```
   ```php
   <?php
   return [
       'db' => [
           'host' => 'localhost',
           'name' => 'vbot_calls',
           'user' => 'vbot_user',
           'pass' => 'your_password'
       ],
       'api_key' => 'your_api_key'
   ];
   ```

2. Set permissions:
   ```bash
   sudo chown -R www-data:www-data /var/www/html/vbot-webhook
   sudo chmod -R 755 /var/www/html/vbot-webhook
   ```

### 4. Testing Setup

1. Test webhook endpoint:
   ```bash
   curl -X POST https://your-domain.com/vbot-webhook/webhook.php \
     -H "Content-Type: application/json" \
     -d '{"test": true}'
   ```

2. Test call recording:
   ```bash
   # Make a test call
   # Check /tmp/calls/ for recording
   # Check webhook logs
   tail -f /var/log/apache2/vbot-access.log
   ```

3. Test database:
   ```sql
   SELECT * FROM call_records ORDER BY created_at DESC LIMIT 1;
   ```

## Security Considerations

1. Firewall Configuration:
   ```bash
   sudo ufw allow 80/tcp
   sudo ufw allow 443/tcp
   sudo ufw allow 5060/udp  # SIP
   sudo ufw allow 10000:20000/udp  # RTP
   ```

2. SSL/TLS:
   - Use Let's Encrypt for free SSL certificates
   - Configure automatic renewal
   - Use strong cipher suites

3. File Permissions:
   - Secure webhook handler files
   - Restrict access to call recordings
   - Use appropriate ownership

4. Database Security:
   - Use strong passwords
   - Limit database access
   - Regular backups
   - Encryption at rest

## Monitoring Setup

1. Log Monitoring:
   ```bash
   # FreePBX logs
   tail -f /var/log/asterisk/messages
   
   # Webhook logs
   tail -f /var/log/apache2/vbot-access.log
   
   # Database logs
   tail -f /var/log/mysql/error.log
   ```

2. System Monitoring:
   ```bash
   # Install monitoring tools
   sudo apt install prometheus node-exporter
   
   # Configure monitoring
   sudo nano /etc/prometheus/prometheus.yml
   ```

3. Alerting:
   - Set up email notifications
   - Configure alert thresholds
   - Monitor disk space

## Maintenance

1. Regular Tasks:
   - Update system packages
   - Rotate logs
   - Backup database
   - Clean old recordings

2. Backup Strategy:
   ```bash
   # Database backup
   mysqldump -u vbot_user -p vbot_calls > backup.sql
   
   # Configuration backup
   tar -czf config_backup.tar.gz /etc/asterisk/
   ```

3. Update Process:
   ```bash
   # Update webhook handler
   cd /var/www/html/vbot-webhook
   git pull
   
   # Update FreePBX
   sudo apt update
   sudo apt upgrade
   ```

## Troubleshooting

1. Common Issues:
   - Webhook delivery failures
   - Database connection errors
   - Call recording problems
   - SSL certificate issues

2. Debug Tools:
   ```bash
   # Check webhook logs
   tail -f /var/log/apache2/vbot-error.log
   
   # Check FreePBX CLI
   sudo asterisk -rx "core show version"
   
   # Test database connection
   mysql -u vbot_user -p vbot_calls
   ```

3. Support:
   - Check documentation
   - Review logs
   - Contact support
   - Submit issues