⚠️ This lesson is retired and might contain outdated information.

Firebase Intro

Tom Chant
InstructorTom Chant
Share this video with your friends

Social Share Links

Send Tweet
Published 2 years ago
Updated 2 months ago

We will learn how to integrate a Google Firebase database into our project to persist chat conversations. By storing the conversation in the database, users will be able to pick up where they left off even after refreshing or reloading the page.

Additionally, we will provide the functionality to reset the chat, allowing users to delete the conversation and start fresh. The process involves removing the conversation array from the front end and storing it in the database. When needed, we can retrieve the conversation from the database and use it when making API calls to the OpenAI service.

To get started, we will create a Google Firebase account and set up the required database. This lesson will guide you through the steps to seamlessly integrate Firebase into your project and enable chat persistence.

[00:00] OK, so we're going to add a Google Firebase database to this project, so we can persist the chat. Now, what does that mean? Well, let's check our specific aims. We want to persist the chat so that a user can pick up where they left off after a refresh or reload. So the conversation will be stored in the database

[00:19] and the user can close the page, turn off their laptop and come back and continue the conversation at a later date. We want to give the user the ability to reset the chat, so they should be able to delete the conversation and start a fresh conversation from the beginning. So how is this going to work? Let's take a look at a diagram.

[00:39] At the moment, all of our code is on the front end and we've got an array holding our conversation. We send that off to OpenAI and it sends us back a response. What we're going to do now is remove the array where we store the conversation on the front end, we're going to create a database and we're going to store the conversation array

[01:00] in that database. When we need it, we'll bring it down to the front end and use it when we make calls to the OpenAI API. To start this off, we need a Google Firebase account and we need to set up a database. So let's start doing that next.

egghead
egghead
~ just now

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today