forked from Trac-Systems/intercom
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
379 lines (329 loc) · 12 KB
/
index.html
File metadata and controls
379 lines (329 loc) · 12 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
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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TaskKeeper - Your AI Task Manager</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 800px;
margin: 0 auto;
}
.header {
text-align: center;
color: white;
margin-bottom: 30px;
}
.header h1 {
font-size: 2.5em;
margin-bottom: 10px;
text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}
.header p {
font-size: 1.1em;
opacity: 0.9;
}
.chat-container {
background: white;
border-radius: 20px;
box-shadow: 0 10px 40px rgba(0,0,0,0.2);
overflow: hidden;
display: flex;
flex-direction: column;
height: 600px;
}
.messages {
flex: 1;
overflow-y: auto;
padding: 20px;
display: flex;
flex-direction: column;
gap: 15px;
}
.message {
max-width: 80%;
padding: 12px 18px;
border-radius: 18px;
line-height: 1.4;
animation: slideIn 0.3s ease;
}
@keyframes slideIn {
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.message.user {
align-self: flex-end;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.message.assistant {
align-self: flex-start;
background: #f0f0f0;
color: #333;
}
.message.system {
align-self: center;
background: #e8f4f8;
color: #0066cc;
font-size: 0.9em;
max-width: 90%;
text-align: center;
}
.input-area {
padding: 20px;
background: #f8f9fa;
border-top: 1px solid #e0e0e0;
display: flex;
gap: 10px;
}
.input-area input {
flex: 1;
padding: 12px 18px;
border: 2px solid #e0e0e0;
border-radius: 25px;
font-size: 1em;
outline: none;
transition: border-color 0.3s;
}
.input-area input:focus {
border-color: #667eea;
}
.input-area button {
padding: 12px 30px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 25px;
font-size: 1em;
cursor: pointer;
transition: transform 0.2s, box-shadow 0.2s;
font-weight: 600;
}
.input-area button:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}
.input-area button:active {
transform: translateY(0);
}
.input-area button:disabled {
opacity: 0.6;
cursor: not-allowed;
transform: none;
}
.task-card {
background: white;
border-left: 4px solid #667eea;
padding: 10px;
margin: 5px 0;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.task-card strong {
color: #667eea;
}
.loading {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
background: #667eea;
animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
0%, 100% { opacity: 0.3; transform: scale(0.8); }
50% { opacity: 1; transform: scale(1.2); }
}
.quick-actions {
display: flex;
gap: 10px;
padding: 15px 20px;
background: white;
border-bottom: 1px solid #e0e0e0;
overflow-x: auto;
}
.quick-action {
padding: 8px 16px;
background: #f0f0f0;
border: none;
border-radius: 20px;
cursor: pointer;
white-space: nowrap;
font-size: 0.9em;
transition: all 0.2s;
}
.quick-action:hover {
background: #667eea;
color: white;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🎯 TaskKeeper</h1>
<p>Your AI-powered task manager with Claude</p>
</div>
<div class="chat-container">
<div class="quick-actions">
<button class="quick-action" onclick="sendQuickMessage('Show my tasks for today')">📋 Today's Tasks</button>
<button class="quick-action" onclick="sendQuickMessage('What do I have coming up this week?')">📅 This Week</button>
<button class="quick-action" onclick="sendQuickMessage('Add a reminder to call mom tomorrow at 2pm')">⏰ Add Reminder</button>
<button class="quick-action" onclick="sendQuickMessage('Create a task to review project proposal')">✅ New Task</button>
</div>
<div class="messages" id="messages">
<div class="message system">
👋 Welcome! I'm your AI task manager. I can help you:
<br><br>
• Create and manage tasks
<br>• Set reminders and alarms
<br>• View your calendar
<br>• Plan your day or week
<br><br>
Just tell me what you need!
</div>
</div>
<div class="input-area">
<input
type="text"
id="userInput"
placeholder="Ask me to add a task, set a reminder, or check your schedule..."
onkeypress="if(event.key==='Enter') sendMessage()"
/>
<button onclick="sendMessage()" id="sendBtn">Send</button>
</div>
</div>
</div>
<script>
const API_URL = 'https://api.anthropic.com/v1/messages';
const conversationHistory = [];
function addMessage(content, type) {
const messagesDiv = document.getElementById('messages');
const messageDiv = document.createElement('div');
messageDiv.className = `message ${type}`;
messageDiv.innerHTML = content;
messagesDiv.appendChild(messageDiv);
messagesDiv.scrollTop = messagesDiv.scrollHeight;
}
function sendQuickMessage(message) {
document.getElementById('userInput').value = message;
sendMessage();
}
async function sendMessage() {
const input = document.getElementById('userInput');
const sendBtn = document.getElementById('sendBtn');
const message = input.value.trim();
if (!message) return;
// Add user message to UI
addMessage(message, 'user');
input.value = '';
sendBtn.disabled = true;
// Add loading indicator
addMessage('<span class="loading"></span> <span class="loading"></span> <span class="loading"></span>', 'assistant');
// Add to conversation history
conversationHistory.push({
role: 'user',
content: message
});
try {
const response = await fetch(API_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'claude-sonnet-4-20250514',
max_tokens: 1000,
system: `You are TaskKeeper, a helpful AI assistant integrated into a personal task management app. You help users:
1. Create and manage tasks and to-do items
2. Set reminders and alarms using the alarm_create_v0 tool
3. Create calendar events using the event_create_v1 tool
4. View upcoming events using event_search_v0
5. Get current time using user_time_v0
6. Create timers using timer_create_v0
When users ask to add tasks or reminders:
- Use alarm_create_v0 for recurring daily reminders (medications, wake-up times, etc.)
- Use event_create_v1 for scheduled events with dates
- Use timer_create_v0 for countdown timers
- Always check current time first with user_time_v0 to understand context
Be conversational, helpful, and proactive. When you create something, confirm it clearly. Present task information in an organized, easy-to-read format with emojis for visual appeal.
For calendar queries, always use event_search_v0 to get actual events rather than making assumptions.`,
messages: conversationHistory,
tools: [
{
"type": "alarm_create_v0",
"name": "alarm_create_v0"
},
{
"type": "event_create_v1",
"name": "event_create_v1"
},
{
"type": "event_search_v0",
"name": "event_search_v0"
},
{
"type": "user_time_v0",
"name": "user_time_v0"
},
{
"type": "timer_create_v0",
"name": "timer_create_v0"
}
]
})
});
const data = await response.json();
// Remove loading indicator
const messages = document.getElementById('messages');
messages.removeChild(messages.lastChild);
// Extract text response
let assistantMessage = '';
if (data.content) {
for (const block of data.content) {
if (block.type === 'text') {
assistantMessage += block.text;
}
}
}
if (assistantMessage) {
addMessage(assistantMessage, 'assistant');
conversationHistory.push({
role: 'assistant',
content: data.content
});
} else {
addMessage('I created that for you! ✅', 'assistant');
}
} catch (error) {
// Remove loading indicator
const messages = document.getElementById('messages');
messages.removeChild(messages.lastChild);
addMessage(`Sorry, I encountered an error: ${error.message}. Please try again.`, 'system');
conversationHistory.pop(); // Remove the failed user message
}
sendBtn.disabled = false;
input.focus();
}
// Focus input on load
document.getElementById('userInput').focus();
</script>
</body>
</html>