Skip to content
- Choosing a selection results in a full page refresh.
- Press the space key then arrow keys to make a selection.
- Use left/right arrows to navigate the slideshow or swipe left/right if using a mobile device
💬 Chat with DEM Assistant(Beta)
async function sendMessage() {
const input = document.getElementById('user-input');
const log = document.getElementById('chat-log');
const userText = input.value;
if (!userText) return;
log.innerHTML += `You: ${userText}
`;
input.value = "";
try {
const response = await fetch("https://ancient-unit-b923.michael-ab6.workers.dev/", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
messages: [
{ role: "system", content: "You are a helpful assistant for an online Shopify store. Answer questions about products, orders, or anything else in a friendly tone." },
{ role: "user", content: userText }
]
})
});
const data = await response.json();
const reply = data.choices[0].message.content;
log.innerHTML += `DEM Assistant: ${reply}
`;
} catch (error) {
console.error(error);
log.innerHTML += `Bot: Sorry, something went wrong.
${error.message}
`;
;
}
log.scrollTop = log.scrollHeight;
}