Using ToolNodes
Basic Structure
Copy
from fibonacci import ToolNode
node = ToolNode(
id="unique_id", # Required: Unique identifier
name="Human Name", # Required: Display name
tool="tool_name", # Required: Tool to execute
params={ # Required: Tool parameters
"param1": "value",
"param2": "{{input.field}}"
}
)
With Dependencies
Copy
# Read data, then write to another sheet
read = ToolNode(
id="read_source",
name="Read Source",
tool="google_sheets_read",
params={"spreadsheet_id": "...", "range": "A1:Z100"}
)
write = ToolNode(
id="write_dest",
name="Write Destination",
tool="google_sheets_write",
params={
"spreadsheet_id": "...",
"range": "A1",
"values": "{{read_source}}"
},
dependencies=["read_source"]
)
Tool Discovery
List All Tools
Copy
from fibonacci import list_tools
tools = list_tools()
for tool in tools:
print(f"{tool['name']}: {tool['description']}")
Search Tools
Copy
from fibonacci import search_tools
# Find Google-related tools
google_tools = search_tools("google")
# Find email tools
email_tools = search_tools("email")
Get Tool Schema
Copy
from fibonacci import print_tool_info
# See full details including parameters and examples
print_tool_info("google_sheets_read")
Copy
======================================================================
🔧 google_sheets_read
======================================================================
Category: google_workspace
Description: Read data from a Google Sheets spreadsheet
Cost per use: $0.0001
📥 Input Parameters:
• spreadsheet_id (string) - required
The ID of the spreadsheet
• range (string) - required
The A1 notation range to read (e.g., "Sheet1!A1:D10")
📖 Examples:
1. Read sales data
Params: {"spreadsheet_id": "abc123", "range": "Sales!A1:E100"}
======================================================================
Find Tool for Task
Copy
from fibonacci import find_tool_for_task
# Describe what you want to do
tool = find_tool_for_task("send a message to slack")
print(tool) # "slack_send_message"
tool = find_tool_for_task("read data from google sheets")
print(tool) # "google_sheets_read"
Google Workspace
Google Sheets
Copy
read = ToolNode(
id="read_data",
name="Read Sheet Data",
tool="google_sheets_read",
params={
"spreadsheet_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",
"range": "Sheet1!A1:D100"
}
)
Google Docs
Copy
read_doc = ToolNode(
id="read_doc",
name="Read Document",
tool="google_docs_read",
params={
"document_id": "{{input.doc_id}}"
}
)
Gmail
Copy
send_email = ToolNode(
id="send_email",
name="Send Email",
tool="gmail_send",
params={
"to": "[email protected]",
"subject": "Your Report is Ready",
"body": """
Hi {{input.recipient_name}},
Your weekly report is attached.
Summary:
{{executive_summary}}
Best,
Fibonacci Bot
""",
"attachments": [
{"name": "report.pdf", "content": "{{report_pdf}}"}
]
}
)
Communication Tools
Slack
Copy
slack_msg = ToolNode(
id="notify_team",
name="Notify Team",
tool="slack_send_message",
params={
"channel": "#team-updates",
"message": "🎉 Report generated!\n\n{{executive_summary}}"
}
)
Discord
Copy
discord_msg = ToolNode(
id="discord_alert",
name="Discord Alert",
tool="discord_send",
params={
"webhook_url": "{{input.webhook}}",
"content": "Alert: {{analyze_data}}"
}
)
HTTP & APIs
Generic HTTP Request
Copy
api_call = ToolNode(
id="call_api",
name="Call External API",
tool="http_request",
params={
"method": "POST",
"url": "https://api.example.com/data",
"headers": {
"Authorization": "Bearer {{input.api_token}}",
"Content-Type": "application/json"
},
"body": {
"query": "{{input.search_term}}",
"limit": 10
}
}
)
Webhook
Copy
webhook = ToolNode(
id="trigger_webhook",
name="Trigger Webhook",
tool="webhook_call",
params={
"url": "https://hooks.zapier.com/hooks/catch/123/abc",
"payload": {
"event": "report_generated",
"data": "{{report_data}}"
}
}
)
Database Tools
SQL Query
Copy
query = ToolNode(
id="query_db",
name="Query Database",
tool="database_query",
params={
"connection_string": "{{secrets.DATABASE_URL}}",
"query": """
SELECT customer_id, SUM(amount) as total
FROM orders
WHERE date >= '{{input.start_date}}'
GROUP BY customer_id
ORDER BY total DESC
LIMIT 10
"""
}
)
Never hardcode database credentials. Use secrets management.
Cloud Storage
AWS S3
Copy
s3_upload = ToolNode(
id="upload_s3",
name="Upload to S3",
tool="s3_upload",
params={
"bucket": "my-reports",
"key": "reports/{{input.report_id}}.pdf",
"content": "{{report_pdf}}",
"content_type": "application/pdf"
}
)
CRM & Business Tools
Salesforce
Copy
create_lead = ToolNode(
id="create_lead",
name="Create Salesforce Lead",
tool="salesforce_create",
params={
"object": "Lead",
"data": {
"FirstName": "{{input.first_name}}",
"LastName": "{{input.last_name}}",
"Email": "{{input.email}}",
"Company": "{{input.company}}",
"Description": "{{qualify_lead}}"
}
}
)
HubSpot
Copy
hubspot_contact = ToolNode(
id="update_contact",
name="Update HubSpot Contact",
tool="hubspot_update_contact",
params={
"email": "{{input.email}}",
"properties": {
"lead_score": "{{score_lead}}",
"last_activity": "{{timestamp}}"
}
}
)
Notion
Copy
notion_page = ToolNode(
id="create_notion",
name="Create Notion Page",
tool="notion_create_page",
params={
"database_id": "{{input.database_id}}",
"properties": {
"Name": "{{input.title}}",
"Status": "Ready",
"Priority": "High"
},
"content": "{{generate_notes}}"
}
)
Tool Categories
Copy
from fibonacci import list_tool_categories
categories = list_tool_categories()
for cat in categories:
print(f"{cat['name']}: {cat['count']} tools")
print(f" Examples: {', '.join(cat['tools'][:3])}")
Copy
google_workspace: 12 tools
Examples: google_sheets_read, google_docs_read, gmail_send
communication: 8 tools
Examples: slack_send_message, discord_send, twilio_sms
databases: 5 tools
Examples: database_query, mongodb_find, redis_get
cloud_storage: 6 tools
Examples: s3_upload, gcs_upload, azure_blob
...
Error Handling
Retry on Failure
Copy
api_call = ToolNode(
id="api_call",
name="API Call",
tool="http_request",
params={...}
).with_retry(max_retries=3, delay=2.0)
Timeout Configuration
Copy
slow_api = ToolNode(
id="slow_api",
name="Slow API",
tool="http_request",
params={...},
timeout=60 # 60 seconds timeout
)