Is there a way to fire an api call and trigger an ...
# pacc-nov-19-20-2024
d
Is there a way to fire an api call and trigger an automation/flow run, but then have the results of the flow run returned as a response to the source of the api call?
👀 1
e
@Daniel Adayev Not exactly if I’m understanding the question correctly. Interacting with Prefect Cloud to run a flow doesn’t fit in the span of a single API call.
You could run a flow inside of an API. A flow is just a wrapped function after all so if you could stick it in an API and execute it as part of it.
What scenario did you have in mind? I imagine it would be a pretty quick flow if it gets executed in ~<1s
d
Sorry for the lack of context here. My use case is I'm using the sklearn library for some fuzzy matching. It's not how api calls are meant to be used as this means there should be like a 10-15 second lag between the call and response, but I would ideally like to grab data out of salesforce, pass it into my flow, get a % match on how similar 2 strings are, and then push that back onto a record in salesforce. Without the use of responses, I would have to grab that data, process it, and then use the salesforce api to push that data in. With response handling, it makes processing these little bits of data easier.
I also understand though this this is not how prefect was intended to be used, I was more just curious
e
Ah, I see. Great question! Prefect is used in all sorts of ways so not an unusual question. Since you need to respond to the API request directly I do think you’d want a middleware API layer. Prefect webhooks and the API generally don’t allow custom responses to the same request AFAIK. That being said, it could be a pretty light flask/fast-api request that just calls
run_deployment
(which I do believe allows you to retrieve the result).