CONNECT APP
Build with Dify
Leading Agentic Workflow Builder
Artificial Intelligence (AI)
- API key
MCP
Give your agent Dify tools
Every Dify action is exposed as an MCP tool on Pipedream's remote server. Point a client at it with your end user's ID and Connect resolves that user's Dify account for each tool call — you store no tokens.
// accessToken: mint a short-lived token with the Connect SDK — see the MCP guide
const transport = new StreamableHTTPClientTransport(
new URL("https://remote.mcp.pipedream.net/v3"),
{
requestInit: {
headers: {
Authorization: `Bearer ${accessToken}`,
"x-pd-project-id": "{project_id}",
"x-pd-environment": "production",
"x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
"x-pd-app-slug": "dify",
},
},
},
)
const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)
const { tools } = await mcp.listTools()
// e.g. run Get App Parameters:
const result = await mcp.callTool({
name: "dify-get-app-parameters",
arguments: {},
})# access_token: mint a short-lived token with the Connect SDK — see the MCP guide
headers = {
"Authorization": f"Bearer {access_token}",
"x-pd-project-id": "{project_id}",
"x-pd-environment": "production",
"x-pd-external-user-id": "{external_user_id}", # any stable ID for this user in your system
"x-pd-app-slug": "dify",
}
async with streamablehttp_client("https://remote.mcp.pipedream.net/v3", headers=headers) as (read, write, _):
async with ClientSession(read, write) as session:
await session.initialize()
tools = await session.list_tools()
# e.g. run Get App Parameters:
result = await session.call_tool("dify-get-app-parameters", {})API PROXY
Call the Dify API directly
For an endpoint with no pre-built tool, the Connect proxy forwards your request to the Dify API with the connected user's credentials attached. You store no tokens and write no refresh logic.
const resp = await pd.proxy.get({
externalUserId: "{external_user_id}", // any stable ID for this user in your system
accountId: "apn_xxxxxxx",
url: "https://api.dify.ai/v1/info",
})
// Any allowed Dify endpoint works here. Pipedream attaches the
// connected account's credentials to the outgoing request.# The path segment is the target URL, URL-safe base64 encoded:
# https://api.dify.ai/v1/info
curl "https://api.pipedream.com/v1/connect/{project_id}/proxy/aHR0cHM6Ly9hcGkuZGlmeS5haS92MS9pbmZv?external_user_id={external_user_id}&account_id=apn_xxxxxxx" \
-H "Authorization: Bearer {access_token}" \
-H "x-pd-environment: production"SDK
Run Dify actions from your backend
Connect a user's Dify account once, then run Get App Parameters on their behalf from your own code — TypeScript, Python, or plain HTTP.
import { PipedreamClient } from "@pipedream/sdk"
const pd = new PipedreamClient({
projectId: process.env.PIPEDREAM_PROJECT_ID!,
clientId: process.env.PIPEDREAM_CLIENT_ID!,
clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
projectEnvironment: "production",
})
const result = await pd.actions.run({
id: "dify-get-app-parameters",
externalUserId: "{external_user_id}", // any stable ID for this user in your system
configuredProps: {
dify: { authProvisionId: "apn_xxxxxxx" },
},
})from pipedream import Pipedream
pd = Pipedream(
client_id="{oauth_client_id}",
client_secret="{oauth_client_secret}",
project_id="{project_id}",
project_environment="production",
)
result = pd.actions.run(
id="dify-get-app-parameters",
external_user_id="{external_user_id}", # any stable ID for this user in your system
configured_props={
"dify": {"authProvisionId": "apn_xxxxxxx"},
},
)curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
-H "Content-Type: application/json" \
-H "X-PD-Environment: production" \
-H "Authorization: Bearer {access_token}" \
-d '{
"external_user_id": "{external_user_id}",
"id": "dify-get-app-parameters",
"configured_props": {
"dify": { "authProvisionId": "apn_xxxxxxx" }
}
}'TOOLS
Dify actions
On-demand operations your product or agent can configure and run on behalf of a connected user.
-
Get App Parameters
actionReturn the connected Dify app's configuration: itsuser_input_form(the exact input variable names, types, and which are required), file-upload limits, opening statement, and suggested questions. Call this before Run Workflow to know what to pass in itsInputsparameter, instead of guessing variable names. Example: an app with one required text variable returns{ user_input_form: [{ "text-input": { variable: "city", label: "City", required: true, default: "" } }], opening_statement, suggested_questions, file_upload, ... }, so pass{ "city": "..." }asInputs. See the documentationRead-onlyv0.0.1 -
List Conversations
actionList a Dify Chatflow, Chatbot, Agent, or Legacy Agent app's conversations, most recently active first. Conversations are scoped byUser, so pass the same value used to create those conversations to see that end user's threads. Example:Useruser-123,Limit20→{ data: [{ id, name: "iPhone Specs Chat", inputs, status: "normal", created_at, updated_at }], has_more: true, limit: 20 }. Ifhas_moreistrue, call again withLast Conversation IDset to theidof the last conversation indata. Pass a conversation'sidto List Messages to read it. See the documentationRead-onlyv0.0.1 -
List Messages
actionReturn a Dify Chatflow, Chatbot, Agent, or Legacy Agent conversation's message history. The first call returns the latest messages; page backward into older ones withFirst Message ID. Use List Conversations to find aConversation ID. Each message includes thequery/answerpair, so this is how an agent reconstructs prior turns of a conversation instead of relying on its own memory. By default each message is trimmed toid,conversation_id,query,answer,status,error,feedback, andcreated_at; setInclude Full Detailsto also get retrieved knowledge-base passages (retriever_resources), agent reasoning (agent_thoughts), files, and token usage. Example:Conversation ID45701982-8118-4bc5-8e9b-64562b4555f2,Useruser-123→{ data: [{ id, conversation_id, query: "What are the specs of the iPhone 13 Pro Max?", answer: "...", status: "normal", feedback: { rating: "like" }, created_at }], has_more: true, limit: 20 }. Ifhas_moreistrue, call again withFirst Message IDset to theidof the first message indatato get older messages. See the documentationRead-onlyv0.0.1 -
List Workflow Logs
actionList past runs of a Dify Workflow app, newest first, with each run's status, token usage, step count, and timing. Only Workflow apps record these logs: a Chatflow, Chatbot, Agent, or Text Generator app's key returns an empty page, not an error. For runs started through the API,created_by_end_user.session_idis theUservalue sent with that run, which is useful for tracing a run back to its caller and for filtering withUser. Runs started by a team member inside Dify havecreated_by_end_user: nulland an account undercreated_by_accountinstead. Each entry is a run-level summary; node-by-node execution logs for finished runs aren't available. Example:Statusfailed,Limit5→{ data: [{ id, created_by_role: "end_user", created_by_end_user: { id, session_id: "user-123", type: "service-api" }, workflow_run: { id, status: "failed", error, total_tokens, elapsed_time } }], page: 1, limit: 5, total: 12, has_more: true }. Ifhas_moreistrue, call again withPageincremented by one. See the documentationRead-onlyv0.0.1 -
Run Workflow
actionRun the published workflow of the Dify app that the connected API key belongs to, and return its outputs. Only works for Workflow-type apps: a Chatflow, Chatbot, Agent, or Text Generator app's key returns anot_workflow_apperror. Requires the workflow to be published; an unpublished workflow returns aninvalid_paramerror. Use Get App Parameters first to learn the input variable names. Example:Inputs{ "city": "San Francisco" },Useruser-123→{ workflow_run_id, data: { id, status: "succeeded", outputs: { result: "..." }, total_tokens, elapsed_time } }. This action usesblockingresponse mode, which waits for the run to finish before returning; long-running workflows on Dify Cloud risk being cut off by the platform's 100-second edge proxy timeout, in which case the run may still complete server-side but this action will not see the result. See the documentationWritev0.0.1
No Dify triggers are available yet.
- App slug
- dify
- Authentication
- API key
- Categories
- Artificial Intelligence (AI)
- Actions
- 5
- Triggers
- 0
- API proxy
- Available