> For the complete documentation index, see [llms.txt](https://docs.greytrix.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.greytrix.com/sage-crm-add-ons/gumu-co-pilot-for-sage-crm/installation-+-setup/creating-custom-actions-and-capabilities.md).

# Creating Custom Actions and Capabilities

Custom actions allow GUMU™ Co-Pilot to retrieve specific information from Sage CRM.

For example, an action can be created to retrieve customer sales history from a Sage CRM custom entity such as:

```
vcustomersaleshistory
```

### Step 1: Navigate to Actions

Log in to Bportaly and navigate to:

**Configuration → Actions → New**

<figure><img src="https://794987320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MCRVg-TYx3gVa2Tqtf_%2Fuploads%2Fd23AYLt5cEeSb4fNkVIG%2Fimage.png?alt=media&amp;token=04e10fe3-cb46-4b6a-a941-da2c718901fc" alt=""><figcaption></figcaption></figure>

### Step 2: Create a New Action

Click **New** to create a new action.

Enter the required action details, including:

* **Action Name**
* **Object/Entity Name**
* Required input fields
* Required output fields
* Action script

<figure><img src="https://794987320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MCRVg-TYx3gVa2Tqtf_%2Fuploads%2Fs3VZutQF8BNLlYwQWD29%2Fimage.png?alt=media&amp;token=020fad7e-ff5f-4b71-bad7-4d2abb06c15c" alt=""><figcaption></figcaption></figure>

#### Example Entity

For example:

```
vcustomersaleshistory
```

**Important:** The object/entity name must be entered in **lowercase**.

### Step 3: Add the Action Script

Use the following script format for the action(user can replace it by custom entity name):

```
async def vcustomersaleshistory(
```

```
    self,
```

```
    filters: list[dict],
```

```
    orderBy: dict = {},
```

```
    page_size: int = 10,
```

```
    child_entity: str = ""
```

```
):
```

```
    """
```

```
    Auto-generated tool for SAGE CRM entity: vcustomersaleshistory
```

```
 
```

```
    filters: list of {
```

```
        "field": str,
```

```
        "op": str,
```

```
        "value": Any
```

```
    }
```

```
 
```

```
    orderBy: e.g.,
```

```
    {"field": "chis_compid", "direction": "asc"}
```

```
    """
```

```
 
```

```
    try:
```

```
        response = await self.call_sagecrm_api_async(
```

```
            filters,
```

```
            orderBy,
```

```
            page_size,
```

```
            child_entity
```

```
        )
```

```
 
```

```
        return response
```

```
 
```

```
    except Exception as e:
```

```
        print(f"Error in customersaleshistory: {e}")
```

```
        return f"Error fetching customersaleshistory: {str(e)}"
```

#### Important

The **action name and script/function name must match**.

For example:

**Action Name:**

```
vcustomersaleshistory
```

**Script/Function Name:**

Vcustomersaleshistory

<figure><img src="https://794987320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MCRVg-TYx3gVa2Tqtf_%2Fuploads%2F39Y8faClj5ElPjPrQo9q%2Fimage.png?alt=media&amp;token=d1ad4870-ab0a-4783-bebc-b4502c75f678" alt=""><figcaption></figcaption></figure>

<figure><img src="https://794987320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MCRVg-TYx3gVa2Tqtf_%2Fuploads%2F4liO2KHJU8O3GKTlhMjZ%2Fimage.png?alt=media&amp;token=809d98d1-0079-4f3d-9b1c-8dc6ac8d7e37" alt=""><figcaption></figcaption></figure>

<figure><img src="https://794987320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MCRVg-TYx3gVa2Tqtf_%2Fuploads%2FpXqeFwZdgxxkHe2quUoa%2Fimage.png?alt=media&amp;token=4845c6ab-d993-40a3-aa2f-7b8b9ddc5203" alt=""><figcaption></figcaption></figure>

<figure><img src="https://794987320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MCRVg-TYx3gVa2Tqtf_%2Fuploads%2FVrqSqWPY0sDhFAzPm7kW%2Fimage.png?alt=media&amp;token=d0ce0987-8327-4661-a9f9-9d795d141857" alt=""><figcaption></figcaption></figure>
