Overview
Concrete adapter for integrating Zapier Actions API with CrewAI provided by CrewAI.
Description
This module implements two classes: ZapierActionTool and ZapierActionsAdapter. The ZapierActionsAdapter class discovers available Zapier actions from a user's account via the Zapier Actions API and dynamically generates ZapierActionTool instances for each action. Each tool is created with a dynamically generated Pydantic schema based on the action's parameters. The ZapierActionTool class extends BaseTool and executes individual Zapier actions by sending POST requests to action-specific endpoints. It supports a special instructions parameter for natural language action execution and formats other parameters with Zapier's "value" and "mode" (guess) structure. API authentication is handled via the x-api-key header, with the key sourced from the constructor parameter or the ZAPIER_API_KEY environment variable.
Usage
Import and instantiate ZapierActionsAdapter with your Zapier API key to automatically discover and create CrewAI tools for all configured Zapier actions. This enables agents to interact with 5000+ app integrations (Gmail, Slack, Salesforce, Google Sheets, etc.) through Zapier's automation platform.
Code Reference
Source Location
- Repository: CrewAI
- File: lib/crewai-tools/src/crewai_tools/adapters/zapier_adapter.py
- Lines: 1-127
Signature
class ZapierActionsAdapter:
def __init__(self, api_key: str | None = None):
class ZapierActionTool(BaseTool):
name: str = Field(description="Tool name")
description: str = Field(description="Tool description")
action_id: str = Field(description="Zapier action ID")
api_key: str = Field(description="Zapier API key")
Import
from crewai_tools.adapters.zapier_adapter import ZapierActionsAdapter
I/O Contract
Inputs (ZapierActionsAdapter)
| Name |
Type |
Required |
Description
|
| api_key |
None |
No |
Zapier API key; falls back to ZAPIER_API_KEY environment variable
|
Inputs (ZapierActionTool._run)
| Name |
Type |
Required |
Description
|
| instructions |
str |
No |
Natural language instructions for how to execute the action (default: "Execute this action with the provided parameters")
|
| **kwargs |
Any |
No |
Dynamic parameters specific to each Zapier action, formatted as value/mode pairs
|
Outputs
| Name |
Type |
Description
|
| tools() return |
list[ZapierActionTool] |
List of ZapierActionTool instances, one per configured Zapier action
|
| _run() return |
dict |
JSON response from Zapier's action execution endpoint
|
Usage Examples
Basic Usage
from crewai_tools.adapters.zapier_adapter import ZapierActionsAdapter
# Initialize with API key (or set ZAPIER_API_KEY env var)
adapter = ZapierActionsAdapter(api_key="your-zapier-api-key")
# Get all available tools
tools = adapter.tools()
# Use tools with a CrewAI agent
agent = Agent(
role="automation_specialist",
tools=tools,
)
Direct Tool Execution
from crewai_tools.adapters.zapier_adapter import ZapierActionsAdapter
adapter = ZapierActionsAdapter()
tools = adapter.tools()
# Find a specific tool by name
for tool in tools:
if "gmail" in tool.name:
result = tool._run(
instructions="Send an email",
to="user@example.com",
subject="Hello from CrewAI",
)
Related Pages
- Principle needed: Third-party automation adapter pattern for CrewAI
Page Connections
Double-click a node to navigate. Hold to expand connections.