{
  "access": "public",
  "type": "tutorial",
  "format": "markdown",
  "title": "Building Workflows",
  "chunked": true,
  "url": "https://library.datagrout.ai/building-workflows",
  "summary": "**Create multi-step integrations across your tools**",
  "content_markdown": "# Building Workflows\n\n**Create multi-step integrations across your tools**\n\nThis guide covers how to build workflows that span multiple integrations -- from simple queries to multi-step pipelines with type bridging and approval gates.\n\n---\n\n## Simple Query\n\nThe fastest way to call a tool:\n\n### Playground\n\nType a goal and the system finds and executes the right tool:\n\n```\nYou: Show me my Salesforce leads\nSystem: [discovers salesforce@1/get_leads@1, executes, shows results]\n```\n\n### Conduit SDK\n\n```python\nresult = client.perform(\"salesforce@1/get_leads@1\", {\"limit\": 10})\n```\n\n### Sandbox\n\nOpen the integration's detail page, go to the **Sandbox** tab, select the tool, fill in parameters, and click **Run**.\n\n---\n\n## Multi-Step Workflow\n\nWhen your goal involves multiple systems, the planning engine chains tools automatically.\n\n### Via Playground\n\n```\nYou: Create QuickBooks invoices for qualified Salesforce leads\n```\n\nThe system builds a plan:\n\n1. `salesforce@1/get_leads@1` (filter: status = Qualified)\n2. `data-grout@1/prism.focus@1` (convert lead to customer)\n3. `quickbooks@1/create_invoice@1`\n\nReview the plan and approve to execute. Each step runs in sequence, with type bridging handled automatically.\n\n### Via the API\n\nUse `discovery.plan` to generate a verified plan, then `flow.into` to execute it:\n\n```python\nplan = client.call_tool(\"data-grout@1/discovery.plan@1\", {\n    \"goal\": \"Create invoices from qualified leads\"\n})\n\nresult = client.call_tool(\"data-grout@1/flow.into@1\", {\n    \"plan\": plan[\"steps\"],\n    \"save_as_skill\": True,\n    \"name\": \"lead_to_invoice\"\n})\n```\n\nThe plan comes with a Cognitive Trust Certificate proving it is cycle-free, type-safe, and policy-compliant before any tool runs.\n\n---\n\n## Type Bridging\n\nWhen tools produce data in one format and the next tool expects another, the planner inserts `prism.focus` to convert between types:\n\n```\nsalesforce@1/get_leads@1 → crm.lead@1\n  ↓ prism.focus (crm.lead@1 → billing.customer@1)\nquickbooks@1/create_invoice@1 ← billing.customer@1\n```\n\nThis happens automatically during planning. You can also call `prism.focus` directly:\n\n```python\ncustomer = client.call_tool(\"data-grout@1/prism.focus@1\", {\n    \"data\": lead,\n    \"source_type\": \"crm.lead@1\",\n    \"target_type\": \"billing.customer@1\"\n})\n```\n\n---\n\n## Approval Gates\n\nFor operations that modify data, insert an approval gate:\n\n```python\napproval = client.call_tool(\"data-grout@1/flow.request-approval@1\", {\n    \"action\": \"Create 25 invoices in QuickBooks\",\n    \"details\": {\"total_amount\": 47500, \"count\": 25},\n    \"reason\": \"Bulk invoice creation\"\n})\n\nif approval[\"decision\"] == \"approved\":\n    # proceed with execution\n```\n\nApproval gates pause the workflow until a human responds. Configure which operations require approval in your [Policy settings](policy-security).\n\n---\n\n## Saving Skills\n\nAfter a successful workflow, save it as a reusable skill:\n\n```python\nresult = client.call_tool(\"data-grout@1/flow.into@1\", {\n    \"plan\": [...],\n    \"save_as_skill\": True,\n    \"name\": \"lead_to_invoice\"\n})\n```\n\nSkills retain their CTC and execute without re-verification on subsequent runs:\n\n```python\nresult = client.perform(\"skills@1/lead_to_invoice@1\", {})\n```\n\n---\n\n## Error Handling\n\nWhen a tool call fails, the response includes a structured error:\n\n```json\n{\n  \"error\": {\n    \"code\": \"upstream_error\",\n    \"message\": \"QuickBooks API rate limit exceeded\"\n  }\n}\n```\n\nCommon error codes: `tool_not_found`, `invalid_arguments`, `upstream_error`, `timeout`, `rate_limit`, `policy_violation`.\n\nCheck the **Runs** tab for detailed execution logs, or use the [Agent Inspector](agent-inspector) for cognitive-level debugging.\n\n---\n\n## Related\n\n- [Discovery Tools](discovery-tools) -- Plan and discover tools programmatically\n- [Flow and Inspect Tools](flow-inspect-tools) -- Workflow orchestration reference\n- [Cognitive Trust Certificates](cognitive-trust-certificates) -- How plan verification works\n- [Using the Playground](playground-guide) -- Interactive workflow building\n"
}