This project is a configurable Retail Brand Assistant built using Microsoft Semantic Kernel for AI Orchestration, OpenAI or Azure OpenAI GPT models, and Microsoft Bing Custom Search for brand-specific search results. Using the Retail Brand Assistant allows brands to rapidly test and deploy a fully functioning AI Assistant for customers that uses real-time page information to answer questions with high accuracy and consistency.
When retail brand experiences fail like this... | Retail Brand Assistant succeeds... |
---|---|
![]() |
![]() |
- .NET SDK (version 6.0 or later)
- OpenAI API key or Azure OpenAI API key and deployment
- Bing Custom Search instance and key
- Node.js and npm (for the frontend)
Click to expand Bing Custom Search setup instructions
- Microsoft Azure Account: You need an Azure account to use Bing Custom Search. Sign up at Azure.
- Go to the Azure portal.
- Click on Create a resource.
- Search for Bing Custom Search and select it.
- Click Create.
- Fill in the required details:
- Subscription: Your Azure subscription.
- Resource group: Create a new one or use an existing one.
- Name: A unique name for your resource.
- Pricing tier: Choose a pricing tier that suits your needs.
- Resource region: Select the region.
- Click Review + create and then Create.
- After the resource is created, go to the resource page.
- Under Resource Management, click on Custom Search Portal. This will take you to the Bing Custom Search UI.
- In the Custom Search UI, click on Create new custom search instance.
- Provide a name and description for your custom search instance.
- Click Create.
- Click on Add a site to your search instance.
- Enter the domain or specific URLs you want to include in your custom search.
- Click Add.
- After adding the domain, you can further customize your search instance by specifying:
- Domains and URLs: Add multiple domains or specific URLs.
- Pinned Results: Pin specific pages to the top of the search results.
- Block Certain Sites: Exclude certain domains or URLs from search results.
- Once you have added the necessary domains and customized your search instance, click on Publish.
- Confirm the details and click Publish again to make your custom search instance live.
- Go back to the Azure portal, under your Bing Custom Search resource.
- Under Keys and Endpoint, copy one of the keys and the endpoint URL. You will need these if you decide to access the custom search programmatically.
project_root/
├── reactfrontend/
│ ├── public/
│ ├── scripts/
│ ├── src/
│ │ ├── App.css
│ │ ├── App.js
│ ├── package-lock.json
│ └── package.json
├── skbackend/
│ ├── Program.cs
│ ├── RetailContextPlugin.cs
│ ├── SalesHelpPlugin.cs
│ ├── SalesHelpPrompt.txt
│ └── SystemMessage.txt
├── README.md
├── setup.sh
├── start.sh
├── startbackend.sh
├── startfrontend.sh
└── stop.sh
-
Clone the repository:
git clone https://github.com/function1st/retailbrandassistant-public.git cd retailbrandassistant-public
-
Make the scripts executable and run the setup script:
chmod +x setup.sh start.sh startbackend.sh startfrontend.sh stop.sh ./setup.sh
-
Follow the prompts to enter your brand name, language, market, and locale.
-
Edit the
.env
file and add your API keys:Depending on whether you are using OpenAI or Azure OpenAI, you will need to provide different environment variables.
For OpenAI:
# .env file in skbackend directory AZURE_OPEN_AI=False # or omit this line; default is False OPENAI_API_KEY=your_openai_api_key_here OPENAI_MODEL_NAME=gpt-4 # Optional, defaults to 'gpt-4o-mini' if not set BING_SUBSCRIPTION_KEY=your_bing_subscription_key_here CUSTOM_CONFIG_ID=your_bing_custom_config_id_here
For Azure OpenAI:
# .env file in skbackend directory AZURE_OPEN_AI=True AZURE_OPENAI_ENDPOINT=https://your-azure-endpoint.openai.azure.com/ AZURE_OPENAI_KEY=your_azure_openai_api_key_here AZURE_OPENAI_DEPLOYMENT_NAME=your_deployment_name_here BING_SUBSCRIPTION_KEY=your_bing_subscription_key_here CUSTOM_CONFIG_ID=your_bing_custom_config_id_here
Note: The
AZURE_OPEN_AI
environment variable determines whether the application uses Azure OpenAI or OpenAI. IfAZURE_OPEN_AI
is not set or set toFalse
, the application defaults to OpenAI.
-
To start the application:
./start.sh
This will automatically update the current date in the system message and start both the backend and frontend.
-
Interact with the Retail Brand Assistant through your web browser at
http://localhost:3000
. -
To stop the application:
./stop.sh
The setup script helps you configure the basic brand information and site information. If you need to change this information later, you can either run the setup script again or manually edit the SystemMessage.txt
file located in the skbackend
directory.
The current date is automatically updated each time you start the application using the start script.
You can customize the Retail Brand Assistant by modifying the following files:
SystemMessage.txt
: Contains the system message that defines the agent's behavior and how it uses real-time context.Program.cs
: Main Semantic Kernel logic and chat handling. In addition, the prompt logic for plugin orchestration as well as topic classification is found here.RetailContextPlugin.cs
: Plugin for retrieving real-time retail context. Leverages Bing Custom Search to retrieve top results, uses OpenAI to pick the most relevant pages that answer the question, visits those pages to parse important information from them, and then provides that context back to Semantic Kernel for leveraging with OpenAI.SalesHelpPlugin.cs
: Sample plugin for handling sales-related queries based on theSalesHelpPrompt.txt
instructions.SalesHelpPrompt.txt
: Contains a sample prompt for handling a hypothetical human transfer scenario for sales-related queries.
IMPORTANT: This project is intended for educational purposes only and should not be used for production workloads. The creators and contributors of this project accept no responsibility for its functionality, reliability, or any consequences arising from its use.
For a detailed overview of the conversation flows and how the conversation topic classifiers work, please refer to the Orchestration and Conversation Topic Classifiers section.
This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License. To view a copy of this license, visit CC BY-NC 4.0.
This project is licensed for free use for educational and non-commercial purposes only. Commercial use is strictly prohibited. The software is provided "as is," without warranty of any kind, express or implied.
Contributions to improve the educational value of this project are welcome. Please follow these steps to contribute:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them with clear, descriptive messages.
- Push your changes to your fork.
- Submit a pull request with a clear description of your changes.
Disclaimer
Users of this project are solely responsible for ensuring their use complies with the terms and conditions of all third-party services utilized, including but not limited to Bing Custom Search, Azure services, and OpenAI. Users must also ensure their use of this project adheres to all applicable local, national, and international laws and regulations.
The creators and contributors of this project are not responsible for any misuse, data breaches, costs incurred, or any other liabilities arising from the use of this project or the third-party services it integrates with.