First_agent_template3 / tools /WebhookPostTool.py
Isaac454's picture
Update tools/WebhookPostTool.py
a93662f verified
raw
history blame contribute delete
556 Bytes
from smolagents import Tool
import requests # Required to send HTTP POST requests
class WebhookPostTool(Tool):
name = "webhook_post"
description = "Send a JSON payload to a webhook URL and return the response as text."
output_type = str # Must be one of SmolAgents authorized types
def forward(self, webhook_url: str, payload: dict) -> str:
try:
response = requests.post(webhook_url, json=payload)
return response.text
except Exception as e:
return f"Error sending request: {str(e)}"