AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
feat(Builder): Adds node to send messages to discord webhook (#7381)
Bentlyb7096e01fb96
diff --git a/rnd/autogpt_server/autogpt_server/blocks/__init__.py b/rnd/autogpt_server/autogpt_server/blocks/__init__.pyindex 7a0f255ca0..ec9f60d258 100644--- a/rnd/autogpt_server/autogpt_server/blocks/__init__.py+++ b/rnd/autogpt_server/autogpt_server/blocks/__init__.py@@ -1,5 +1,4 @@-from autogpt_server.blocks import sample, reddit, text, ai-from autogpt_server.blocks.wikipedia import GetWikipediaSummary+from autogpt_server.blocks import sample, reddit, text, ai, wikipedia, discordfrom autogpt_server.data.block import BlockAVAILABLE_BLOCKS = {@@ -7,4 +6,4 @@ AVAILABLE_BLOCKS = {for block in [v() for v in Block.__subclasses__()]}-__all__ = ["ai", "sample", "reddit", "text", "AVAILABLE_BLOCKS", "GetWikipediaSummary"]+__all__ = ["ai", "sample", "reddit", "text", "AVAILABLE_BLOCKS", "wikipedia", "discord"]\ No newline at end of filediff --git a/rnd/autogpt_server/autogpt_server/blocks/discord.py b/rnd/autogpt_server/autogpt_server/blocks/discord.pynew file mode 100644index 0000000000..65bd10aa5a--- /dev/null+++ b/rnd/autogpt_server/autogpt_server/blocks/discord.py@@ -0,0 +1,30 @@+import requests+from autogpt_server.data.block import Block, BlockSchema, BlockOutput+++class DiscordSendMessage(Block):+ class Input(BlockSchema):+ webhook_url: str+ message: str++ class Output(BlockSchema):+ status: str++ def __init__(self):+ super().__init__(+ id="b3a9c1f2-5d4e-47b3-9c4e-2b6e4d2c4f3e",+ input_schema=DiscordSendMessage.Input,+ output_schema=DiscordSendMessage.Output,+ test_input={+ "webhook_url": "https://discord.com/api/webhooks/your_webhook_url",+ "message": "Hello, Webhook!"+ },+ test_output=("status", "sent"),+ )++ def run(self, input_data: Input) -> BlockOutput:+ response = requests.post(input_data.webhook_url, json={"content": input_data.message})+ if response.status_code == 204: # Discord webhook returns 204 No Content on success+ yield "status", "sent"+ else:+ yield "status", f"failed with status code {response.status_code}"