π₯How to connect FirebaseDB to Copilot
In this guide, we will learn how to create a Functions call to push medical records to Firebase Realtime Database via a conversational Copilot meant for Community Health Workers.
Scenario
A CHW visits a beneficiary for a monthly checkup, taking notes by hand due to unstable network connectivity that disrupts data entry in the Android app.
Proposed Copilot
The CHW sends a voice note via WhatsApp. It transcribes data for approval and updates the medical database hosted on Firebase Realtime Database, avoiding connectivity issues.

You can try the WhatsApp Workflow here:
You can tweak the Workflow here:
Create the Firebase Function
Step 1: Create a Firebase project


Step 2: Create a Realtime DB in Firebase
Once you have created the RTDB, copy the RTDB URL



Step 3: Duplicate the Firebase Function
Head to the FirebaseDB example in Gooey.AI (see the link below), duplicate the example by using the βSave as Newβ button and adding it to your workspace


Step 4: Paste the RTDB URL in Gooey.AI Functions
Paste the RTDB URL from Step 2 and replace it in the `firebaseURL` as shown below

Step 5: Create a path in Firebase RTDB
Head back to your Firebase Realtime Database and add a name value to the RTDB, eg data

Step 6: Get Firebase API key


Step 7: Add the Firebase API key to Gooey Secrets
Go back to Function you have created in Gooey.AI, scroll down to βSecretsβ section. Click on the βAddβ button

Add the βnameβ as FIREBASE_API_KEY and the API key which you copied from Firebase in the βvalueβ section, and save the key.

Once its saved, select it from the drop down.

Know more about adding secrets here
Step 8: Test function
Step 8.1: You can hit βRunβ to test if the function is working.
If the log shows a βsuccessfulβ message. Your screen should show this message:

Step 8.2: Please check the firebaseRTDB for data updates. Your data should have uploaded.

Step 9: Save the workflow
Save the changes by clicking βUpdateβ
On saving the function to your workspace, please remember to add a detailed description of what the function does, this will allow the AI Copilot to use the functions in an agentic way

Add Firebase Function to Copilot
Step 1: Add function to Copilot
Duplicate the example by using the βSave as Newβ button and adding it to your workspace
Scroll down to the βDeveloper Tools and Functionsβ section in the Copilot, toggle it on and select the Firebase Function that you saved.

Step 2: Add prompt instruction
Your prompt needs to be a bit detailed to make sure that the Functions are working properly. You need this:
To make sure Copilot knows it needs to call a Function at appropriate time,
To ensure that LLM translates natural language conversation to JSON data structure as per your requirement
Your prompt could look something like this:
What is the prompt doing?
In point 2 of the prompt, we have shared all the information the Copilot must collect to create a record.
In point 3, we provide a FIXED json format for the LLM to output. This ensures that the data pushed to the FirebaseDB is always in the same format, which is important for retrieval
In point 4, we instruct the Copilot to utilize Functions when the user requests to retrieve or push information.
Step 3: Test copilot
In the chatbox of the Copilot Builder, you can run a test to check whether the Copilot is working.
If the Function is run, you can see the widget with all the details.

You can also confirm if the data has been created and stored by logging into the Firebase RTDB like Step 8 from above.
Step 4: Save the workflow
Save the changes by clicking βUpdateβ.
Last updated
Was this helpful?
