Skip to content

Add Cloudflare Workers AI chat assistant to homepage#9

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/setup-cloudflare-ai-bot
Draft

Add Cloudflare Workers AI chat assistant to homepage#9
Copilot wants to merge 2 commits intomainfrom
copilot/setup-cloudflare-ai-bot

Conversation

Copy link
Contributor

Copilot AI commented Mar 22, 2026

Adds EduBot, a floating AI chat widget on the homepage backed by Cloudflare Workers AI (@cf/meta/llama-3.1-8b-instruct), so users can ask questions about the platform and learning activities without leaving the page.

Backend — POST /api/chat

  • New endpoint in src/worker.py accepting { message, history[] }
  • Forwards to env.AI.run() with an EduPlatform-scoped system prompt
  • Sanitises and caps conversation history (10-turn window, 2000-char per message)
  • Returns 503 on AI service failure; wrangler.toml gains the required [ai] binding
result = await env.AI.run(
    "@cf/meta/llama-3.1-8b-instruct",
    {"messages": messages},
)

Frontend — floating chat widget (public/index.html)

  • Fixed bottom-right 💬 toggle button; opens a branded chat window (EduBot header, scrollable message log, typing indicator)
  • Vanilla JS maintains client-side history, sends prior turns as history[] and current message as message on each request
  • Accessible: role="log", aria-live="polite", aria-label on controls

Screenshots

Chat button (collapsed)
Homepage with chat button

Chat window open
Chat window open

Original prompt

This section details on the original issue you should resolve

<issue_title>setup a cloudflare ai bot so users can chat with a bot from the homepage</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

@cloudflare-workers-and-pages
Copy link
Contributor

cloudflare-workers-and-pages bot commented Mar 22, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
learn d34ea61 Commit Preview URL

Branch Preview URL
Mar 22 2026, 05:16 PM

Copilot AI changed the title [WIP] Add Cloudflare AI bot for user chat on homepage Add Cloudflare Workers AI chat assistant to homepage Mar 22, 2026
Copilot AI requested a review from A1L13N March 22, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

setup a cloudflare ai bot so users can chat with a bot from the homepage

2 participants