Skip to content

Latest commit

 

History

History

chatbot-end

Chatbot - completed code

An AI chatbot that uses the PaLM API to answer questions.

chatbot-final.mp4

To run with a real firebase project (recommended)

Run these commands in your terminal:

  1. Navigate to this web app folder and install dependencies:
cd chatbot-end
npm install
  1. Specify which project Firebase should use:
firebase use <name-of-your-project>
# For example: firebase use codelab-ai-extensions
  1. Enable the web frameworks experiment:
firebase experiments:enable webframeworks
  1. Initialize Firebase hosting:
firebase init hosting

Use default options for all prompts.

  1. Deploy the extension used in this web app:

Note: If you are asked Would you like to delete any other extensions, select No.

firebase deploy --only extensions
  1. Deploy the Firestore and Cloud Storage Security Rules:
firebase deploy --only firestore:rules,storage
  1. In your code editor, edit the lib/firebase/firebase-config.js file with your Firebase configuration.

  2. Back in your terminal, run the web app:

firebase emulators:start --only hosting
  1. Open http://localhost:5000/ in your browser (or whatever URL is presented to your in your terminal) to see the result.

To run locally with mock data (not recommended)

This uses mock data, and has no AI functionality.

This is only useful for codelab authors, or learners who are unable to use a real Firebase project.

  1. In your terminal, navigate to this web app folder:
cd chatbot-end
  1. Run this command in your terminal:
firebase emulators:start --project demo-codelab-chatbot --import=../firestore-export/
  1. In the root of the chatbot project folder you are working in, replace the .env.development file with these contents:
NEXT_PUBLIC_IS_TEST_MODE=true
  1. Edit the lib/firebase/firebase-config.js file with your emulator configuration.

  2. In a new terminal tab:

npm install
npm run dev
  1. Open http://localhost:3000/ in your browser to see the result.