Update chat.html
Browse files
chat.html
CHANGED
|
@@ -545,6 +545,98 @@
|
|
| 545 |
|
| 546 |
/* Hidden file input */
|
| 547 |
#imageInput { display: none; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 548 |
</style>
|
| 549 |
</head>
|
| 550 |
<body>
|
|
@@ -762,16 +854,13 @@
|
|
| 762 |
/* ββ Add message to DOM ββ */
|
| 763 |
function addMessage(role, text, images = []) {
|
| 764 |
msgCount++;
|
| 765 |
-
const msgs
|
| 766 |
-
const isUser
|
| 767 |
-
const row
|
| 768 |
row.className = `msg-row ${isUser ? 'user' : ''}`;
|
| 769 |
|
| 770 |
-
const initials = isUser
|
| 771 |
-
|
| 772 |
-
: 'NA';
|
| 773 |
-
|
| 774 |
-
const now = new Date();
|
| 775 |
const time = now.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
| 776 |
|
| 777 |
let imagesHtml = '';
|
|
@@ -781,19 +870,32 @@
|
|
| 781 |
).join('');
|
| 782 |
}
|
| 783 |
|
| 784 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 785 |
const confidentialBadge = isConfidential
|
| 786 |
-
? `<span class="conf-badge">β Confidential info not disclosed</span>`
|
| 787 |
-
: '';
|
| 788 |
|
| 789 |
row.innerHTML = `
|
| 790 |
<div class="msg-avatar ${isUser ? 'user-av' : 'bot'}">${initials}</div>
|
| 791 |
<div class="msg-content">
|
| 792 |
<span class="msg-sender">${isUser ? 'You' : 'New Age AI'}</span>
|
| 793 |
<div class="bubble ${isUser ? 'user' : 'bot'}">
|
| 794 |
-
${
|
| 795 |
${imagesHtml}
|
| 796 |
</div>
|
|
|
|
| 797 |
${confidentialBadge}
|
| 798 |
<span class="msg-time">${time}</span>
|
| 799 |
</div>
|
|
@@ -803,6 +905,51 @@
|
|
| 803 |
msgs.scrollTop = msgs.scrollHeight;
|
| 804 |
}
|
| 805 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 806 |
/* ββ Typing indicator ββ */
|
| 807 |
function showTyping() {
|
| 808 |
isTyping = true;
|
|
@@ -873,34 +1020,72 @@
|
|
| 873 |
}
|
| 874 |
|
| 875 |
/* ββββββββββββββββββββββββββββββββββββββββββββββ
|
| 876 |
-
|
| 877 |
-
|
| 878 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 879 |
ββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 880 |
-
// βββββββββββββββββββββββββββββββββββββββββββ
|
| 881 |
-
// GROQ API KEYS β Auto failover system
|
| 882 |
-
// Add more keys below if needed
|
| 883 |
-
// βββββββββββββββββββββββββββββββββββββββββββ
|
| 884 |
const GROQ_API_KEYS = [
|
| 885 |
'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',
|
| 886 |
'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',
|
| 887 |
'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'
|
| 888 |
];
|
| 889 |
let currentKeyIndex = 0;
|
| 890 |
-
const chatHistory = [];
|
| 891 |
-
const messageCache = {};
|
| 892 |
|
| 893 |
async function callGroqAPI(userText, images = []) {
|
| 894 |
try {
|
| 895 |
-
// Build user message content
|
| 896 |
let userContent = userText || '';
|
| 897 |
-
if (images.length > 0) {
|
| 898 |
-
|
| 899 |
-
|
| 900 |
-
|
| 901 |
-
|
|
|
|
|
|
|
| 902 |
|
| 903 |
-
// Add user message to history
|
| 904 |
chatHistory.push({ role: 'user', content: userContent });
|
| 905 |
|
| 906 |
const response = await fetch('https://api.groq.com/openai/v1/chat/completions', {
|
|
@@ -911,68 +1096,73 @@
|
|
| 911 |
},
|
| 912 |
body: JSON.stringify({
|
| 913 |
model: 'llama-3.1-8b-instant',
|
| 914 |
-
max_tokens:
|
| 915 |
messages: [
|
| 916 |
{
|
| 917 |
role: 'system',
|
| 918 |
-
content: `You are
|
| 919 |
|
| 920 |
==============================
|
| 921 |
-
|
| 922 |
==============================
|
| 923 |
-
|
| 924 |
-
ABOUT NEW AGE:
|
| 925 |
-
- Full name: Invento One Private Limited
|
| 926 |
- Brand name: New Age
|
| 927 |
- Website: newage4.com
|
| 928 |
-
-
|
| 929 |
-
-
|
| 930 |
-
-
|
| 931 |
-
-
|
| 932 |
-
-
|
| 933 |
-
-
|
| 934 |
-
|
| 935 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 936 |
|
| 937 |
DIVISIONS:
|
| 938 |
-
|
| 939 |
-
|
| 940 |
-
2. Services Division β AI and Mobile App Development services for clients
|
| 941 |
|
| 942 |
-
PRODUCTS:
|
| 943 |
-
- New Age AI: AI-powered workflow automation suite
|
| 944 |
- Cadabra: Supercharges Monday.com workflows with AI (ChatGPT integration)
|
| 945 |
-
- iGrammar: Chrome extension β personal writing assistant
|
| 946 |
-
- New Age Slack Bot: AI automation for Slack
|
| 947 |
-
-
|
| 948 |
-
- Android Apps: Various apps on Google Play Store
|
| 949 |
-
|
| 950 |
-
CONTACT INFORMATION:
|
| 951 |
-
- Phone: +91 81600 78511
|
| 952 |
-
- WhatsApp: +91 81600 78511
|
| 953 |
-
- Office address: B10, MBH, Sarthana, Surat
|
| 954 |
-
- General inquiries email: contact@newage4.com
|
| 955 |
-
- HR and recruitment email: hr@newage4.com
|
| 956 |
-
- LinkedIn: linkedin.com/company/new-age-ai-products-and-services
|
| 957 |
|
| 958 |
-
|
| 959 |
-
|
| 960 |
-
|
| 961 |
-
-
|
| 962 |
-
-
|
| 963 |
-
-
|
| 964 |
-
-
|
|
|
|
|
|
|
|
|
|
| 965 |
|
| 966 |
-
|
| 967 |
-
|
| 968 |
-
|
| 969 |
-
-
|
| 970 |
-
-
|
|
|
|
|
|
|
|
|
|
| 971 |
|
| 972 |
-
|
| 973 |
-
|
|
|
|
|
|
|
| 974 |
|
| 975 |
-
|
|
|
|
|
|
|
| 976 |
1. User First Approach
|
| 977 |
2. Honest and Constructive Communication
|
| 978 |
3. Constant Improvement
|
|
@@ -982,23 +1172,48 @@ CORE VALUES:
|
|
| 982 |
7. People First
|
| 983 |
8. Purpose with Passion
|
| 984 |
|
| 985 |
-
|
| 986 |
-
|
| 987 |
-
|
| 988 |
-
|
| 989 |
-
|
| 990 |
-
-
|
| 991 |
-
|
| 992 |
-
|
| 993 |
-
|
| 994 |
-
|
| 995 |
-
|
| 996 |
-
|
| 997 |
-
|
| 998 |
-
|
| 999 |
-
|
| 1000 |
-
|
| 1001 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1002 |
},
|
| 1003 |
...chatHistory
|
| 1004 |
]
|
|
@@ -1006,24 +1221,22 @@ IMPORTANT RULES β ALWAYS FOLLOW
|
|
| 1006 |
});
|
| 1007 |
|
| 1008 |
const data = await response.json();
|
| 1009 |
-
|
| 1010 |
if (!response.ok) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1011 |
throw new Error(data.error?.message || 'Something went wrong with AI');
|
| 1012 |
}
|
| 1013 |
|
| 1014 |
const reply = data.choices[0].message.content;
|
| 1015 |
-
|
| 1016 |
-
// Add assistant reply to history (for conversation context)
|
| 1017 |
chatHistory.push({ role: 'assistant', content: reply });
|
| 1018 |
-
|
| 1019 |
-
// Keep history to last 20 messages to avoid token limit
|
| 1020 |
if (chatHistory.length > 20) chatHistory.splice(0, 2);
|
| 1021 |
|
| 1022 |
hideTyping();
|
| 1023 |
-
// Store in cache
|
| 1024 |
if (chatHistory.length > 0) {
|
| 1025 |
-
const
|
| 1026 |
-
if (
|
| 1027 |
}
|
| 1028 |
addMessage('bot', reply);
|
| 1029 |
|
|
|
|
| 545 |
|
| 546 |
/* Hidden file input */
|
| 547 |
#imageInput { display: none; }
|
| 548 |
+
|
| 549 |
+
/* ββ NAR Suggestion Card ββ */
|
| 550 |
+
.nar-card {
|
| 551 |
+
margin-top: 10px;
|
| 552 |
+
background: linear-gradient(135deg, rgba(10,15,40,0.95) 0%, rgba(10,15,55,0.92) 100%);
|
| 553 |
+
backdrop-filter: blur(16px);
|
| 554 |
+
border: 1px solid rgba(99,130,255,0.3);
|
| 555 |
+
box-shadow: 0 0 20px rgba(0,66,234,0.15), 0 8px 32px rgba(0,0,0,0.35);
|
| 556 |
+
border-radius: 14px;
|
| 557 |
+
padding: 16px 18px;
|
| 558 |
+
max-width: 400px;
|
| 559 |
+
animation: fadeUp 0.3s ease both;
|
| 560 |
+
position: relative;
|
| 561 |
+
overflow: hidden;
|
| 562 |
+
}
|
| 563 |
+
.nar-card::before {
|
| 564 |
+
content: '';
|
| 565 |
+
position: absolute;
|
| 566 |
+
top: 0; left: 0; right: 0; height: 1px;
|
| 567 |
+
background: linear-gradient(90deg, transparent, rgba(99,130,255,0.5), transparent);
|
| 568 |
+
}
|
| 569 |
+
.nar-badge {
|
| 570 |
+
display: inline-flex;
|
| 571 |
+
align-items: center;
|
| 572 |
+
gap: 6px;
|
| 573 |
+
background: rgba(99,130,255,0.12);
|
| 574 |
+
border: 1px solid rgba(99,130,255,0.3);
|
| 575 |
+
border-radius: 99px;
|
| 576 |
+
padding: 3px 10px;
|
| 577 |
+
font-size: 0.6875rem;
|
| 578 |
+
font-weight: 700;
|
| 579 |
+
color: #818cf8;
|
| 580 |
+
letter-spacing: 0.05em;
|
| 581 |
+
text-transform: uppercase;
|
| 582 |
+
margin-bottom: 10px;
|
| 583 |
+
}
|
| 584 |
+
.nar-pulse {
|
| 585 |
+
width: 6px; height: 6px;
|
| 586 |
+
background: #818cf8; border-radius: 50%;
|
| 587 |
+
animation: pulse-dot 1.5s ease-in-out infinite;
|
| 588 |
+
}
|
| 589 |
+
@keyframes pulse-dot {
|
| 590 |
+
0%,100% { opacity:1; transform:scale(1); }
|
| 591 |
+
50% { opacity:0.4; transform:scale(0.65); }
|
| 592 |
+
}
|
| 593 |
+
.nar-title {
|
| 594 |
+
font-size: 1rem; font-weight: 700;
|
| 595 |
+
color: #f1f5f9; margin-bottom: 6px; line-height: 1.3;
|
| 596 |
+
}
|
| 597 |
+
.nar-cat {
|
| 598 |
+
display: inline-block;
|
| 599 |
+
font-size: 0.6875rem; font-weight: 600;
|
| 600 |
+
padding: 2px 8px; border-radius: 4px;
|
| 601 |
+
margin-bottom: 10px;
|
| 602 |
+
}
|
| 603 |
+
.nar-reason {
|
| 604 |
+
font-size: 0.8125rem; color: #94a3b8; line-height: 1.55;
|
| 605 |
+
margin-bottom: 14px; padding: 8px 10px;
|
| 606 |
+
background: rgba(255,255,255,0.04);
|
| 607 |
+
border-left: 2px solid rgba(99,130,255,0.4);
|
| 608 |
+
border-radius: 0 6px 6px 0;
|
| 609 |
+
}
|
| 610 |
+
.nar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
|
| 611 |
+
.nar-btn-primary {
|
| 612 |
+
padding: 8px 16px; background: #0042EA; color: #fff;
|
| 613 |
+
border: none; border-radius: 8px;
|
| 614 |
+
font-family: 'DM Sans', sans-serif; font-size: 0.8125rem; font-weight: 600;
|
| 615 |
+
cursor: pointer; transition: background 0.2s, transform 0.15s;
|
| 616 |
+
box-shadow: 0 2px 10px rgba(0,66,234,0.4);
|
| 617 |
+
}
|
| 618 |
+
.nar-btn-primary:hover { background: #0037C1; transform: translateY(-1px); }
|
| 619 |
+
.nar-btn-ghost {
|
| 620 |
+
padding: 8px 14px;
|
| 621 |
+
background: rgba(255,255,255,0.05); color: #94a3b8;
|
| 622 |
+
border: 1px solid rgba(255,255,255,0.1); border-radius: 8px;
|
| 623 |
+
font-family: 'DM Sans', sans-serif; font-size: 0.8125rem;
|
| 624 |
+
cursor: pointer; transition: background 0.2s, color 0.2s;
|
| 625 |
+
}
|
| 626 |
+
.nar-btn-ghost:hover { background: rgba(255,255,255,0.1); color: #cbd5e1; }
|
| 627 |
+
.nar-alts {
|
| 628 |
+
display: none; flex-direction: column; gap: 6px; margin-top: 10px;
|
| 629 |
+
}
|
| 630 |
+
.nar-alts.open { display: flex; }
|
| 631 |
+
.nar-alt-item {
|
| 632 |
+
display: flex; align-items: center; justify-content: space-between;
|
| 633 |
+
padding: 8px 12px;
|
| 634 |
+
background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08);
|
| 635 |
+
border-radius: 8px; cursor: pointer; transition: background 0.15s;
|
| 636 |
+
}
|
| 637 |
+
.nar-alt-item:hover { background: rgba(99,130,255,0.1); border-color: rgba(99,130,255,0.25); }
|
| 638 |
+
.nar-alt-name { font-size: 0.8125rem; color: #cbd5e1; font-weight: 500; }
|
| 639 |
+
.nar-alt-cat { font-size: 0.6875rem; color: #475569; }
|
| 640 |
</style>
|
| 641 |
</head>
|
| 642 |
<body>
|
|
|
|
| 854 |
/* ββ Add message to DOM ββ */
|
| 855 |
function addMessage(role, text, images = []) {
|
| 856 |
msgCount++;
|
| 857 |
+
const msgs = document.getElementById('messages');
|
| 858 |
+
const isUser = role === 'user';
|
| 859 |
+
const row = document.createElement('div');
|
| 860 |
row.className = `msg-row ${isUser ? 'user' : ''}`;
|
| 861 |
|
| 862 |
+
const initials = isUser ? (document.getElementById('userAvatar').textContent || 'U') : 'NA';
|
| 863 |
+
const now = new Date();
|
|
|
|
|
|
|
|
|
|
| 864 |
const time = now.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
| 865 |
|
| 866 |
let imagesHtml = '';
|
|
|
|
| 870 |
).join('');
|
| 871 |
}
|
| 872 |
|
| 873 |
+
// Parse NAR suggestion block out of bot reply
|
| 874 |
+
let narCardHtml = '';
|
| 875 |
+
let cleanText = text;
|
| 876 |
+
if (!isUser) {
|
| 877 |
+
const m = text.match(/:::nar-suggestion\s*(\{[\s\S]*?\})\s*:::/);
|
| 878 |
+
if (m) {
|
| 879 |
+
try {
|
| 880 |
+
narCardHtml = buildNarCard(JSON.parse(m[1]));
|
| 881 |
+
cleanText = text.replace(/:::nar-suggestion[\s\S]*?:::/, '').trim();
|
| 882 |
+
} catch(e) { /* keep raw text if JSON broken */ }
|
| 883 |
+
}
|
| 884 |
+
}
|
| 885 |
+
|
| 886 |
+
const isConfidential = !isUser && /salary|revenue|profit|confidential/i.test(cleanText);
|
| 887 |
const confidentialBadge = isConfidential
|
| 888 |
+
? `<span class="conf-badge">β Confidential info not disclosed</span>` : '';
|
|
|
|
| 889 |
|
| 890 |
row.innerHTML = `
|
| 891 |
<div class="msg-avatar ${isUser ? 'user-av' : 'bot'}">${initials}</div>
|
| 892 |
<div class="msg-content">
|
| 893 |
<span class="msg-sender">${isUser ? 'You' : 'New Age AI'}</span>
|
| 894 |
<div class="bubble ${isUser ? 'user' : 'bot'}">
|
| 895 |
+
${(cleanText && !narCardHtml) ? `<span>${escHtml(cleanText)}</span>` : (cleanText && narCardHtml) ? `<span>${escHtml(cleanText.split('\n')[0])}</span>` : ''}
|
| 896 |
${imagesHtml}
|
| 897 |
</div>
|
| 898 |
+
${narCardHtml}
|
| 899 |
${confidentialBadge}
|
| 900 |
<span class="msg-time">${time}</span>
|
| 901 |
</div>
|
|
|
|
| 905 |
msgs.scrollTop = msgs.scrollHeight;
|
| 906 |
}
|
| 907 |
|
| 908 |
+
/* ββ Build NAR card HTML ββ */
|
| 909 |
+
function buildNarCard(data) {
|
| 910 |
+
const catColors = { IT:'#06b6d4', HR:'#a78bfa', Finance:'#34d399', General:'#94a3b8', Legal:'#fb923c', Growth:'#f472b6', Ops:'#facc15', Management:'#818cf8' };
|
| 911 |
+
const c = catColors[data.category] || '#818cf8';
|
| 912 |
+
const uid = 'nar_' + Date.now() + '_' + Math.random().toString(36).slice(2,6);
|
| 913 |
+
const MONDAY_BOARD_URL = 'https://new-age1.monday.com/boards/9934117905/views/210975370';
|
| 914 |
+
const altsHtml = (data.alternatives||[]).map(a =>
|
| 915 |
+
`<div class="nar-alt-item" onclick='adoptNar(${JSON.stringify(a).replace(/'/g,"'")})'>
|
| 916 |
+
<span class="nar-alt-name">${a.title}</span>
|
| 917 |
+
<span class="nar-alt-cat">${a.category}</span>
|
| 918 |
+
</div>`
|
| 919 |
+
).join('');
|
| 920 |
+
return `
|
| 921 |
+
<div class="nar-card">
|
| 922 |
+
<div class="nar-badge"><span class="nar-pulse"></span>π― Suggested NAR</div>
|
| 923 |
+
<div class="nar-title">${data.title}</div>
|
| 924 |
+
<div class="nar-cat" style="color:${c};background:${c}18;border:1px solid ${c}30">${data.category}</div>
|
| 925 |
+
<div class="nar-reason">${data.reason}</div>
|
| 926 |
+
${data.fields_guide ? `<div class="nar-reason" style="margin-top:-6px; font-size:0.78rem; color:#64748b; line-height:1.6;">
|
| 927 |
+
π <strong style="color:#94a3b8; font-size:0.78rem;">How to fill:</strong><br>${data.fields_guide}
|
| 928 |
+
</div>` : ''}
|
| 929 |
+
<div class="nar-actions">
|
| 930 |
+
<button class="nar-btn-primary" onclick="window.open('${MONDAY_BOARD_URL}','_blank')">Open NAR Board β</button>
|
| 931 |
+
${altsHtml ? `<button class="nar-btn-ghost" onclick="this.textContent=this.textContent.includes('Show')?'β² Hide others':'βΌ Show others';document.getElementById('${uid}').classList.toggle('open')">βΌ Show others</button>` : ''}
|
| 932 |
+
</div>
|
| 933 |
+
<div class="nar-alts" id="${uid}">${altsHtml}</div>
|
| 934 |
+
</div>`;
|
| 935 |
+
}
|
| 936 |
+
|
| 937 |
+
/* ββ Adopt an alternative NAR into a new card ββ */
|
| 938 |
+
function adoptNar(alt) {
|
| 939 |
+
const msgs = document.getElementById('messages');
|
| 940 |
+
const div = document.createElement('div');
|
| 941 |
+
div.className = 'msg-row';
|
| 942 |
+
div.innerHTML = `
|
| 943 |
+
<div class="msg-avatar bot">NA</div>
|
| 944 |
+
<div class="msg-content">
|
| 945 |
+
<span class="msg-sender">New Age AI</span>
|
| 946 |
+
${buildNarCard({...alt, reason:'You selected this as an alternative.', alternatives:[]})}
|
| 947 |
+
<span class="msg-time">${new Date().toLocaleTimeString([],{hour:'2-digit',minute:'2-digit'})}</span>
|
| 948 |
+
</div>`;
|
| 949 |
+
msgs.appendChild(div);
|
| 950 |
+
msgs.scrollTop = msgs.scrollHeight;
|
| 951 |
+
}
|
| 952 |
+
|
| 953 |
/* ββ Typing indicator ββ */
|
| 954 |
function showTyping() {
|
| 955 |
isTyping = true;
|
|
|
|
| 1020 |
}
|
| 1021 |
|
| 1022 |
/* ββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1023 |
+
NAR DATABASE β all 28 request types
|
| 1024 |
+
ββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 1025 |
+
const NAR_TYPES = [
|
| 1026 |
+
{ id:1, title:'General Requests', category:'General', keywords:['general','misc','other','help','info'] },
|
| 1027 |
+
{ id:2, title:'Access Request', category:'IT', keywords:['access','permission','login','account','tool','software','system','monday','slack','drive','github','credentials'] },
|
| 1028 |
+
{ id:3, title:'Leave Request', category:'HR', keywords:['leave','vacation','time off','holiday','sick','absence','pto','break'] },
|
| 1029 |
+
{ id:4, title:'Purchase Request', category:'Finance', keywords:['buy','purchase','order','laptop','monitor','hardware','equipment','device','phone','keyboard','mouse','screen'] },
|
| 1030 |
+
{ id:5, title:'Payment Request', category:'Finance', keywords:['payment','pay','invoice','reimbursement','expense','reimburse','refund','bill','money'] },
|
| 1031 |
+
{ id:6, title:'Contract Change', category:'Legal', keywords:['contract','agreement','change','modify','update','terms','scope','role','rate','hours'] },
|
| 1032 |
+
{ id:7, title:'Billing / Subscription Concern', category:'Finance', keywords:['billing','subscription','charge','overcharge','plan','renewal','pricing','overage'] },
|
| 1033 |
+
{ id:8, title:'Subscription Cancellation Request', category:'Finance', keywords:['cancel','cancellation','unsubscribe','stop subscription','terminate plan'] },
|
| 1034 |
+
{ id:9, title:'Data Report Blocker', category:'Ops', keywords:['report blocked','data stuck','blocker','report issue','data error','dashboard broken','analytics issue'] },
|
| 1035 |
+
{ id:10, title:'Data Analysis and Reporting Request', category:'Ops', keywords:['data analysis','reporting','analytics','dashboard','metrics','stats','report','insight','kpi'] },
|
| 1036 |
+
{ id:11, title:'Grievance / Strategic Alignment Requests', category:'HR', keywords:['grievance','complaint','alignment','strategy','concern','issue with team','unfair','conflict','disagreement'] },
|
| 1037 |
+
{ id:12, title:'Onboard New Access', category:'IT', keywords:['onboard','new joiner','new employee','new access','setup','new hire','joining','first day','create account'] },
|
| 1038 |
+
{ id:13, title:'Complaint', category:'HR', keywords:['complaint','problem','unhappy','dissatisfied','bad experience','report problem'] },
|
| 1039 |
+
{ id:14, title:'Offer Release Request', category:'HR', keywords:['offer letter','offer release','job offer','send offer','hiring offer','appointment letter'] },
|
| 1040 |
+
{ id:15, title:'Contract Termination', category:'Legal', keywords:['terminate','termination','end contract','fire','exit','notice period','last day'] },
|
| 1041 |
+
{ id:16, title:'Resignation Letter', category:'HR', keywords:['resign','resignation','quit','leaving','notice','last working day','stepping down'] },
|
| 1042 |
+
{ id:17, title:'Job Requisition', category:'HR', keywords:['hire','hiring','job opening','vacancy','recruit','new position','headcount','open role'] },
|
| 1043 |
+
{ id:18, title:'HR Support', category:'HR', keywords:['hr','human resources','hr help','policy','payroll','hr query','documents','certificate','letter'] },
|
| 1044 |
+
{ id:19, title:'Project Request', category:'General', keywords:['project','new project','start project','initiate','kick off','new work','client project'] },
|
| 1045 |
+
{ id:20, title:'Automation Request', category:'Ops', keywords:['automate','automation','workflow','bot','script','automatic','zapier','make','n8n','monday automation'] },
|
| 1046 |
+
{ id:21, title:'Process Change Request', category:'Ops', keywords:['process','change process','improve process','workflow change','sop','procedure','operations'] },
|
| 1047 |
+
{ id:22, title:'Root Cause Analysis', category:'Ops', keywords:['root cause','rca','why did','investigation','post mortem','incident','bug cause','what went wrong'] },
|
| 1048 |
+
{ id:23, title:'Emergency Protocol', category:'General', keywords:['emergency','urgent','critical','asap','immediately','down','outage','crisis','production issue'] },
|
| 1049 |
+
{ id:24, title:'Growth Team Bug Report', category:'Growth', keywords:['bug','error','crash','broken','not working','fix','glitch','app crash','defect'] },
|
| 1050 |
+
{ id:25, title:'Training Required', category:'HR', keywords:['training','learn','course','skill','workshop','upskill','tutorial','mentorship','education'] },
|
| 1051 |
+
{ id:26, title:'Meeting Request with CEO', category:'Management', keywords:['ceo','meeting with ceo','talk to ceo','bhargav','leadership','executive','founder'] },
|
| 1052 |
+
{ id:27, title:'WFH Request', category:'HR', keywords:['wfh','work from home','remote','work remotely','home office'] },
|
| 1053 |
+
{ id:28, title:'Maintenance Task', category:'Ops', keywords:['maintenance','maintain','upkeep','routine task','scheduled','infra','server maintenance'] },
|
| 1054 |
+
];
|
| 1055 |
+
|
| 1056 |
+
/* ββ Keyword-score a query against NAR types, return top 3 ββ */
|
| 1057 |
+
function matchNarTypes(query) {
|
| 1058 |
+
const q = query.toLowerCase();
|
| 1059 |
+
return NAR_TYPES
|
| 1060 |
+
.map(n => ({ ...n, score: n.keywords.reduce((s,kw) => s + (q.includes(kw) ? kw.split(' ').length : 0), 0) }))
|
| 1061 |
+
.filter(n => n.score > 0)
|
| 1062 |
+
.sort((a,b) => b.score - a.score)
|
| 1063 |
+
.slice(0, 3);
|
| 1064 |
+
}
|
| 1065 |
+
|
| 1066 |
+
/* ββββββββββββββββββββββββββββββοΏ½οΏ½βββββββββββββββ
|
| 1067 |
+
GROQ AI API
|
| 1068 |
ββββββββββββββββββββββββββββββββββββββββββββββ */
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1069 |
const GROQ_API_KEYS = [
|
| 1070 |
'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',
|
| 1071 |
'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',
|
| 1072 |
'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'
|
| 1073 |
];
|
| 1074 |
let currentKeyIndex = 0;
|
| 1075 |
+
const chatHistory = [];
|
| 1076 |
+
const messageCache = {};
|
| 1077 |
|
| 1078 |
async function callGroqAPI(userText, images = []) {
|
| 1079 |
try {
|
|
|
|
| 1080 |
let userContent = userText || '';
|
| 1081 |
+
if (images.length > 0) userContent += `\n[User attached ${images.length} image(s)]`;
|
| 1082 |
+
|
| 1083 |
+
// Pre-match NAR types locally β kept internal, never shown to user
|
| 1084 |
+
const matches = matchNarTypes(userContent);
|
| 1085 |
+
const narHints = matches.length > 0
|
| 1086 |
+
? `\n[SYSTEM ONLY - never repeat this to the user]: Likely NAR matches: ${JSON.stringify(matches.map(n=>({id:n.id,title:n.title,category:n.category})))}. Use these silently to pick the best suggestion.`
|
| 1087 |
+
: '';
|
| 1088 |
|
|
|
|
| 1089 |
chatHistory.push({ role: 'user', content: userContent });
|
| 1090 |
|
| 1091 |
const response = await fetch('https://api.groq.com/openai/v1/chat/completions', {
|
|
|
|
| 1096 |
},
|
| 1097 |
body: JSON.stringify({
|
| 1098 |
model: 'llama-3.1-8b-instant',
|
| 1099 |
+
max_tokens: 600,
|
| 1100 |
messages: [
|
| 1101 |
{
|
| 1102 |
role: 'system',
|
| 1103 |
+
content: `You are the internal AI assistant for New Age (Invento One Private Limited). You know everything about the company and help team members with questions, policies, and raising NAR requests on Monday.com. Always give specific, factual answers β never be vague.
|
| 1104 |
|
| 1105 |
==============================
|
| 1106 |
+
ABOUT NEW AGE
|
| 1107 |
==============================
|
| 1108 |
+
- Full legal name: Invento One Private Limited
|
|
|
|
|
|
|
| 1109 |
- Brand name: New Age
|
| 1110 |
- Website: newage4.com
|
| 1111 |
+
- Founded and led by: Bhargav (CEO)
|
| 1112 |
+
- Office: B10, MBH, Sarthana, Surat, Gujarat, India
|
| 1113 |
+
- Phone & WhatsApp: +91 81600 78511
|
| 1114 |
+
- General email: contact@newage4.com
|
| 1115 |
+
- HR email: hr@newage4.com
|
| 1116 |
+
- LinkedIn: linkedin.com/company/new-age-ai-products-and-services
|
| 1117 |
+
|
| 1118 |
+
MISSION: Listen to users with empathy, innovate and empower them through high-quality, responsible apps that address new-age problems. No addictions, only solutions.
|
| 1119 |
+
VISION: Positively impacting the daily lives of 1 million users with mindful, globally accessible digital experiences.
|
| 1120 |
+
|
| 1121 |
+
WHAT WE DO:
|
| 1122 |
+
- We build 25+ mobile and web apps across Android, iOS, and Web
|
| 1123 |
+
- 25 million+ total installs across all apps
|
| 1124 |
+
- 100K+ active users | 98% user satisfaction | 4.6/5 average rating | 15+ awards won
|
| 1125 |
+
- App categories: Tools, Education, Productivity, AI-powered utilities
|
| 1126 |
|
| 1127 |
DIVISIONS:
|
| 1128 |
+
1. Product Division β builds and maintains our own Android apps, iOS apps, and web products
|
| 1129 |
+
2. Services Division β AI and Mobile App Development services for external clients
|
|
|
|
| 1130 |
|
| 1131 |
+
KEY PRODUCTS:
|
| 1132 |
+
- New Age AI: AI-powered workflow automation suite for businesses
|
| 1133 |
- Cadabra: Supercharges Monday.com workflows with AI (ChatGPT integration)
|
| 1134 |
+
- iGrammar: Chrome extension β personal AI writing assistant
|
| 1135 |
+
- New Age Slack Bot: AI automation for Slack workspaces
|
| 1136 |
+
- 20+ more apps on Google Play Store and Apple App Store
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1137 |
|
| 1138 |
+
==============================
|
| 1139 |
+
TEAM & WORK CULTURE
|
| 1140 |
+
==============================
|
| 1141 |
+
- Remote-first company: 95% of roles are fully remote β work from anywhere in the world
|
| 1142 |
+
- Global team from 10+ countries: developers, designers, testers, marketers, managers, administrators
|
| 1143 |
+
- Work hours: Flexible 8-hour workday with 70% overlap during 10 AM β 6 PM IST
|
| 1144 |
+
- Pay schedule: Fortnightly (every 2 weeks)
|
| 1145 |
+
- Rate revisions: Every 6 months, based on performance
|
| 1146 |
+
- Employment structure: Freelance/contractor (no PF, gratuity, or statutory deductions)
|
| 1147 |
+
- Equipment: Team members use their own laptops, phones, and internet connections
|
| 1148 |
|
| 1149 |
+
==============================
|
| 1150 |
+
LEAVE POLICY
|
| 1151 |
+
==============================
|
| 1152 |
+
- Paid leave: 1 week (7 calendar days) per year β available after completing 1 year of service
|
| 1153 |
+
- Unpaid leave: Up to 3 weeks per year, subject to manager approval
|
| 1154 |
+
- Sick leave: As needed, with valid notice or documentation
|
| 1155 |
+
- Public holidays: No fixed national holidays β apply on your preferred days (95% approval rate)
|
| 1156 |
+
- WFH: Apply via WFH Request NAR if needed
|
| 1157 |
|
| 1158 |
+
==============================
|
| 1159 |
+
BENEFITS
|
| 1160 |
+
==============================
|
| 1161 |
+
- Health insurance: Available to C1 contract holders who have completed 2+ years of service at 40 hrs/week
|
| 1162 |
|
| 1163 |
+
==============================
|
| 1164 |
+
CORE VALUES
|
| 1165 |
+
==============================
|
| 1166 |
1. User First Approach
|
| 1167 |
2. Honest and Constructive Communication
|
| 1168 |
3. Constant Improvement
|
|
|
|
| 1172 |
7. People First
|
| 1173 |
8. Purpose with Passion
|
| 1174 |
|
| 1175 |
+
ALL 28 NAR REQUEST TYPES:
|
| 1176 |
+
${NAR_TYPES.map(n=>`${n.id}. ${n.title} [${n.category}]`).join('\n')}
|
| 1177 |
+
|
| 1178 |
+
NAR SUGGESTION RULE β CRITICAL, ALWAYS FOLLOW:
|
| 1179 |
+
You MUST suggest a NAR whenever the user's message contains ANY of these signals:
|
| 1180 |
+
- Words like: apply, request, submit, raise, need, want, get, buy, report, fix, hire, resign, cancel, change, access, approve, complain, train, schedule, automate
|
| 1181 |
+
- Phrases like: "I want to", "I need to", "how do I", "can I", "I would like to", "how to apply"
|
| 1182 |
+
- Topics like: leave, WFH, laptop, reimbursement, payment, access, bug, contract, resignation, training, meeting with CEO
|
| 1183 |
+
|
| 1184 |
+
EXAMPLES β always show NAR card for these:
|
| 1185 |
+
- "I want to apply for wfh" β WFH Request
|
| 1186 |
+
- "I want to apply for leave" β Leave Request
|
| 1187 |
+
- "I need a new laptop" β Purchase Request
|
| 1188 |
+
- "how do I submit reimbursement" β Payment Request
|
| 1189 |
+
- "I want to report a bug" β Growth Team Bug Report
|
| 1190 |
+
|
| 1191 |
+
You may have internal context at the end of this prompt to help you pick the right NAR. Never mention or quote that internal context to the user.
|
| 1192 |
+
|
| 1193 |
+
After your answer, append this block EXACTLY (valid JSON only, no extra text inside):
|
| 1194 |
+
:::nar-suggestion
|
| 1195 |
+
{
|
| 1196 |
+
"id": <number>,
|
| 1197 |
+
"title": "<exact title from list>",
|
| 1198 |
+
"category": "<category>",
|
| 1199 |
+
"reason": "<one short sentence telling the employee which form to use and why, e.g. To submit a reimbursement, please use the Payment Request form under Finance.>",
|
| 1200 |
+
"fields_guide": "<bullet list of the key fields to fill in this form, specific to what the user asked. Use β’ as bullet. E.g. β’ Request Type: Reimbursement β’ Amount: Enter the exact amount β’ Description: What was the expense for β’ Attachment: Upload receipt if available>",
|
| 1201 |
+
"alternatives": [
|
| 1202 |
+
{"id": <n>, "title": "<title>", "category": "<cat>"},
|
| 1203 |
+
{"id": <n>, "title": "<title>", "category": "<cat>"}
|
| 1204 |
+
]
|
| 1205 |
+
}
|
| 1206 |
+
:::
|
| 1207 |
+
|
| 1208 |
+
If the message is purely informational (no action needed), do NOT include the block.
|
| 1209 |
+
|
| 1210 |
+
RULES:
|
| 1211 |
+
1. NEVER share salary, revenue, profit, or financial figures β direct to hr@newage4.com
|
| 1212 |
+
2. When answering company questions (e.g. "what is New Age"), always use SPECIFIC facts from the knowledge base β mention the actual numbers (25+ apps, 25M+ installs, 100K+ users), divisions, mission, and products. Never give a vague generic answer.
|
| 1213 |
+
3. When a NAR card is shown: keep your text reply to 1-2 lines only. Do NOT repeat the form name, fields, or Monday.com instructions β the card handles that.
|
| 1214 |
+
4. Example good reply when NAR is shown: "Sure! I've pulled up the right form for you below. π"
|
| 1215 |
+
5. Do NOT say "Please log in to Monday.com" or "Open the board" in your text reply β the card button handles that.
|
| 1216 |
+
6. Be warm, friendly, and speak like a helpful colleague β not a system.${narHints}`
|
| 1217 |
},
|
| 1218 |
...chatHistory
|
| 1219 |
]
|
|
|
|
| 1221 |
});
|
| 1222 |
|
| 1223 |
const data = await response.json();
|
|
|
|
| 1224 |
if (!response.ok) {
|
| 1225 |
+
if (data.error?.code === 'rate_limit_exceeded' && currentKeyIndex < GROQ_API_KEYS.length - 1) {
|
| 1226 |
+
currentKeyIndex++;
|
| 1227 |
+
return callGroqAPI(userText, images);
|
| 1228 |
+
}
|
| 1229 |
throw new Error(data.error?.message || 'Something went wrong with AI');
|
| 1230 |
}
|
| 1231 |
|
| 1232 |
const reply = data.choices[0].message.content;
|
|
|
|
|
|
|
| 1233 |
chatHistory.push({ role: 'assistant', content: reply });
|
|
|
|
|
|
|
| 1234 |
if (chatHistory.length > 20) chatHistory.splice(0, 2);
|
| 1235 |
|
| 1236 |
hideTyping();
|
|
|
|
| 1237 |
if (chatHistory.length > 0) {
|
| 1238 |
+
const last = chatHistory[chatHistory.length - 2];
|
| 1239 |
+
if (last) messageCache[last.content.trim().toLowerCase()] = reply;
|
| 1240 |
}
|
| 1241 |
addMessage('bot', reply);
|
| 1242 |
|