Files
mem0/integrations/zapier-mem0/searches/get_memories.js
T
Himanshu-Sangshetti e66e97b725 fix(integrations): address code-review findings
n8n: throw on FAILED memory events (was silently returned), poll on any
non-terminal status (PENDING or RUNNING), use top_k (not limit) for
search, coerce search/getAll responses to arrays, guard invalid-JSON
metadata, reject empty updates, mark user_id required; lint clean.

Zapier: coerce boolean fields (String(x) !== 'false') + boolean defaults
so "Wait"/"Infer = No" are honored, throw on HTTP >= 400 (was silent
empty/fake-success), throw on FAILED events, use top_k, numeric coercion
with clamping, mark user_id required.
2026-07-20 11:55:29 +05:30

33 lines
867 B
JavaScript

'use strict';
const perform = async (z, bundle) => {
const body = {};
if (bundle.inputData.user_id) body.filters = { user_id: bundle.inputData.user_id };
const response = await z.request({
url: '/v3/memories/',
method: 'POST',
params: { page: 1, page_size: Math.max(1, Math.floor(Number(bundle.inputData.limit) || 50)) },
body,
});
const data = response.data;
return Array.isArray(data) ? data : data.results || [];
};
module.exports = {
key: 'get_memories',
noun: 'Memory',
display: {
label: 'Get Memories',
description: 'List stored memories for a user.',
},
operation: {
perform,
inputFields: [
{ key: 'user_id', label: 'User ID', type: 'string', required: true },
{ key: 'limit', label: 'Limit', type: 'integer', default: 50 },
],
sample: { id: '00000000-0000-0000-0000-000000000000', memory: 'User loves hiking' },
},
};