Skip to content
Sub-Workflow: Preve...
 
Notifications
Clear all

Sub-Workflow: Prevent Duplicate API Calls & Manage Data Flow

8 Posts
4 Users
0 Reactions
6 Views
Jonathan_Sherman
(@jonathan_sherman)
Posts: 4
Active Member
Topic starter
 

Describe the problem/error/question

Hi, what's the most effective method to prevent unnecessary API calls in sub-workflows (or any workflow, for that matter) and also enable forwarding/retrieval of the last output from a sub-workflow? Based on the 'chat with sheets' example from callin.io, it appears the sub-workflow is loading the sheet with every chat entry. I'd prefer to load the sheet just once and be able to forward or retrieve its output from another workflow at any time. I'm aware of the callin.io get workflow nodes and webhooks, but I'm looking for a best practice approach. Thanks!

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Please provide the rewritten markdown content *it should be in the markdown format.

 
Posted : 23/07/2024 7:42 am
n8n
 n8n
(@n8n)
Posts: 97
Trusted Member
 

It seems your topic is missing some crucial details. Could you please provide the following information, if it applies?

  • callin.io version:
  • Database (default: SQLite):
  • callin.io EXECUTIONS_PROCESS setting (default: own, main):
  • Running callin.io via (Docker, npm, callin.io cloud, desktop app):
  • Operating system:
 
Posted : 23/07/2024 7:42 am
Jonathan_Sherman
(@jonathan_sherman)
Posts: 4
Active Member
Topic starter
 

I'm aiming for something similar to the below, although I recognize that the wait node cannot be used in this manner. This is merely to illustrate the concept. Essentially, the sub-workflow should begin with an initial state where data is loaded upon workflow activation. Subsequently, the data processing occurs as is standard practice, driven by the Execute Workflow Trigger. How can I achieve this or a comparable setup using the workflow and sub-workflow structure?

 
Posted : 25/07/2024 3:24 am
Jim_Le
(@jim_le)
Posts: 35
Eminent Member
 

Great point!

For most use cases, I wouldn't be concerned about the API limits. Are you encountering quota issues with your current workflow?

Regardless,

I believe the simplest solution is to incorporate chat memory into the agent. This allows tool results to be saved as part of the ongoing conversation. If the agent determines it has sufficient information from a previous message, it might opt not to use the tool again, thereby reducing API requests.

An alternative approach would be to build your own caching system, perhaps utilizing a fast and lightweight solution like Redis.

It's worth noting that you can set an expiration time for cached data, giving you control over how stale it can become. In the example below, I've set the expiration to 5 minutes.

 
Posted : 26/07/2024 10:38 am
Jonathan_Sherman
(@jonathan_sherman)
Posts: 4
Active Member
Topic starter
 

Thank you Jim, I believe I'll find both methods you provided useful. My current objective, however, is to develop a concise code example that exclusively utilizes callin.io nodes. I consider it good practice to bypass any superfluous API calls. If I were coding, I'd simply store it as a variable or read/write from disk. However, it appears that each execution in callin.io might discard the variable option? This leads to substituting your Redis approach with a callin.io node. But I'm unsure which node would be appropriate. Do you have any suggestions? Perhaps the in-vector memory store? Though this might not be as "general" as I'd prefer, as it's intended for embeddings. Essentially, what node can serve as a replacement for Redis?

 
Posted : 29/07/2024 3:25 am
Jim_Le
(@jim_le)
Posts: 35
Eminent Member
 

You might want to explore the “chat memory manager” and “window buffer memory” (found under Advanced AI > Other AI nodes > Miscellaneous > Chat memory manager) and connect it to your AI agent.

If you're open to a more intensive solution like using the in-memory vector store (though I'd advise against it!), another option is to paste the spreadsheet data directly into a code node and utilize it that way.

:thinking:

 
Posted : 30/07/2024 1:51 pm
Jonathan_Sherman
(@jonathan_sherman)
Posts: 4
Active Member
Topic starter
 

Thanks again - this should also work for self-hosted options

 
Posted : 01/08/2024 3:45 am
system
(@system)
Posts: 332
Reputable Member
 

This discussion was automatically closed 7 days following the last response. New replies are no longer permitted.

 
Posted : 15/08/2024 6:04 am
Share: