This is a sample project that demonstrates how to add a chatbot to your content-focused static site. The chatbot is grounded in the content of the website by using the retrieval augmentated generation pattern. See the accompanying blog for more information: https://techcommunity.microsoft.com/t5/apps-on-azure-blog/add-a-context-grounded-ai-chatbot-to-your-azure-static-web-apps/ba-p/4097223
This sample builds upon a Next.js static site that demonstrates a content-focused site. See the original blog post to find more information about the Next.js site itself. Build an Azure Static Web Apps site using WordPress as a headless CMS.
- Run the development server for the Next.js site:
cd nextjs-site
npm run dev
This should start the Next.js development server on http://localhost:3000.
- Run the Azure Functions:
cd api
func start
This should start the Azure Functions on http://localhost:7071.
- Run the Static Web Apps server:
swa start --app-devserver-url http://localhost:3000 --api-devserver-url http://localhost:7071
This will start the Static Web Apps server on http://localhost:4280 and simulate the API routing to the Azure Functions.
This sample can be directly deployed to Static Web Apps. It requires that you have a properly configured Azure AI Search, Azure OpenAI resources before you get started. This project has also been configured to use OpenAI APIs directly, so you will need to use an OpenAI API key or adapt the code to use Azure OpenAI for chat completion.
- Fork this repository.
- Create a new Static Web Apps resource in the Azure portal using this newly forked repository.
- Configure the required environment variables for the Azure Functions in the Static Web Apps portal.
"AI_SEARCH_KEY": "<Enter your Azure AI Search key>",
"AI_SEARCH_ENDPOINT": "<Enter your Azure AI Search endpoint/URL>",
"AI_SEARCH_INDEX": "<Enter your Azure AI Search Index>",
"OPENAI_KEY":"<Enter your OpenAI Key>",