Integration
Memory for Dify agents
This page shows how to add Harny memory to a Dify app so each person's facts are stored with dates and recalled per user.
What the framework does not keep
- Which value is current. Harny memory is dated: a changed value with a newer timestamp becomes the current value, and the earlier value stays answerable by date.
- When a fact happened. Each item you send to Harny can carry a
timestamp, so a question about an earlier date can be answered by date. - One person across sources. Harny keeps a private memory for each person, and you recall it per user.
The pattern: HTTP requests
Your workflow runs a recall request before the model node. It sends the person's question and the user id from the workflow input, and the returned memories go into the model's context. Keep the app key on the server side and out of any browser.
After the model answers, a second HTTP Request node sends the exchange to ingest. The X-Harny-User header carries your id for the person.
POST https://api.harny.ai/v1/memory/recall
Authorization: Bearer <app key, stored as a secret variable>
X-Harny-User: <the user id from the workflow input>
Content-Type: application/json
{ "query": "<the question>", "identity": "<the user id from the workflow input>" }What recall returns
Memory results with dated sources and source labels. Every result names the data point (source) behind it and the date it happened.
POST https://api.harny.ai/v1/memory/ingesttakesid,content,labelandtimestamp.POST https://api.harny.ai/v1/memory/recalltakesqueryandidentity, and returns results withsources.
Example: your agent asks “what is the Acme pilot budget?” and gets this back. Your code hands the model the content and the source label, so it can say who said it and when.
{
"asOf": "2026-07-29T00:00:00Z",
"results": [
{
"rank": 1,
"occurredAt": "2026-07-28T16:00:00Z",
"content": "Acme pilot budget: currently 40k.",
"sources": [
{ "sourceId": "call-8821", "label": "Email from Nadia" }
]
}
]
}When to use which
- Use Dify's own state for the current workflow run: the inputs, the intermediate outputs and the steps the workflow is in right now.
- Add Harny when a fact must persist across runs, carry a date, or be recalled for one person later.
Frequently asked questions
Is a package needed?
The Memory API is an HTTP API, so you call it from the server side of your Dify deployment. Harny is never called from a browser.
Where does the user id come from?
It comes from the workflow input that your app sets for the signed-in person. The X-Harny-User header takes that id, and an end user needs no Harny account.
Go on. Get Harny.
The first 500 monthly-active end users are free for good. Create an app key and make your first call in minutes.