I'm trying to create an application to extract data from a PDF. Tried Retool Ai but the output is not consistent enough. So I'm trying to use a third party OCR solution.
I can trigger the extraction from my app, but the response is send back to a webhook. Of course I can catch this response in a Workflow, but how can I parse the received data back in my app?
I would like to see the data entering my app 'live', without reloading the app.
Anyone any suggestions how to solve this case?
Hi Ronaldvm,
Thanks for reaching out and I hope I can help!
I wanted to clarify your current application flow for this PDF extraction:
- Upload the PDF in the application
- Trigger the workflow from the application passing in the encoded PDF string
- Within the workflow send encoded string to third party OCR
- Return response in workflow via response block that includes OCR response
- Read workflow’s response in application within appropriate Retool UI component
Let me know if any of these steps don’t match what your process currently is or are unclear to make sure we are on the same page.
How is the data currently entering your app that it is not 'live'?
Thanks!
Hi Taylor,
Slight differnce in your summary and the actual case:
- I get the PDF out of a Supabase DB - but in essence not a difference
- Correct
- Correct
- Response is coming in another Workflow as it's triggerd by a Webhook called by the thrid party.
- Get the response from the 2nd Workflow and use it within my Retool App
Hope you can advice,
Thanks,
Ronald
Hi Ronald,
Thanks for clarifying! For step 4, does the OCR have to return the response via a webhook or is there an option to send it back as a response to the original request?
For step 5, do you have an at least partially working solution for how you are accomplishing this? How are you getting the response into your app via the 2nd workflow?
There might be a possiblity to retrieve the data, (althought the solution advice to use the webhook function as it's more robust and consistent, for example if i'm not using the webhook I have to retrieve the last added or a time range). Besides the timing of retrieving the data could be a challenge, as not every PDF takes the same time extract.
Currently I'm saving the data into Supabase, and refresh a connected table (query) manually.
With that structure I did have one thought. For the query you have going to your Supabase you could use the query's advanced setting of enabling "run this query periodically" and set it for a duration that you are ok with. That way it will keep refreshing the data in your app without you needing to manually run, but you will need to think about how often you want it to hit your database.
It may also be helpful to check out the provided solution from this forum post: Button Script - Trigger API call, Poll Response and display loading will polling
Hi @Ronaldvm, I just wanted to check in and see how your workflow is doing and if polling helped with your use case.
Hi Taylor, thanks for you support.
This could do the job, I don't have a better idea aswell.. altough it feels a bit rickety..
Hi Ronald,
Agreed that it isn't the cleanest process, but I think if you have a process like this it could be viable.
- An application variable array that is populated with some kind of id for the pdf sent out that is added on request send.
- A query that is checking your table periodically. It is disabled when the app variable array is empty, but runs when it has id's in it.
- The periodic query checks for new entries in the table. This could be done by checking timestamps. When there is a match it will remove the matching id from the app variable array and then also trigger the other query in your app that you use to populate whatever you wanted to get refreshed on an update.
- If that was the last id in the array then the periodic query goes back to being disabled.
I just wanted to lay out what I was thinking, since I had been mulling it over during the holiday break. Maybe you already considered that.
One item that could be of issue that I haven't thought through is if the OCR fails to send something to your db or your table just never gets updated with the results of that request then the periodic query will run forever. Maybe a process for clearing the app variable array after a set amount of time.