Cookbook Index
Hello, Dify!
Hack are some hack solution that may help you better use Dify.
And they might be supported by Dify officially in the future.
Quick Guide
CookbookInstructionsHow to download the DSL file?
How to copy the prompt?
Checklist
Hack You can leave some unused blocks without preventing you publish the app.
CookbookDetail Checklist
Conversation Variables
Hack Allow you assign constant to the “Conversation Variable”.
CookbookDetail Conversation Variable with Constant
Code block
LevelBeginner Write or generate Python code in Dify !
CookbookDetail Code block
CookbookExtra Python Debug
CookbookDSL File DSL
CookbookPrompt Prompt
DemoHelper Code Generator
Code block with API
LevelIntermediate Alternative way to call your favorite API, Not “HTTP Request” or “Tools-Custom”. More flexibility.
Code example
# Python & Dify
import httpx
def main(auth_bearer: str) -> dict:
url = "https://api.cloudflare.com/client/v4/accounts"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {auth_bearer}"
}
with httpx.Client() as client:
response = client.get(url, headers=headers)
data = response.json()
result = []
if data["success"] and "result" in data:
for account in data["result"]:
result.append({
"id": account["id"],
"name": account["name"]
})
return {"result": result}Dify Agent inside Chatflow or Workflow
Hack Allow you to use Dify Agent inside Chatflow or Workflow, just like the “Workflow as tool” feature.
This is a hack solution, not a official feature. Offical feature is coming soon.
CookbookDetail Dify Agent inside Chatflow or Workflow
TipRequirementI implemented with one-shot agent, so no history. I also implemented this with 1 input variable, you can either remove it, or use it, or add more of it.
So modify code is required.. However, you can try to use the code generator with the prompt I provided above, bring my code and the prompt, chat with some smart LLM like GPT-4o or Claude 3.5 Sonnet that help you modify the code.
Cloudflare KV for Persistent Storage
LevelIntermediate Example of using Cloudflare KV for persistent storage.
CookbookDetail Cloudflare KV for Persistent Storage
CookbookDSL File DSL
DemoHelper Get account_id by Cloudflare API
Better Personalized Memory Assistant
LevelAdvanceCookbookDetail Personalized Memory Assistant
CookbookDSL File DSL
DemoTry this Personalized Memory Assistant
Hack 2024-09-22 Out of date, conversation variable can greatly reduce the complexity of this example.
TipRequirement- You will need an Cloudflare account.
- You must finished the Cloudflare KV for Persistent Storage first.

