Hello, I have a form where my users can post a form.
I use form’s data to start an async job on my Python API.
I takes around 5mn and 30mn to complete the job for the API, but the API give immediate answer when the job is added to the queue.
When the job is done i need to send an event to my user and update my collection.
I think Webhooks are suited for this usecase but I can’t find it on Weweb nor the forum.
webhooks are used to notify your backend. To know if the job is done from your frontend you either poll requests to your backend to know when it’s done or use websocket/server sent events to send a completion message.
They require some work on your backend and custom js in weweb.
Does this need the user to be connected ?
The user need not be “online” when you send your email. You will need an event-based backend system to send the email. You basically have two kinds of approaches:
- A more full-featured backend like Xano, Supabase or Fastgen; or
- A specific workflow provided by the likes of Zapier, Make or Pipedream.
You might have an easy time getting started with #2 to manage a simple backend event if you don’t already have a backend to orchestrate these questions. Zapier costs more than Make, but it’s a lot easier to get started, and I recommend it to my business clients.
There are a plethora of choices on both sides of this option - I listed a few that I have seen work well for others. Use what is easiest for you.
This kind of back-end orchestration is a central topic in our State Change office hours and loom-enabled forum because it is harder and usually more removed from people who started from the design end.
Hi,
Thanks for your answer
I’m looking to send an email but to update data in the collection.
I don’t find anyway to send async data to weweb
what are you trying to do?
Do you need to send an email to the user? No need for the user to be connected to your app. Send a request directly to the service you use to send emails.
Do you need to update the data in another backend? Create an endpoint in your second backend and send the data.
Do you need to show the new data in the frontend of weweb? You need to use polling/websockest/server sent events and of course the user needs to be online on your app.
Ok thanks for the answer.
Do you need to show the new data in the frontend of weweb? → This is my case.
I will look at polling/websockest/server
Webhooks/SSE are more commonly used for data that can change “any minute now”. Like a chat interface - you can get data at any time, so getting pushed creates a high level of responsiveness.
For 5-30m wait time, a websocket approach is high work-to-return because the page is likely to invalidate in that time, meaning the user loads on their own. A reasonable workflow is that the user gets the email, and then they click the email to go back to your page. That loads your page anew.
The middle ground is a long poll. That has your front end trigger a collection refetch every X minutes. This is straightforward to do with a disconnected workflow and an action running a custom JS with “setInterval”.
All this assumes you have some sort of back-end storage to be polled to keep track of state.
Thinking outside the box, there’s a really interesting backend company called convex.dev that is websockets-first. They are not no-code first, so it would take some work to make it connect with Weweb. But their approach to state synchronization is to push as things change, which is intuitively what you are going for.
Convex is great, but the reactivity part for the frontend is tied to a reactjs implementation, while the generic ConvexHttpClient
handles normal non-reactive requests. There are unofficial attepmpts to integrate it with vue but of course it’s not on par with the official react client.