How to connect FirebaseDB to Copilot
Last updated
Was this helpful?
Last updated
Was this helpful?
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.
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.
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:
Once you have created the RTDB, copy the RTDB URL
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
Paste the RTDB URL from Step 2 and replace it in the `firebaseURL` as shown below
Head back to your Firebase Realtime Database and add a name value to the RTDB, eg data
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
If the log shows a “successful” message. Your screen should show this message:
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
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.
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:
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.
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.
Save the changes by clicking “Update”.