🤖 ChatGPT meets Firestore: Create Intelligent Conversations in Your App
Tags: chatgpt, firebase, opensource, chatbot
Published: 2023-06-30 15:51:52

### 👋 🤝 Hello, everyone! It's been a long time!

<img src="https://media.giphy.com/media/l1J9urAfGd3grKV6E/giphy.gif" />

-------------------------------------------------------------

## ⚡️ Quick Story

> I can still vividly recall the excitement I felt when Firebase announced [Extensions](https://firebase.google.com/products/extensions) at the [2019 Summit in Madrid, Spain](https://youtu.be/DkXtV-XzYOQ). I immediately saw the immense value they could bring to us developers, especially for those of us heavily relying on Firebase products.

Now, as AI's popularity soars, I've seen a multitude of innovative applications powered by this technology, giving rise to increasingly beneficial products. Truly, the **sky's the limit** when it comes to AI's potential!

-------------------------------------------------------------

## 👀 What's New?

> It's been a week now since the Firebase Team approved my first-ever Firebase Extension: [**Chatbot with ChatGPT**](https://extensions.dev/extensions/shiftescape/firestore-chatgpt-bot) ! 🥳 👏 🍾

It is an extension that integrates the [ChatGPT Model from OpenAI](https://openai.com/chatgpt) and designed to facilitate AI-based conversations in real-time chat applications backed by [Firestore](https://firebase.google.com/docs/firestore).

By making use of Firebase and ChatGPT's powerful language processing capabilities, this extension empowers developers to implement AI-based automated interactions within their apps, making them more engaging and interactive!

-------------------------------------------------------------

## 📌 How to Use

Setting up and using `Chatbot with ChatGPT` is easy.

Go to the [extensions page](https://extensions.dev/extensions/shiftescape/firestore-chatgpt-bot) and click `Install in Firebase console` button. Follow the prompts, and you're good to go!

-------------------------------------------------------------

<img src="https://media.giphy.com/media/G5XoVH1Rh8tL7MbC5f/giphy.gif" />

-------------------------------------------------------------

## ⚙️ Configurable Parameters

- **`Collection Path`**: Path to a Cloud Firestore collection which will represent a discussion with OpenAI's ChatGPT.

- **`Prompt Field`**: The field in the message document that contains the prompt. (Default: `prompt`)

- **`Response Field`**: The field in the message document into which to put the response. (Default: `response`)

- **`Cloud Functions Location`**: Where do you want to deploy the functions created for this extension? For help selecting a location, refer to the [location selection guide](https://firebase.google.com/docs/functions/locations).

- **`Language Model`**: Which language `model` do you want to use? Refer to [OpenAI's Model Reference](https://platform.openai.com/docs/models/overview).

- **`Temperature`**: What sampling `temperature` to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. [Learn more here](https://platform.openai.com/docs/api-reference/chat/create#chat/create-temperature).

- **`Nucleus Sampling Probability`**: An alternative to sampling with temperature, called `nucleus sampling`, where the model considers the results of the tokens with `top_p` probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. [Learn more here](https://platform.openai.com/docs/api-reference/chat/create#chat/create-top_p).

-------------------------------------------------------------

## 🎬 Demo

For this demo, here's my configured params:
- OpenAI API Key: `*******************`
- Collection path: `users/{uid}/messages`
- Prompt field: `(default - prompt)`
- Response field: `(default - response)`
- Language Model: `GPT-3.5`

![Chatbot with ChatGPT Demo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tcnyls8je2t4o8y9fd41.gif)

-------------------------------------------------------------


## That's all folks! 🤜🤛

Give it a try, please share your experiences, thoughts, and suggestions. Also, please don't forget to share this to your friends! 😊

Thank you so much! 🙇

-------------------------------------------------------------

<img src="https://media.giphy.com/media/12noFudALzfIynHuUp/giphy.gif" />