Ai assistans + edge functions + flutterFlow

Database & APIs

πŸ”§ How to call a Supabase Edge Function (using OpenAI Assistant API) from FlutterFlow? Hey everyone, I'm building an AI assistant into my FlutterFlow app using the OpenAI Assistant API β€” but through a Supabase Edge Function (not a direct API call from the frontend). What I've done so far: Created a Supabase Edge Function that: Creates a thread via OpenAI API, Adds the user's prompt as a message, Runs the assistant, Waits for completion, Returns the assistant's reply as JSON. The function works fine when tested via Postman or curl. βœ… Here's my question: How can I call this Edge Function properly from FlutterFlow using the API Call action? I want to: Pass the user’s prompt from a TextField as the request body, Trigger the request via a button, Show the response from the assistant in a Text widget. Extra context: My Edge Function URL looks like: https://<my-project>.supabase.co/functions/v1/assistant The body should be: { "prompt": "Hello assistant!" } The response is: { "message": "Hello! How can I help you today?" } What I'm unsure about: Do I need a Custom Action to make this work in FlutterFlow? How can I securely include the Authorization header if my function requires a secret key? Any best practices for handling loading states and errors? Thanks a lot! πŸ™ Would really appreciate any help or a step-by-step example.

What have you tried so far?

What have you tried so far?

I created and deployed a working Edge Function in Supabase that calls the OpenAI Assistant API (thread > message > run > wait > return). I tested it in Postman and it works perfectly.

Then I went to FlutterFlow and did the following:

  • Created a TextField for user input and a Text widget for the response;

  • Set up an API Call action in FlutterFlow to call the Edge Function URL;

  • Passed prompt as JSON body using the TextField value;

  • Tried setting headers with Authorization: Bearer <anon or secret key>;

  • Created conditions and page state updates to show the response.

But when I trigger it in the app, nothing happens or the response is empty.

I’m not sure if I need a custom action instead of a regular API Call, or if I should handle the auth key differently.

Did you check FlutterFlow's Documentation for this topic?
No
1
1 reply