# Actions

With actions you can share your functions all around the Dashboard.

Use your actions inside your plugin, or other plugins.

The idea behind `Actions` is to give plugins the power of using other plugins functions and business logic or to share your functions with other plugins

## How to register an Action?

You can register Actions from the `Agent` only, and only once.

You can register one or more actions with `registerAction` method that your Agent will get as long as you extend your Agent from the Agent-Base from Plugin-API

#### Action object:

```javascript
{
    id: '@plugin_bundle-my-awesome-action',
    description: 'My awesome action, to handle awesome things!',
    action: () => {// My awesome action}
}
```

#### register

> You can pass on Action object to registerActions or an array of Action objects

```javascript
import { Plugin } from '@root'

export default class MyAgent extends Plugin.Agent {
    constructor(props) {
        super(props)

        const myActions = [
            {
                id: 'my-logger-action',
                description: 'A logger action to style logs outputs',
                action: this._logger.bind(this)
            },
            {
                id: 'my-fetch-action',
                description: 'A fetch action to handle fetch requests',
                action: this._fetch.bind(this)
            }
        ]

        this.registerActions(actions)
    }

    _logger(message) {
        console.log('=====')
        console.log(message)
        console.log('=====')
    }

    _fetch(url) {
        return new Promise((resolve, reject) => {
            this.request(url).then(resp => resp.json()).then(data => {
                resolve(data)
            }).catch(error => {
                reject(error)
            })
        })
    }
}
```

## How to use an Action?

{% content-ref url="/pages/-MCg1j6bbod6g8V-SkVd" %}
[getAction](/dashboard-plugin/api-and-gui/api/getaction.md)
{% endcontent-ref %}


---

# 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.navigaglobal.com/dashboard-plugin/components/agent/actions.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.
