# Run function on bot startup

You can run create features scheduled to run when the bot starts.

In order to allow for this you'll need to fulfill some prerequisites

## plugin.json required parameters

has\_index MUST be marked as true. If you don't mark this true Bit will skip the file

main\_file MUST be set to the FULL name of your file. Bit uses index.js by default, it's highly recommended you keep it that way.

start\_function in your main\_file. The actual function that starts on bot startup MUST be start\_function.

Start index.js example

```javascript
const core = require('bit/core')

// In order to allow the bot to read the start_function it MUST be set as an export.
module.exports = {
    // Defines the start_function
    start_function: function start_function() {
        // Calls bit core and tells it to create an info log telling the user the plugin has loaded.
        console.log("Successfully Loaded")
    }
}
```


---

# 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://bit.lockyzdev.com/docs/2024.2/dev/create-plugins/run-function-on-bot-startup.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.
