examples/showcases/enterprise-brex/README.md
This demo application highlights the capabilities of CopilotKit by demonstrating how to build an app that emphasizes authorization, supports multiple operations, and incorporates generative UI elements. The banking application scenario serves as a practical example of these features in action.
To get started, install the package and run the development server:
pnpm i
and then
pnpm dev
Open http://localhost:3000 in your browser to view the application.
Please ensure to export OPENAI_API_KEY=your-key to enable OpenAI functionality.
This app requires 3 environment variables to run, which should be added to an .env file in the root of the repository:
OPENAI_API_KEYSERVICENOW_USERNAMESERVICENOW_PASSWORDAuthorization is key in this app, with users assigned to different departments and roles.
Explore how user roles and departments impact the app's behavior. Navigate to the bottom left corner and switch between users. This is done through an app-wide context provided to the co-pilot.
Implemented in copilot-context.tsx, it's a wrapper component that includes useCopilotReadable and useCopilotAction hooks for anything app-wide.
The application offers various operations that can be performed through the co-pilot on different pages. Here are some examples:
/cards page, you can request the co-pilot to change a credit card's PIN or add a new card. Note that adding a new card may have different outcomes depending on the user's role./team page, the co-pilot can assist with inviting a new member, editing a member's role or department, or removing a member.The app demonstrates the power of Generative UI through two main examples in cards/page.tsx:
showTransactions useCopilotAction exemplifies the ability to present information via a component, eliminating the need for additional text or LLM follow-up.showAndApproveTransactions useCopilotAction demonstrates the capacity to solicit user action, specifically the approval of transactions. This process is done one transaction at a time, ensuring all are resolved.The app handles unsupported actions by redirecting users to the relevant page, optionally starting the task. Explore this on the main page:
This feature is implemented in copilot-context.tsx as navigateToPageAndPerform.
The SQL query generator at /sql leverages co-pilot chat with Generative UI to convert user questions into SQL queries. Users can pose questions like "Show me all transactions for my visa ending with 4242" or "Let's find the pending transaction for the policy assigned to the card ending with 4242" and receive a corresponding SQL query. The query can be copied or executed directly (execution functionality is currently unavailable).
The /api/v1 path serves as the primary endpoint for API requests, handling various routes that interact with the application's data. Notably, the data.ts file contains hardcoded data that is utilized throughout the application.