# Macro Component Additions

**PluginCore.cs**

```csharp
[Plugin(1, "Extra Macro Component Plugin", "Adds new macro components to the macro builder!")]
public class PluginCore : IStartPlugin
{
    /// <summary>
    /// Should be used to check compatability with the
    /// current version of the bot.
    /// </summary>
    public override void OnLoad(int version, int subversion, int buildversion) { }
    public override PluginResponse OnEnable(IBotSettings botSettings) {
        /* Regular plugin content */
        return base.OnEnable(botSettings);
    }
}
    
public class TestMacroComponent : IExternalMacroComponent {
    
    public TestMacroComponent() {
        this.Category = MacroComponentCategory.Misc;
        this.Outputs = new IMacroOutputCollection(
            new KeyValuePair<string, ExternalMacroOutput>("success", new ExternalMacroOutput("Success", "This output gets called once the call finishes", true)),
            new KeyValuePair<string, ExternalMacroOutput>("output_internal_name", new ExternalMacroOutput("Error", "This output will never get called", false))
        );
        this.Variables = new IMacroVariableCollection(
            new KeyValuePair<string, ExternalMacroVariable>("variable_internal_name1", new ExternalMacroVariable(typeof(string), "Message", "What message should we send to chat?", "my default message!"))
        );
    }
    
    public override string GetName() {
        return "Test macro component";
    }
    
    public override string GetInternalName() {
        return "ex:test_macro_component";
    }
    
    public override string GetDescription() {
        return "This is a test macro component";
    }
    public override string GetInteractiveDescription() {
        var variableValue = GetVariable<string>("variable_internal_name1");
        return 
            string.IsNullOrWhiteSpace(variableValue) ? GetDescription() 
            : $"I will say {variableValue}.";
    }
    
    public override string Execute(IBotContext Context) {
        Context.Functions.Chat("My message: " + GetVariable<string>("variable_internal_name1"));
        return "success"; // or return "output_internal_name"
    }
}
```

## Outputs

<div align="left"><img src="/files/-M81_-5O27Jm_a5RT6Re" alt="Macro component outputs"></div>

Outputs refer to possible paths that the macro component will lead to. **The execute method should return a name of one of the registered outputs**. These should be registered in the constructor, as can be seen here:

```csharp
public TestMacroComponent() {
    ...
    this.Outputs = new IMacroOutputCollection(
        new KeyValuePair<string, ExternalMacroOutput>("success", new ExternalMacroOutput("Success", "This output gets called once the call finishes", true)),
        new KeyValuePair<string, ExternalMacroOutput>("output_internal_name", new ExternalMacroOutput("Error", "This output will never get called", false))
    );
    ...
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.minecraftbot.com/examples/macro-component-additions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
