diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4edfe52dce..fb473a76a0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -24,6 +24,8 @@ on: required: true HUGO_PHI_ONNX_LLM_API: required: true + HUGO_CHATBOT_API: + required: true HUGO_DEV_PROG_SIGNIUP_FORM_MUNCHKIN_ID: required: true HUGO_FORM_ID_FOR_PROGRAM_SIGNUP: @@ -74,6 +76,7 @@ jobs: HUGO_RAG_API: ${{ secrets.HUGO_RAG_API }} HUGO_AUDIO_API: ${{ secrets.HUGO_AUDIO_API }} HUGO_PHI_ONNX_LLM_API: ${{ secrets.HUGO_PHI_ONNX_LLM_API }} + HUGO_CHATBOT_API: ${{ secrets.HUGO_CHATBOT_API }} HUGO_DEV_PROG_SIGNIUP_FORM_MUNCHKIN_ID: ${{ secrets.HUGO_DEV_PROG_SIGNIUP_FORM_MUNCHKIN_ID }} HUGO_FORM_ID_FOR_PROGRAM_SIGNUP: ${{ secrets.HUGO_FORM_ID_FOR_PROGRAM_SIGNUP }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 81505b2eb0..830982e62e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,5 +27,6 @@ jobs: HUGO_RAG_API: ${{ secrets.HUGO_RAG_API }} HUGO_AUDIO_API: ${{ secrets.HUGO_AUDIO_API }} HUGO_PHI_ONNX_LLM_API: ${{ secrets.HUGO_PHI_ONNX_LLM_API }} + HUGO_CHATBOT_API: ${{ secrets.HUGO_CHATBOT_API }} HUGO_DEV_PROG_SIGNIUP_FORM_MUNCHKIN_ID: ${{ secrets.HUGO_DEV_PROG_SIGNIUP_FORM_MUNCHKIN_ID }} HUGO_FORM_ID_FOR_PROGRAM_SIGNUP: ${{ secrets.HUGO_FORM_ID_FOR_PROGRAM_SIGNUP }} diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 67dee55cb4..a6e7f9ead0 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -26,5 +26,6 @@ jobs: HUGO_RAG_API: ${{ secrets.HUGO_RAG_API }} HUGO_AUDIO_API: ${{ secrets.HUGO_AUDIO_API }} HUGO_PHI_ONNX_LLM_API: ${{ secrets.HUGO_PHI_ONNX_LLM_API }} + HUGO_CHATBOT_API: ${{ secrets.HUGO_CHATBOT_API }} HUGO_DEV_PROG_SIGNIUP_FORM_MUNCHKIN_ID: ${{ secrets.HUGO_DEV_PROG_SIGNIUP_FORM_MUNCHKIN_ID }} HUGO_FORM_ID_FOR_PROGRAM_SIGNUP: ${{ secrets.HUGO_FORM_ID_FOR_PROGRAM_SIGNUP }} diff --git a/themes/arm-design-system-hugo-theme/layouts/partials/footer/script-includes.html b/themes/arm-design-system-hugo-theme/layouts/partials/footer/script-includes.html index 4715342856..297e08f352 100644 --- a/themes/arm-design-system-hugo-theme/layouts/partials/footer/script-includes.html +++ b/themes/arm-design-system-hugo-theme/layouts/partials/footer/script-includes.html @@ -45,9 +45,15 @@ - + + + + diff --git a/themes/arm-design-system-hugo-theme/static/js/chat-ai-integration.js b/themes/arm-design-system-hugo-theme/static/js/chat-ai-integration.js new file mode 100644 index 0000000000..416621b735 --- /dev/null +++ b/themes/arm-design-system-hugo-theme/static/js/chat-ai-integration.js @@ -0,0 +1,33 @@ +(async () => { + try { + await initAuth(); + + const account = getAccount(); + const claims = await getIdTokenClaimsForAccount(account); + const email = getEmailClaimValue(claims); + const chatbotApiUrl = atob(window.chatbotApiUrlEncoded || ""); + + if (!chatbotApiUrl) { + throw new Error("HUGO_CHATBOT_API is not configured"); + } + + if (email) { + // Create and append chat-ai element only after successful auth + const chatAi = document.createElement("chat-ai"); + chatAi.id = "chat-ai"; + chatAi.setAttribute("theme", "dark"); + chatAi.setAttribute("app-name", "learning-paths"); + chatAi.setAttribute("api-url", chatbotApiUrl); + chatAi.setAttribute("tnc-url", "https://ipuser.dev.bespin.arm.com/vfae-terms-and-conditions"); + chatAi.setAttribute("stream", "false"); + chatAi.setAttribute("login-hint", email); + chatAi.setAttribute("redirect-url", window.location.origin + "/"); + chatAi.setAttribute("login-on-load", "true"); + + document.body.appendChild(chatAi); + window.chatAiRef = chatAi; + } + } catch (error) { + console.warn("Unable to authenticate:", error); + } +})();