{"id":17,"date":"2025-12-23T16:12:27","date_gmt":"2025-12-23T16:12:27","guid":{"rendered":"https:\/\/voyages.simoneau.cloud\/?page_id=17"},"modified":"2026-04-05T12:38:00","modified_gmt":"2026-04-05T17:38:00","slug":"assistant-virtuel","status":"publish","type":"page","link":"https:\/\/voyages.simoneau.cloud\/","title":{"rendered":"Assistant virtuel"},"content":{"rendered":"\n<p>Gabrielle est pr\u00eate \u00e0 vous aider dans votre choix.<\/p>\n\n\n    <div id=\"gabrielle-chat-shell\">\n        <div class=\"gab-header\">\n            <div class=\"gab-title\">Gabrielle<\/div>\n            <div class=\"gab-subtitle\">Posez votre question<\/div>\n        <\/div>\n\n        <div class=\"gab-messages\" id=\"gab-messages\"><\/div>\n\n        <form class=\"gab-form\" id=\"gab-form\">\n            <textarea id=\"gab-input\" rows=\"3\" placeholder=\"\u00c9crivez votre message...\"><\/textarea>\n            <button type=\"submit\">Envoyer<\/button>\n        <\/form>\n    <\/div>\n\n    <style>\n        #gabrielle-chat-shell{max-width:980px;margin:0 auto;border:1px solid #e5e7eb;border-radius:18px;overflow:hidden;background:#fff}\n        #gabrielle-chat-shell .gab-header{padding:18px 20px;border-bottom:1px solid #e5e7eb;background:#fff}\n        #gabrielle-chat-shell .gab-title{font-size:22px;font-weight:700;line-height:1.2}\n        #gabrielle-chat-shell .gab-subtitle{font-size:14px;opacity:.75;margin-top:4px}\n        #gabrielle-chat-shell .gab-messages{min-height:320px;max-height:65vh;overflow:auto;padding:18px;background:#fafafa}\n        #gabrielle-chat-shell .gab-bubble{max-width:88%;padding:14px 16px;border-radius:16px;margin:0 0 14px 0;line-height:1.5}\n        #gabrielle-chat-shell .gab-user{margin-left:auto;background:#111827;color:#fff;white-space:pre-wrap}\n        #gabrielle-chat-shell .gab-assistant{margin-right:auto;background:#fff;border:1px solid #e5e7eb;color:#111827}\n        #gabrielle-chat-shell .gab-assistant h3,#gabrielle-chat-shell .gab-assistant h4{margin:0 0 10px 0;line-height:1.35}\n        #gabrielle-chat-shell .gab-assistant p{margin:0 0 10px 0}\n        #gabrielle-chat-shell .gab-assistant ul,#gabrielle-chat-shell .gab-assistant ol{margin:0 0 10px 20px;padding:0}\n        #gabrielle-chat-shell .gab-assistant li{margin:0 0 6px 0}\n        #gabrielle-chat-shell .gab-assistant a{word-break:break-word}\n        #gabrielle-chat-shell .gab-assistant img.gab-inline-image{display:block;max-width:100%;height:auto;border-radius:12px;margin:10px 0;border:1px solid #e5e7eb}\n        #gabrielle-chat-shell .gab-form{display:flex;gap:12px;padding:16px;border-top:1px solid #e5e7eb;background:#fff}\n        #gabrielle-chat-shell textarea{flex:1;resize:vertical;min-height:56px;padding:12px;border:1px solid #d1d5db;border-radius:12px;font:inherit}\n        #gabrielle-chat-shell button{padding:0 18px;border:none;border-radius:12px;background:#111827;color:#fff;cursor:pointer;font:inherit}\n    <\/style>\n\n    <script>\n    (() => {\n        const form = document.getElementById('gab-form');\n        const input = document.getElementById('gab-input');\n        const messagesEl = document.getElementById('gab-messages');\n        const ajaxUrl = \"https:\\\/\\\/voyages.simoneau.cloud\\\/wp-admin\\\/admin-ajax.php\";\n        const history = [];\n\n        function addUserBubble(text) {\n            const div = document.createElement('div');\n            div.className = 'gab-bubble gab-user';\n            div.textContent = text;\n            messagesEl.appendChild(div);\n            messagesEl.scrollTop = messagesEl.scrollHeight;\n        }\n\n        function addAssistantBubble(html) {\n            const div = document.createElement('div');\n            div.className = 'gab-bubble gab-assistant';\n            div.innerHTML = html;\n            messagesEl.appendChild(div);\n            messagesEl.scrollTop = messagesEl.scrollHeight;\n        }\n\n        async function sendMessage(text) {\n            const body = new URLSearchParams();\n            body.set('action', 'gabrielle_chat_proxy');\n            body.set('message', text);\n            body.set('messages', JSON.stringify(history));\n\n            const res = await fetch(ajaxUrl, {\n                method: 'POST',\n                headers: { 'Content-Type': 'application\/x-www-form-urlencoded; charset=UTF-8' },\n                body: body.toString(),\n                credentials: 'same-origin',\n                cache: 'no-store'\n            });\n\n            const data = await res.json().catch(() => ({}));\n            if (!res.ok || !data.success) {\n                throw new Error(data?.data?.error || ('HTTP ' + res.status));\n            }\n            return data.data;\n        }\n\n        form.addEventListener('submit', async (e) => {\n            e.preventDefault();\n            const text = input.value.trim();\n            if (!text) return;\n\n            history.push({ role: 'user', content: text });\n            addUserBubble(text);\n            input.value = '';\n\n            try {\n                const data = await sendMessage(text);\n                history.push({ role: 'assistant', content: data.reply || '' });\n                addAssistantBubble(data.html || '<p>Aucune r\u00e9ponse.<\/p>');\n            } catch (err) {\n                addAssistantBubble('<p>Erreur de communication avec Gabrielle : ' + String(err.message || err) + '<\/p>');\n                console.error(err);\n            }\n        });\n    })();\n    <\/script>\n    \n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Gabrielle est pr\u00eate \u00e0 vous aider dans votre choix.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-17","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/voyages.simoneau.cloud\/index.php?rest_route=\/wp\/v2\/pages\/17","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/voyages.simoneau.cloud\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/voyages.simoneau.cloud\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/voyages.simoneau.cloud\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/voyages.simoneau.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=17"}],"version-history":[{"count":11,"href":"https:\/\/voyages.simoneau.cloud\/index.php?rest_route=\/wp\/v2\/pages\/17\/revisions"}],"predecessor-version":[{"id":2110,"href":"https:\/\/voyages.simoneau.cloud\/index.php?rest_route=\/wp\/v2\/pages\/17\/revisions\/2110"}],"wp:attachment":[{"href":"https:\/\/voyages.simoneau.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=17"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}