Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

For Dialogflow ES chatbot, using 3rd party Postgres database for knowledge bases and fulfillment?

Hi, I am building a Dialogflow ES chatbot using Supabase as my PostgreSQL database with CSV file storage to use as intent, training and fulfillment as I can use RESTful webhooks. Running into some blockers including how to set up webhooks on each end (I enabled this on my agent's Fulfillment section w/ the credentials from Supabase) via the API + Python client library. For context I am using the Streamlit framework as my UI for the chatbot and will deploy on Cloud Run. 

Any questions you might have feel free to ask for clarification, and any input/guidance is welcome. 

Solved Solved
0 10 1,518
1 ACCEPTED SOLUTION

hey!

Thanks for the detailed explanation. I have a couple of questions. Is supabase a requirement? My suggestions is that you are trying to build a custom solution while there other tools that are basically acheiving what you are building:
1. langchain
2. Dialogflow CX with the data store agents
3. Voiceflow with the Kowledge Base

I will suggest to you to check those solutions before moving forward to see if your solution still make sense ro you wanna switch to another one that we know it works just fine!

Best,

Xavi

View solution in original post

10 REPLIES 10

@mollycarroll  Just to get more details, are you planning to send webhook request on particular event/intent or generally you need to call webhook to fetch data?

Hi! I'm ideally trying to use webhook calls for most if not all intents, plus to fetch knowledge base data for responses/fulfillment. Does that help?

HI!

Can you please specify which blockers are you experiencing?

thanks!

I will work on a list of more specific blockers I'm facing and reply here once it's ready. Busy work day heh, but thank you for helping address my questions!

Hi @xavidop , here are the blockers/indecision problems I feel are most prominent for now, but I could be asking the wrong questions... I hope these help for better context, though.

TL;DR: Trying to use FAQ CSV files in Supabase for intent, training and fulfillment via the Dialogflow API (Python library) in my app code. Avoiding storing most if not all data in Dialogflow console itself. (but, what DO I need/have to put in Dialogflow itself?)

Supabase requires authentication to make changes to the database. (Possibly I could make a Postgres Row Level Security policy to bypass this..) Currently my test DB with my knowledge base FAQ CSV is read-only per the current policy, but would Dialogflow need some sort of way to do insert/update/delete operations on my knowledge DB? If so I think I could figure this out, but I am not sure if I need to. -- Figured this out as I wrote this! I can authorize access w/ API keys, if this is the way to do it.

To detect intent using my knowledge base in Supabase, could I use the Supabase Python client library's session methods (or even user auth methods?) to make the user's chat sessions continuous/stateful?
- Dialogflow has a SessionsClient class in the API, though it's definitely tailored toward accessing data housed in Google Cloud vs. other locations
- Supabase has session retrieval and setting methods, but seems to want to have a user actually sign up on my page w/ an account to have saved sessions... might be a token-based option but haven't figured this out yet

Another way to let Dialogflow manipulate my knowledge data could be to use Supabase's storage API; it uses buckets but maybe I refer to my CSV files stored there vs. the actual database? Then I would have access to methods for all forms of data manipulation from the API and can authorize Dialogflow w/ permissions for this.

Some references:

Detect intent w/ knowledge base - https://cloud.google.com/dialogflow/es/docs/knowledge-connectors#detect_intent_with_knowledge_base 

Using webhooks for fulfillment - https://cloud.google.com/dialogflow/es/docs/fulfillment-webhook 

GCP KnowledgeBasesClient - example of docs only explaining data stored in GCP - https://cloud.google.com/python/docs/reference/dialogflow/latest/google.cloud.dialogflow_v2beta1.ser... 

PostgREST-py library request docs - https://postgrest-py.readthedocs.io/en/latest/api/request_builders.html 

Supabase REST API docs - https://supabase.com/docs/guides/api 

hey!

Thanks for the detailed explanation. I have a couple of questions. Is supabase a requirement? My suggestions is that you are trying to build a custom solution while there other tools that are basically acheiving what you are building:
1. langchain
2. Dialogflow CX with the data store agents
3. Voiceflow with the Kowledge Base

I will suggest to you to check those solutions before moving forward to see if your solution still make sense ro you wanna switch to another one that we know it works just fine!

Best,

Xavi

Thanks for these suggestions! Supabase isn't a requirement, but what I do require is as much as possible to be free/open-source as I am an underpaid engineer lol. I will check these out (except Dialogflow CX, alas) and also this is why I'm avoiding stuff like Cloud SQL, Cloud Storage etc. else I'd be a lot faster. 

Dialgoflow CX or Voiceflow are quite cheap I think it is worth it to take a look at them, They will give a better outcome over time, trust me!

I've been heavily diving into Langchain, actually, and it has some great integrations with Google's AI technology including a chat LLM w/ Gemini and genAI embeddings with Google along with everything else in their Python package to integrate with Google. With Langchain's many connections I may end up not needing Dialogflow at all.. 😅 Of course, subsequent versions of this app could definitely use Dialogflow CX, Voiceflow + their knowledge base architecture. Time will tell since if my app is successful in its main purpose I will have more capital to invest in a more robust version. 🙂 
I appreciate all your input @xavidop !

thanks @mollycarroll keep us posted!!

Langchain is super powerful but when you want to implement a complex assistant with different conversation flows, it is quite complex thus DFCX enters in action!