Ajit Panday commited on
Commit
22ebc27
·
1 Parent(s): 1be9f65

Add comprehensive setup guide

Browse files
Files changed (1) hide show
  1. SETUP_GUIDE.md +212 -0
SETUP_GUIDE.md ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # vBot Setup Guide
2
+
3
+ ## Step 1: Deploy to Hugging Face Spaces
4
+
5
+ 1. **Create Hugging Face Account**
6
+ - Go to https://huggingface.co/
7
+ - Sign up for a free account
8
+ - Verify your email
9
+
10
+ 2. **Deploy the Space**
11
+ - Visit https://huggingface.co/spaces/iajitpanday/vBot
12
+ - Click "Use this Space"
13
+ - Choose your deployment settings
14
+ - Wait for deployment to complete
15
+
16
+ 3. **Configure Environment Variables**
17
+ ```bash
18
+ # Generate a secure JWT secret
19
+ python3 -c "import secrets; print(secrets.token_urlsafe(32))"
20
+
21
+ # Set these in your Space settings
22
+ JWT_SECRET=<generated-secret>
23
+ ADMIN_USERNAME=your-admin-username
24
+ ADMIN_PASSWORD=your-secure-password
25
+ DATABASE_URL=mysql+pymysql://username:password@host:port/vbot_main
26
+ ```
27
+
28
+ ## Step 2: Set Up Main Database
29
+
30
+ 1. **Create MySQL Database**
31
+ - Sign up for a free MySQL hosting service:
32
+ - [PlanetScale](https://planetscale.com/) (Recommended)
33
+ - [Railway](https://railway.app/)
34
+ - [Clever Cloud](https://www.clever-cloud.com/)
35
+ - Create a new database named `vbot_main`
36
+ - Get your database connection URL
37
+
38
+ 2. **Verify Database Connection**
39
+ ```bash
40
+ # Test connection using the DATABASE_URL
41
+ mysql -h your-host -u your-user -p your-password
42
+ ```
43
+
44
+ ## Step 3: Admin Setup
45
+
46
+ 1. **Access Admin Dashboard**
47
+ - Go to your Space URL
48
+ - Navigate to `/api/v1/token`
49
+ - Login with your admin credentials
50
+ - Save the JWT token
51
+
52
+ 2. **Create First Customer**
53
+ ```bash
54
+ # POST /api/v1/customers/
55
+ {
56
+ "name": "John Doe",
57
+ "company_name": "ACME Corp",
58
+ "email": "john@acme.com",
59
+ "db_host": "customer-db-host",
60
+ "db_port": 3306,
61
+ "db_name": "acme_calls",
62
+ "db_user": "acme_user",
63
+ "db_password": "acme_password"
64
+ }
65
+ ```
66
+
67
+ 3. **Save Customer API Key**
68
+ - Note down the API key from the response
69
+ - Share it securely with the customer
70
+
71
+ ## Step 4: Customer Setup
72
+
73
+ 1. **Create Customer Database**
74
+ - Customer creates their own MySQL database
75
+ - Provides database credentials to admin
76
+ - Admin configures customer in the system
77
+
78
+ 2. **Configure Asterisk**
79
+ ```ini
80
+ # /etc/asterisk/dialplan/vbot.conf
81
+ [from-internal]
82
+ exten => _X.,1,Answer()
83
+ same => n,Set(CALLERID=${CALLERID(num)})
84
+ same => n,Set(CALLED=${EXTEN})
85
+ same => n,Record(/tmp/call-${UNIQUEID}.wav,0,30)
86
+ same => n,System(curl -X POST "https://your-huggingface-space-url/api/v1/process-call" \
87
+ -H "api-key: YOUR_API_KEY" \
88
+ -H "caller-number: ${CALLERID}" \
89
+ -H "called-number: ${CALLED}" \
90
+ -F "file=@/tmp/call-${UNIQUEID}.wav")
91
+ same => n,System(rm /tmp/call-${UNIQUEID}.wav)
92
+ same => n,Dial(SIP/${EXTEN})
93
+ same => n,Hangup()
94
+ ```
95
+
96
+ 3. **Update Asterisk Configuration**
97
+ ```bash
98
+ # Edit /etc/asterisk/extensions.conf
99
+ [general]
100
+ # Add this line
101
+ #include vbot.conf
102
+
103
+ # Reload Asterisk
104
+ asterisk -rx "dialplan reload"
105
+ ```
106
+
107
+ ## Step 5: Testing
108
+
109
+ 1. **Test API Connection**
110
+ ```bash
111
+ # Test customer API key
112
+ curl -X POST "https://your-huggingface-space-url/api/v1/process-call" \
113
+ -H "api-key: YOUR_API_KEY" \
114
+ -H "caller-number: +1234567890" \
115
+ -H "called-number: +0987654321" \
116
+ -F "file=@test.wav"
117
+ ```
118
+
119
+ 2. **Test Call Processing**
120
+ - Make a test call through Asterisk
121
+ - Check customer's database for results
122
+ - Verify transcription, summary, and sentiment
123
+
124
+ 3. **Monitor Logs**
125
+ ```bash
126
+ # Check Asterisk logs
127
+ tail -f /var/log/asterisk/messages
128
+
129
+ # Check Hugging Face Space logs
130
+ # View logs in Space settings
131
+ ```
132
+
133
+ ## Step 6: Production Deployment
134
+
135
+ 1. **Security Checklist**
136
+ - [ ] Use HTTPS only
137
+ - [ ] Set strong passwords
138
+ - [ ] Configure firewall rules
139
+ - [ ] Enable database encryption
140
+ - [ ] Regular backups
141
+
142
+ 2. **Performance Optimization**
143
+ - [ ] Configure database indexes
144
+ - [ ] Set up connection pooling
145
+ - [ ] Monitor resource usage
146
+ - [ ] Configure caching
147
+
148
+ 3. **Monitoring Setup**
149
+ - [ ] Set up error alerts
150
+ - [ ] Monitor API usage
151
+ - [ ] Track database performance
152
+ - [ ] Monitor disk space
153
+
154
+ ## Step 7: Maintenance
155
+
156
+ 1. **Regular Tasks**
157
+ - Monitor system resources
158
+ - Check error logs
159
+ - Update dependencies
160
+ - Backup databases
161
+
162
+ 2. **Customer Management**
163
+ - Review API usage
164
+ - Monitor database sizes
165
+ - Handle customer requests
166
+ - Update customer configurations
167
+
168
+ 3. **System Updates**
169
+ - Test updates in staging
170
+ - Plan maintenance windows
171
+ - Keep dependencies current
172
+ - Monitor security patches
173
+
174
+ ## Troubleshooting
175
+
176
+ 1. **Common Issues**
177
+ - API key invalid
178
+ - Database connection failed
179
+ - File processing errors
180
+ - Resource limits reached
181
+
182
+ 2. **Solutions**
183
+ - Check API key validity
184
+ - Verify database credentials
185
+ - Monitor file permissions
186
+ - Review resource quotas
187
+
188
+ 3. **Support**
189
+ - Check Space logs
190
+ - Review error messages
191
+ - Contact system administrator
192
+ - Consult documentation
193
+
194
+ ## Best Practices
195
+
196
+ 1. **Security**
197
+ - Rotate API keys regularly
198
+ - Use strong passwords
199
+ - Enable database encryption
200
+ - Monitor access logs
201
+
202
+ 2. **Performance**
203
+ - Optimize database queries
204
+ - Monitor resource usage
205
+ - Set up caching
206
+ - Configure connection pooling
207
+
208
+ 3. **Reliability**
209
+ - Regular backups
210
+ - Monitor system health
211
+ - Set up alerts
212
+ - Plan for failures