<!-- QUOTE FOLLOW UP AGENT -->
Browse files<div class="agent-card bg-gradient-to-br from-blue-50 to-blue-100 p-4 rounded-lg"
data-agent="quote"
data-webhook="https://n8n.minimise.co.nz/webhook-test/d6770799-63da-4787-8b83-983f03b770ea">
<div class="agent-icon bg-blue-100 text-blue-600 p-2 rounded-full inline-flex items-center justify-center">
<i data-feather="file-text"></i>
</div>
<h3 class="mt-2 text-lg font-semibold text-gray-800">Quote Follow Up</h3>
<p class="text-gray-700">Automatically follow up on sent quotes</p>
<div class="agent-form mt-4">
<input
type="text"
class="agent-phone w-full px-3 py-2 bg-white text-black border border-gray-300 rounded-lg mb-2"
placeholder="Enter phone number"
>
<button class="agent-activate-btn w-full px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors">
Activate Agent
</button>
</div>
</div>
<!-- SCRIPT FOR WEBHOOK SENDING (PUT THIS AT THE BOTTOM OF THE PAGE, BEFORE </body>) -->
<script>
document.addEventListener("DOMContentLoaded", () => {
const buttons = document.querySelectorAll(".agent-activate-btn");
buttons.forEach((btn) => {
btn.addEventListener("click", async (e) => {
e.preventDefault();
e.stopPropagation();
// Find the agent-card container
const card = btn.closest(".agent-card");
const agentType = card?.dataset.agent || "unknown";
// Get the webhook unique to THIS block
const webhookUrl = card?.dataset.webhook;
if (!webhookUrl) {
alert("No webhook configured for this agent.");
return;
}
// Get phone number
const input = card.querySelector(".agent-phone");
const phone = input.value.trim();
if (!phone) {
alert("Please enter a phone number first.");
input.focus();
return;
}
// Loading state for button
btn.disabled = true;
const originalText = btn.textContent;
btn.textContent = "Sending...";
try {
const res = await fetch(webhookUrl, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
phone,
agent: agentType,
source: "agent-activation-station",
timestamp: new Date().toISOString(),
}),
});
if (!res.ok) {
throw new Error(`Webhook error: ${res.status}`);
}
// Clear input + show confirmation
input.value = "";
const confirmation = document.getElementById("confirmation");
if (confirmation) confirmation.classList.remove("hidden");
} catch (err) {
console.error(err);
alert("Error sending message to n8n. Check logs.");
} finally {
btn.disabled = false;
btn.textContent = originalText;
}
});
});
});
</script>
- index.html +6 -5
- script.js +41 -11
|
@@ -19,7 +19,9 @@
|
|
| 19 |
</div>
|
| 20 |
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4 mb-12">
|
| 21 |
<!-- Quote Follow Up Agent -->
|
| 22 |
-
<div class="agent-card bg-gradient-to-br from-blue-50 to-blue-100"
|
|
|
|
|
|
|
| 23 |
<div class="agent-icon bg-blue-100 text-blue-600">
|
| 24 |
<i data-feather="file-text"></i>
|
| 25 |
</div>
|
|
@@ -27,13 +29,12 @@
|
|
| 27 |
<p>Automatically follow up on sent quotes</p>
|
| 28 |
<div class="agent-form hidden mt-4">
|
| 29 |
<input type="tel" class="agent-phone w-full px-3 py-2 border border-gray-300 rounded-lg mb-2" placeholder="Enter phone number">
|
| 30 |
-
<button class="agent-activate-btn w-full px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors">
|
| 31 |
Activate Agent
|
| 32 |
</button>
|
| 33 |
</div>
|
| 34 |
</div>
|
| 35 |
-
|
| 36 |
-
<!-- Invoice Follow Up Agent -->
|
| 37 |
<div class="agent-card bg-gradient-to-br from-purple-50 to-purple-100" data-agent="invoice">
|
| 38 |
<div class="agent-icon bg-purple-100 text-purple-600">
|
| 39 |
<i data-feather="dollar-sign"></i>
|
|
@@ -128,6 +129,6 @@
|
|
| 128 |
feather.replace();
|
| 129 |
</script>
|
| 130 |
<script src="script.js"></script>
|
| 131 |
-
<script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
|
| 132 |
</body>
|
| 133 |
</html>
|
|
|
|
| 19 |
</div>
|
| 20 |
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4 mb-12">
|
| 21 |
<!-- Quote Follow Up Agent -->
|
| 22 |
+
<div class="agent-card bg-gradient-to-br from-blue-50 to-blue-100"
|
| 23 |
+
data-agent="quote"
|
| 24 |
+
data-webhook="https://n8n.minimise.co.nz/webhook-test/d6770799-63da-4787-8b83-983f03b770ea">
|
| 25 |
<div class="agent-icon bg-blue-100 text-blue-600">
|
| 26 |
<i data-feather="file-text"></i>
|
| 27 |
</div>
|
|
|
|
| 29 |
<p>Automatically follow up on sent quotes</p>
|
| 30 |
<div class="agent-form hidden mt-4">
|
| 31 |
<input type="tel" class="agent-phone w-full px-3 py-2 border border-gray-300 rounded-lg mb-2" placeholder="Enter phone number">
|
| 32 |
+
<button class="agent-activate-btn w-full px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors">
|
| 33 |
Activate Agent
|
| 34 |
</button>
|
| 35 |
</div>
|
| 36 |
</div>
|
| 37 |
+
<!-- Invoice Follow Up Agent -->
|
|
|
|
| 38 |
<div class="agent-card bg-gradient-to-br from-purple-50 to-purple-100" data-agent="invoice">
|
| 39 |
<div class="agent-icon bg-purple-100 text-purple-600">
|
| 40 |
<i data-feather="dollar-sign"></i>
|
|
|
|
| 129 |
feather.replace();
|
| 130 |
</script>
|
| 131 |
<script src="script.js"></script>
|
| 132 |
+
<script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
|
| 133 |
</body>
|
| 134 |
</html>
|
|
@@ -32,28 +32,58 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
| 32 |
this.classList.add('selected');
|
| 33 |
form.classList.toggle('hidden');
|
| 34 |
});
|
| 35 |
-
|
| 36 |
// Activation button
|
| 37 |
-
activateBtn.addEventListener('click', function() {
|
|
|
|
|
|
|
|
|
|
| 38 |
const phoneNumber = phoneInput.value.trim();
|
| 39 |
-
// Validate phone number - should have at least 8 digits (excluding +64 and spaces)
|
| 40 |
if (!phoneNumber) {
|
| 41 |
alert('Please enter a phone number');
|
| 42 |
-
return;
|
| 43 |
}
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
confirmation.classList.remove('hidden');
|
| 48 |
phoneInput.value = '';
|
| 49 |
card.classList.remove('selected');
|
| 50 |
form.classList.add('hidden');
|
| 51 |
-
|
| 52 |
-
// Hide confirmation after 5 seconds
|
| 53 |
setTimeout(() => {
|
| 54 |
confirmation.classList.add('hidden');
|
| 55 |
}, 5000);
|
| 56 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
});
|
| 58 |
-
|
| 59 |
});
|
|
|
|
| 32 |
this.classList.add('selected');
|
| 33 |
form.classList.toggle('hidden');
|
| 34 |
});
|
|
|
|
| 35 |
// Activation button
|
| 36 |
+
activateBtn.addEventListener('click', async function(e) {
|
| 37 |
+
e.preventDefault();
|
| 38 |
+
e.stopPropagation();
|
| 39 |
+
|
| 40 |
const phoneNumber = phoneInput.value.trim();
|
|
|
|
| 41 |
if (!phoneNumber) {
|
| 42 |
alert('Please enter a phone number');
|
| 43 |
+
return;
|
| 44 |
}
|
| 45 |
+
|
| 46 |
+
const webhookUrl = card.dataset.webhook;
|
| 47 |
+
if (!webhookUrl) {
|
| 48 |
+
alert('No webhook configured for this agent');
|
| 49 |
+
return;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
// Loading state
|
| 53 |
+
const originalText = activateBtn.textContent;
|
| 54 |
+
activateBtn.textContent = "Sending...";
|
| 55 |
+
activateBtn.disabled = true;
|
| 56 |
+
|
| 57 |
+
try {
|
| 58 |
+
const res = await fetch(webhookUrl, {
|
| 59 |
+
method: 'POST',
|
| 60 |
+
headers: { 'Content-Type': 'application/json' },
|
| 61 |
+
body: JSON.stringify({
|
| 62 |
+
phone: phoneNumber,
|
| 63 |
+
agent: card.dataset.agent,
|
| 64 |
+
source: 'agent-activation-station',
|
| 65 |
+
timestamp: new Date().toISOString()
|
| 66 |
+
})
|
| 67 |
+
});
|
| 68 |
+
|
| 69 |
+
if (!res.ok) throw new Error(`Webhook error: ${res.status}`);
|
| 70 |
+
|
| 71 |
+
// Success handling
|
| 72 |
confirmation.classList.remove('hidden');
|
| 73 |
phoneInput.value = '';
|
| 74 |
card.classList.remove('selected');
|
| 75 |
form.classList.add('hidden');
|
| 76 |
+
|
|
|
|
| 77 |
setTimeout(() => {
|
| 78 |
confirmation.classList.add('hidden');
|
| 79 |
}, 5000);
|
| 80 |
+
} catch (err) {
|
| 81 |
+
console.error(err);
|
| 82 |
+
alert('Error sending message to n8n. Check console for details.');
|
| 83 |
+
} finally {
|
| 84 |
+
activateBtn.textContent = originalText;
|
| 85 |
+
activateBtn.disabled = false;
|
| 86 |
+
}
|
| 87 |
});
|
| 88 |
+
});
|
| 89 |
});
|