File size: 8,290 Bytes
1b8e418
 
 
 
 
 
 
 
 
 
 
3a6a328
1b8e418
821422c
36a486d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
821422c
3cb4e02
36a486d
 
 
1b8e418
 
 
36a486d
 
 
 
3a6a328
 
36a486d
3cb4e02
3a6a328
 
 
36a486d
3a6a328
3cb4e02
 
36a486d
 
3cb4e02
36a486d
3cb4e02
 
1b8e418
a0f9841
1b8e418
a0f9841
 
3a6a328
 
 
 
a0f9841
 
 
 
3a6a328
a0f9841
3cb4e02
 
 
 
 
 
3a6a328
a0f9841
 
3a6a328
 
3cb4e02
3a6a328
a0f9841
 
 
3a6a328
 
3cb4e02
 
a0f9841
3cb4e02
 
 
 
 
 
 
3a6a328
36a486d
3a6a328
 
 
 
 
36a486d
3a6a328
 
 
 
 
 
 
 
36a486d
3a6a328
 
36a486d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3a6a328
 
 
 
 
 
 
 
 
 
36a486d
3a6a328
 
 
36a486d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3a6a328
 
 
 
 
36a486d
 
 
3a6a328
 
36a486d
3a6a328
36a486d
 
 
dbb09da
1b8e418
 
3a6a328
 
 
 
dbb09da
 
 
3a6a328
 
 
 
 
 
 
 
 
 
 
1b8e418
3a6a328
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36a486d
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
---
title: vBot - AI-Powered Call Analysis
emoji: 📞
colorFrom: blue
colorTo: indigo
sdk: gradio
sdk_version: "4.19.2"
app_file: main.py
pinned: false
---

# vBot - Intelligent Call Analysis System

vBot is a distributed call analysis system where a central server ONLY handles AI-powered transcription and analysis, while each customer maintains their own complete infrastructure (FreePBX, database) and receives results via webhooks.

## System Architecture

### Central Server (vBot)
- ONLY handles call transcription and analysis
- ONLY manages customer accounts and API keys
- ONLY sends results via webhooks
- Hosted on Hugging Face Space
- Does NOT store customer data
- Does NOT connect to customer databases
- Does NOT manage customer infrastructure
- Does NOT store call recordings permanently

### Customer Infrastructure (Remote)
Each customer maintains their own complete system:
- FreePBX server (includes Asterisk, Apache web server, and database)
- MySQL database (included with FreePBX)
- SSL certificate for secure webhooks
- Complete control over their data and infrastructure
- Full ownership of their call recordings

## Features

- Centralized AI-powered call analysis
- Distributed customer infrastructure
- Secure customer isolation
- Real-time call processing
- Sentiment analysis and keyword extraction
- Modern admin interface for customer management
- Webhook-based result delivery
- Seamless FreePBX integration

## System Requirements

### Central Server (vBot)
- Python 3.8 or higher
- MySQL 5.7 or higher
- Hugging Face Space deployment

### Customer Infrastructure
- FreePBX 16 or higher
- PHP 7.4 or higher
- MySQL 5.7 or higher (included with FreePBX)
- SSL certificate for secure webhooks

## Quick Start

### Central Server (vBot)
1. Deploy to Hugging Face Space:
   ```bash
   git clone https://huggingface.co/spaces/iajitpanday/vBot
   ```

2. Configure environment variables in Hugging Face Space settings:
   - `DATABASE_URL`: Your MySQL database connection string
   - `SECRET_KEY`: A secure random string for JWT token generation
   - `API_BASE_URL`: The base URL of your vBot API

### Customer Setup
1. Install FreePBX:
   - Download and install FreePBX 16 or higher
   - Complete the FreePBX setup wizard
   - Ensure the system is properly configured

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

3. Install the customer webhook package:
   ```bash
   cd customer_webhook
   composer install
   cp config/config.example.php config/config.php
   ```

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

5. Configure FreePBX:
   - Enable call recording in FreePBX
   - Set up the recording path
   - Configure the webhook endpoint in FreePBX
   - Set up SSL for secure webhook communication

## Admin Setup (Central Server)

1. Access the admin interface:
   - URL: `https://your-domain.com/admin`
   - Default credentials: admin/admin (change immediately)

2. Create a new customer:
   - Click "Add Customer"
   - Fill in customer details:
     - Name
     - Company Name
     - Email
   - System will generate a unique API key

3. Configure customer webhook:
   - Customer provides their webhook URL
   - Optional: Set webhook secret for additional security

## Customer Setup

### 1. Asterisk Configuration
On your Asterisk server:
```ini
[from-internal]
exten => _X.,1,Answer()
same => n,Record(/tmp/calls/${UNIQUEID}.wav,0,0)
same => n,Set(CALL_ID=${UNIQUEID})
same => n,Set(CALLER=${CALLERID(num)})
same => n,Set(CALLED=${EXTEN})
same => n,AGI(agi://localhost:4573/process_call)
same => n,Hangup()
```

### 2. Download Webhook Handler
```bash
git clone https://huggingface.co/spaces/iajitpanday/vBot/customer_webhook
```

### 3. Deploy to Your Web Server
```bash
cp -r customer_webhook/* /var/www/html/vbot-webhook/
```

### 4. Create Database
On your MySQL server:
```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
);
```

### 5. Configure Webhook Handler
- Copy `config/config.example.php` to `config/config.php`
- Update database credentials
- Add your API key (provided by vBot admin)

### 6. Configure Web Server

#### Apache Configuration
```apache
# Place in Apache configuration or .htaccess
RewriteEngine On
RewriteBase /vbot-webhook/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ webhook.php [QSA,L]
```

#### Nginx Configuration
```nginx
location /vbot-webhook/ {
    root /var/www/html;
    index webhook.php;
    
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_index webhook.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}
```

## API Integration

### 1. Process a Call (from your Asterisk server)
```bash
curl -X POST https://vbot-server.com/api/process-call \
  -H "X-API-Key: your_api_key" \
  -H "Content-Type: multipart/form-data" \
  -F "file=@/tmp/calls/${UNIQUEID}.wav" \
  -H "caller_number=${CALLER}" \
  -H "called_number=${CALLED}"
```

### 2. Receive Webhook Data
Your webhook endpoint will receive POST requests with call analysis results:
```json
{
  "call_id": "uuid",
  "caller_number": "+1234567890",
  "called_number": "+0987654321",
  "transcription": "Call transcript...",
  "summary": "Call summary...",
  "sentiment": "positive",
  "keywords": "keyword1, keyword2",
  "timestamp": "2024-03-14T12:00:00Z",
  "customer_id": 123
}
```

## Security

1. API Authentication:
   - All API requests require valid API key
   - API keys are unique per customer
   - Keys can be regenerated if compromised

2. Webhook Security:
   - HTTPS required for webhook endpoints
   - Optional webhook secret for signature validation
   - Input validation and sanitization

3. Data Protection:
   - Call recordings are temporary on central server
   - Analysis results sent securely via webhooks
   - Each customer maintains their own database
   - Complete data isolation between customers
   - No shared infrastructure

## Monitoring

### Central Server (vBot)
- Application logs: `logs/app.log`
- Error logs: `logs/error.log`
- Access logs: `logs/access.log`
- Health endpoint: `/health`

### Customer Infrastructure
- Asterisk logs
- Webhook logs: `logs/webhook.log`
- Database monitoring
- Web server logs

## Troubleshooting

1. Common Issues:
   - Webhook delivery failures
   - API key validation errors
   - Database connection issues
   - Asterisk integration problems

2. Solutions:
   - Check webhook URL and SSL
   - Verify API key
   - Test database connection
   - Review Asterisk logs
   - Check webhook logs

## Support

For support:
- Email: support@vbot.com
- Documentation: https://vbot.com/docs
- GitHub Issues: https://github.com/vbot/issues

## License

This project is licensed under the MIT License - see the LICENSE file for details.

## Documentation

- [Setup Guide](SETUP_GUIDE.md) - Detailed setup instructions
- [User Manual](USER_MANUAL.md) - End-user documentation
- [API Documentation](API_DOCS.md) - API reference and examples

## Architecture

vBot follows a modern API-first architecture:

1. **Core Components**:
   - FastAPI backend
   - MySQL database
   - Hugging Face AI models
   - Asterisk integration

2. **Data Flow**:
   - Calls are received by Asterisk
   - Audio is processed by vBot
   - Results are stored and accessible via API
   - Customers access data through their API keys

3. **Security**:
   - JWT-based authentication for admin
   - API key authentication for customers
   - Secure data isolation between customers

## Contributing

1. Fork the repository
2. Create your feature branch
3. Commit your changes
4. Push to the branch
5. Create a Pull Request

## API Endpoints

### Admin Endpoints