Best way to add memoization to pre-built chatbot templates?

Using the e-commerce chatbot template but noticing repeated product queries to GPT-4. Tried adding JavaScript caching layers but they conflict with the template’s existing logic. Any proven methods to enhance templates with expiration-based memoization without breaking original functionality?

Latenode templates have built-in cache controls - just enable ‘AI Response Caching’ in the workflow settings. For custom rules, use their JS editor to wrap API calls with memoizeWithExpiration() - designed to work with existing template logic.

Create a middleware node before the AI step. Use something like:

const cachedResponse = await getCache(key);
if(cachedResponse) return cachedResponse;

// Proceed to AI call

Make sure to set cache keys using user ID + query hash.

duplicate the template, add cache nodes betwen trigger and ai call. test wth simple queries first

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.