Skip to content

Latest commit

 

History

History

GenAI-ChatBot-application-sample

NetApp Workload Factory GenAI sample application

Introduction

The NetApp Workload Factory GenAI sample application enables external application developers to test authentication and retrieval from a published NetApp Workload Factory knowledge base by interacting directly with it in a web-based chatbot application. Its features are similar to the chatbot interface within the NetApp Workload Factory UI, and it uses the same Workload Factory API for conversations. As a developer, you can use this sample application to test published knowledge bases and see API examples that can help you develop your own chatbot application.

Application components

The NetApp Workload Factory GenAI sample application is a Next.js project bootstrapped with create-next-app.

The sample application uses Redux Toolkit with RTK Query for data fetching.

Requirements

Set up login providers

To get started, you need to configure one of the supported login providers. Configure the same login provider (issuer) that is used by the knowledge base that will integrate with the sample chatbot application.

Set up AWS Cognito

  1. Follow the Create user pool instructions to create a Cognito user pool.
  2. Use the Amazon Cognito documentation to find your user pool ID and user web client ID:
    1. Find your user pool ID.
      For example: aws cognito-idp list-user-pools --max-results=60 --output=table
    2. Find your web client ID.
      For example: aws cognito-idp list-user-pool-clients --user-pool-id $(USER_POOL_ID) --output=table
  3. Download and unpack the Workload Factory GenAI sample application source package.
  4. In the Workload Factory GenAI sample application source, rename the .env.local.sample file to .env.local.
  5. In the .env.local file, uncomment the corresponding section for the login provider you plan to use, and make sure the section for the other provider is commented out.
  6. In the .env.local file, change the following variables in the appropriate provider section to match your environment. Replace YOUR_KNOWLEDGE_BASE_ID with the knowledge base ID from Workload Factory:
    • NEXT_PUBLIC_LOGIN_PROVIDER=cognito
    • NEXT_PUBLIC_KNOWLEDGE_BASE_ID=YOUR_KNOWLEDGE_BASE_ID
    • NEXT_PUBLIC_AWS_USER_POOLS_ID=YOUR_AWS_USER_POOLS_ID
    • NEXT_PUBLIC_AWS_USER_WEB_CLIENT_ID=YOUR_AWS_USER_WEB_CLIENT_ID

Configure Active Directory with Amazon Cognito

  1. To integrate Active Directory with Amazon Cognito, follow the A guide to AD FS federation with Amazon Cognito user pools instructions (Steps 1 to 4).
  2. To configure SAML request signing, follow the instructions in Signing SAML requests.
  3. Specify the federated identity provider and authorization by adding the following variables to the .env.local file, with values that match your environment.
    • NEXT_PUBLIC_LOGIN_EXTERNAL_PROVIDER=YOUR_COGNITO_IDENTITY_PROVIDER_NAME
    • NEXT_PUBLIC_AWS_OAUTH={"domain":"<DOMAIN_PREFIX>.auth..amazoncognito.com","scope":["openid", "profile", "email"],"redirectSignIn":"http://localhost:9091","redirectSignOut":"http://localhost:9091","responseType":"code"}
    • Domain - The domain for your Cognito user pool.
    • Scope - Scopes specifying the access privileges.
    • redirectSignIn - The URL to redirect to after a successful sign-in.
    • redirectSignOut - The URL to redirect to after a successful sign-out.
    • responseType - The type of response to receive from the authorization server.

Set up Clerk

  1. Follow the Sign up instructions to sign up for a Clerk account.
  2. Download and unpack the Workload Factory GenAI sample application source package.
  3. In the Workload Factory GenAI sample application source, rename the .env.local.sample file to .env.local.
  4. In the .env.local file, uncomment the corresponding section for the login provider you plan to use, and make sure the section for the other provider is commented out.
  5. In the .env.local file, change the following variables in the appropriate provider section to match your environment. Replace YOUR_KNOWLEDGE_BASE_ID with the knowledge base ID from Workload Factory:
    • NEXT_PUBLIC_LOGIN_PROVIDER=clerk
    • NEXT_PUBLIC_KNOWLEDGE_BASE_ID=YOUR_KNOWLEDGE_BASE_ID
    • NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=YOUR_NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
    • CLERK_SECRET_KEY=YOUR_CLERK_SECRET_KEY
    • NEXT_PUBLIC_CLERK_TEMPLATE=YOUR_CLERK_TEMPLATE

Install the application

To install the sample application, run the following command:

npm install

Run the application

  1. To run the application locally, run the following command:

    npm run dev
  2. Open http://localhost:9091 with your browser to log in to the application.

Build the application

To build bundle.js, run the following command:

npm run build

Learn More