Essentials
Best Practices
Follow these best practices to ensure a robust, secure, and efficient integration with Memoram.
Memory Management
- Be Selective: Only store information that is truly valuable for future interactions and personalization. Avoid storing trivial or redundant data.
- Summarize Effectively: Create concise, meaningful summaries. Summaries are often used for quick previews or relevance scoring, so make them informative.
- Use Importance Wisely: Reserve high importance scores (e.g., > 0.8 or 4-5 depending on the scale) for critical user information like core preferences, constraints, or facts.
- Tag Consistently: Develop and apply a consistent tagging strategy. This improves organization and makes retrieval more effective.
Security
- Secure Storage: Store developer API keys, user access tokens, refresh tokens, memory keys, and encryption keys securely. Never expose them client-side or commit them to version control.
- Minimal Scope (OAuth): When initiating the OAuth flow, request only the permissions (scopes) your application absolutely needs.
- Token Refresh: Implement proper logic to use refresh tokens to obtain new access tokens before the current ones expire. Handle token expiry errors gracefully.
- Data Minimization: Only collect and store user information necessary for your application’s functionality. Avoid storing sensitive data unnecessarily.
- Webhook Secret: Keep your Webhook Signing Secret confidential.
- Signature Verification: Always verify webhook signatures before processing the payload.
Performance
- Efficient Retrieval: Use specific tags and search queries (
/memory-blobs
GET parameters) to retrieve only the most relevant memories, rather than fetching large datasets. - Pagination: Use the
limit
andcursor
parameters when retrieving lists (memories, tags, access requests) to handle potentially large result sets efficiently. - Caching: Consider caching frequently accessed, less volatile data (like tags or user preferences stored in memories) where appropriate, respecting potential updates.
- Asynchronous Processing: For operations that might take time (e.g., complex processing after receiving a webhook), handle them asynchronously to ensure your webhook endpoint responds quickly.