Download static/script2.js from ehsanhon/async-dialogflow-chat: direct link, hf CLI and curl.
- Browser
- Download file 826 Bytes
-
https://huggingface.co/ehsanhon/async-dialogflow-chat/resolve/main/static/script2.js
- Command line
-
hf download hf://ehsanhon/async-dialogflow-chat/static/script2.js
-
curl -L -o script2.js https://huggingface.co/ehsanhon/async-dialogflow-chat/resolve/main/static/script2.js
826 Bytes
| async function sendMessage() { | |
| const inputEl = document.getElementById("userInput"); | |
| const statusEl = document.getElementById("status"); | |
| const replyEl = document.getElementById("botReply"); | |
| const message = inputEl.value.trim(); | |
| if (!message) return; | |
| // Update status | |
| statusEl.innerText = "Connecting to service..."; | |
| await delay(300); | |
| statusEl.innerText = "Getting data..."; | |
| const response = await fetch("/chat", { | |
| method: "POST", | |
| headers: { "Content-Type": "application/json" }, | |
| body: JSON.stringify({ message }) | |
| }); | |
| const data = await response.json(); | |
| statusEl.innerText = "Operation complete."; | |
| replyEl.innerText = data.reply; | |
| } | |
| function delay(ms) { | |
| return new Promise(resolve => setTimeout(resolve, ms)); | |
| } | |