Consider ChatGPT, where a user sends a request and as soon as the response is generated, it is displayed in the repeating group.
I repeated this using frontend workflows, it turned out to be much easier. So after my last action in the workflow was completed, the repeating group received the latest created things from the database.
With the backend, i can’t get it to work the same way, and im not sure what filters or actions to use to display the latest created thing from the backend workflow in the repeating group.
As soon as the event is detected, the workflow triggers and schedules the API workflow. In the API workflow, a sequence of actions occurs that creates a new entry in the database. The problem is that as soon as the workflow is triggered, the repeating group starts looking for the latest thing in the database and displays the previous one instead of the one being generated by the API workflow.
The workflow action happens instantly, and i suspect that the API Workflow does not have time to finish its work while the repeating group has already retrieved the last item.
If it’s not quite clear what i wrote, id be happy to attach screenshots and make it clearer if this information is not enough…
Hi, you can “refresh” the RG by using action “Display list in Repeatin Group” at the end of your frontend workflow. Maybe add a pause before next action if your API workflow take some time to process.
Hope this help
In this case, i would have to specify the data source as the result of step 1 (which schedules the API workflow), but an error occurs here.
However, as you mentioned, i can also pause before the next action and, instead of specifying the result of step 1 (which schedules the API workflow), i can point to the most recently created item in the database. This will likely work.
But then i have a question: how long should the pause be? Since each response takes a different amount of time.
I use states, but i don’t quite understand how to retrieve information from the backend. Are there any functions in Bubble that i might not be aware of? I can only use the information when the backend updates the database.
Yes the pause is tricky because for short response you dont want your user to wait 10s before you refresh the RG.
You can only use the response of an API workflow if you call it through the Bubble API Connector Plugin. Call the url of your workflow (see endpoint doc). Use this call as Action.
Then you can call this API in your frontend workflow (it will process the backend workflow) and then use the Result of Step’s response.
One more question: what is the actual data source of the repeating group with the response? Maybe the real problem is there, because your RG is supposed to show the last entries of the database without to be refreshed.
Custom state - current chat, is my main data source, which means that when a user creates a chat, the RG looks at the entries in this chat.
I also have a floating group that displays the user’s chat list, and im not sure why, but as soon as the backend workflow is executed, the chat title immediately appears in the floating group, and if you click on this chat, its content will appear.
However, to open this chat, the user needs to open the floating group, which is not very good for UX.
I like your idea about calling the workflow through the Bubble API Connector Plugin, will try for sure!
Without seeing your RG setup it is hard to tell what is the actual issue.
If the RG is set to be :make static you should change that
This operation converts a list that relies on dynamic data, e.g., input’s values in search constraints, and converts it into a list with the current items. Once converted to static, the list will not change if underlying values change. Note that this works only within the context of workflows; it will not change the behavior of repeating groups. Caution: This is an advanced feature.
If the RG is not set to make static, you should report a bug to Bubble that the RG is not updating in real time
If your RG is not set to static and the RG source is set to show :last item or :first item, you may have to change it to the other…I believe last item is to show the latest item created.
If your data is not getting created in the DB, you need to fix your backend workflow so the data is saved
When these two workflows are triggered, they create a new entry in the database.
In the first case, with “new-chat,” a new chat is created to which two messages (from AI and user) are assigned, but for some reason, RG does not display this immediately (so i have to open the new chat every time through the floating group).
In the second case, with “resume-chat”, after the newly created chat is opened through the floating group, all new requests are immediately displayed in RG and there are no problems here.
This is using a backend workflow called resume-chat?
This is using a backend workflow with an API call that is called new-chat…you might want to put the API call to ChatGPT into a custom trigger in the backend, so the flow for the new-chat backend workflow will first trigger the custom trigger which runs the API call, and uses the return data function (should be available in backend workflows the same way it is available with on page custom triggers)…this way the API call is ensured to run and complete before the other actions in the new-chat are run, which are intended to save to the database.
Also, ensure the API calls are not failing.
My assumption is it doesn’t display immediately as it is waiting for the API call response to populate the data entry in Bubble.
Yes, i also think that the problem lies there. I tried the same thing but using frontend workflows instead of backend, and instead of API workflows i used custom actions, and it worked perfectly because the RG would refresh after the last step in the custom action was completed.
But the problem is that the response takes 3 times as long, or even longer, compared to using an API workflow. When i use an API workflow, i get the response very quickly, but the RG refreshes obviously faster and doesn’t see the new data lol.