Can an agent developed using the Google ADK integrate with Dify workflows? #6354
-
|
For instance, could a Dify workflow be exported for use by an ADK-based agent to execute specific business processes? Workflows for various business scenarios can be validated for reliability on the low-code platform Dify. Once validated, they can be exported and flexibly integrated into the ADK-based agent. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Yes, but I would use Dify's runtime API as the integration boundary rather than trying to execute an exported Dify DSL file inside ADK. ADK does not provide a Dify-workflow executor. Keep the validated workflow published in Dify and expose it to the ADK agent as a function tool (or describe the endpoint with OpenAPI and use an ADK OpenAPI toolset). For example: import os
import requests
from google.adk.agents import Agent
from google.adk.tools import ToolContext
DIFY_API_BASE = os.environ["DIFY_API_BASE"].rstrip("/")
DIFY_API_KEY = os.environ["DIFY_API_KEY"]
def run_business_workflow(request: str, tool_context: ToolContext) -> dict:
"""Run the validated Dify business workflow for the current user."""
user_id = tool_context.state.get("authenticated_user_id")
if not user_id:
return {
"status": "error",
"error_message": "No authenticated user id is available",
}
try:
response = requests.post(
f"{DIFY_API_BASE}/workflows/run",
headers={
"Authorization": f"Bearer {DIFY_API_KEY}",
"Content-Type": "application/json",
},
json={
# Replace `request` with the Start-node variables
# defined by this particular Dify workflow.
"inputs": {"request": request},
"response_mode": "blocking",
"user": str(user_id),
},
timeout=105,
)
response.raise_for_status()
except requests.RequestException as exc:
return {
"status": "error",
"error_message": f"Dify workflow request failed: {exc}",
}
payload = response.json()
run = payload["data"]
return {
"status": run["status"],
"outputs": run.get("outputs", {}),
"workflow_run_id": payload["workflow_run_id"],
"error_message": run.get("error"),
}
root_agent = Agent(
name="business_agent",
model="gemini-2.5-flash",
instruction="Use run_business_workflow for the validated business process.",
tools=[run_business_workflow],
)A few important details:
The exported Dify DSL is still useful for versioning and importing the workflow into another Dify deployment. If the goal is to remove the Dify runtime completely, the workflow logic must instead be reimplemented as ADK agents/tools; the export itself is not portable executable code for ADK. Docs: Dify Run Workflow API · ADK function tools · ADK OpenAPI tools |
Beta Was this translation helpful? Give feedback.
Yes, but I would use Dify's runtime API as the integration boundary rather than trying to execute an exported Dify DSL file inside ADK. ADK does not provide a Dify-workflow executor. Keep the validated workflow published in Dify and expose it to the ADK agent as a function tool (or describe the endpoint with OpenAPI and use an ADK OpenAPI toolset).
For example: