Demo of a customer support agent interface using NextJS and the OpenAI Responses API with File Search
Demo of a customer support agent interface using NextJS and the OpenAI Responses API with File Search
This repository contains a NextJS demo app of a Customer Service with a Human in the loop (HITL) use case built on top of the Responses API. It leverages the file search built-in tool and implements 2 views of a chat interface: one for the customer, and one for the human agent.
This demo is an example flow where a human agent would be assisted by an AI agent to answer customer questions, while staying in control of sensitive actions.
Features:
Feel free to customize this demo to suit your specific use case.
Set up the OpenAI API:
Clone the Repository:
git clone https://github.com/openai/openai-support-agent-demo.gitSet the OpenAI API key:
2 options:
OPENAI_API_KEY environment variable globally in your systemOPENAI_API_KEY environment variable in the project: Create a .env file at the root of the project and add the following line (see .env.example for reference):OPENAI_API_KEY=Install dependencies:
Run in the project root:
npm installRun the app:
npm run devThe app will be available at http://localhost:3000.
Initialize the vector store:
Go to /init_vs to create a vector store and initialize it with the knowledge base. Once you have created the vector store, update config/constants.ts with your own vector store ID.
To try out the demo, you can ask questions that will trigger a file search.
Example questions:
When an answer is generated, it will be displayed as a suggested response for the customer support representative. In the agent view, you can edit the message or send it as is.
You can also click on the "Relevant articles" to see the corresponding articles in the knowledge base or FAQ.
You can then continue the conversation as the user.
You can ask for help to trigger actions.
Example questions:
cancel_order actionreset_password actionget_order_historyNote that the functions that are executed are just placeholders and are not actually modifying any data, so the actions will not have any effect. For example, calling cancel_order won't change the status of the order.
To customize this demo you can:
config/constants.tsconfig/tools-list.tsconfig/functions.tsconfig/demoData.tsYou can also customize the endpoints in the /api folder to call your own backend or external services.
If you want to use this code repository as a starting point for your own project in production, please note that this demo is not production-ready and that you would need to implement safety measures such as input guardrails, user authentication, etc.
You are welcome to open issues or submit PRs to improve this app, however, please note that we may not review all suggestions.
This project is licensed under the MIT License. See the LICENSE file for details.
No open issues yet, or sync has not completed.