# Predefined vs. custom workflows

There are two primary ways to execute automations with the SDKs: using **predefined methods** or building your own **custom workflows**.

## Predefined workflows

Predefined workflows are the SDK's standard, ready-to-use methods, such as `linkedApi.sendMessage()` or `linkedApi.fetchPerson()`. Each of these helper methods automatically creates and runs a corresponding, pre-configured workflow.

> A complete list of all available methods can be explored in the side navigation menu.

### When to use them

You should always start with predefined workflows. They are the fastest way to integrate Linked API because they are **strongly typed**.

Both the input parameters and the result objects have defined types, which provides auto-completion in your IDE and helps prevent errors. As long as a predefined method meets your needs, it's the recommended approach.

```typescript
// Predefined method to send a message
const sendMessageWorkflow = await linkedapi.sendMessage.execute({
  personUrl: "https://www.linkedin.com/in/john-doe",
  text: "Hello! I saw your post about AI and wanted to connect.",
});
const sendMessageResult = await linkedapi.sendMessage.result(sendMessageWorkflow.workflowId);

// Predefined method to check connection status
const connectionStatusWorkflow = await linkedapi.checkConnectionStatus.execute({
  personUrl: "https://www.linkedin.com/in/john-doe",
});
const connectionStatusResult = await linkedapi.checkConnectionStatus.result(connectionStatusWorkflow.workflowId);
```

```python
from linkedapi import CheckConnectionStatusParams, SendMessageParams

# Predefined method to send a message
send_message_workflow = linkedapi.send_message.execute(
    SendMessageParams(
        person_url="https://www.linkedin.com/in/john-doe",
        text="Hello! I saw your post about AI and wanted to connect.",
    )
)
send_message_result = linkedapi.send_message.result(send_message_workflow.workflow_id)

# Predefined method to check connection status
connection_status_workflow = linkedapi.check_connection_status.execute(
    CheckConnectionStatusParams(person_url="https://www.linkedin.com/in/john-doe")
)
connection_status_result = linkedapi.check_connection_status.result(
    connection_status_workflow.workflow_id
)
```

## Custom workflows

For tasks requiring more flexibility or complex, multi-step logic, you can build a custom workflow. This approach allows you to directly interact with the Linked API workflow engine by constructing an **object that defines the workflow's steps and logic**.

You are responsible for correctly structuring the **workflow definition object** and then parsing the resulting **completion object** returned upon execution. The [building workflows](/docs/building-workflows) page provides the complete specification for both of these object structures.

### When to use them

Switch to custom workflows when the predefined methods are not sufficient for your use case. For example:

```typescript
// Custom workflow to find managers at a company,
// retrieve their education, and send connection requests
const customWorkflow = await linkedapi.customWorkflow.execute({
  "actionType": "st.openCompanyPage",
  "companyUrl": "https://www.linkedin.com/company/techcorp",
  "basicInfo": true,
  "then": {
    "actionType": "st.retrieveCompanyEmployees",
    "filter": {
      "position": "Manager"
    },
    "then": {
      "actionType": "st.doForPeople",
      "then": {
        "actionType": "st.openPersonPage",
        "basicInfo": true,
        "then": [
          {
            "actionType": "st.retrievePersonEducation"
          },
          {
            "actionType": "st.sendConnectionRequest"
          }
        ]
      }
    }
  }
});
const customWorkflowResult = await linkedapi.customWorkflow.result(customWorkflow.workflowId);
```

```python
# Custom workflow to find managers at a company,
# retrieve their education, and send connection requests
custom_workflow = linkedapi.custom_workflow.execute(
    {
        "actionType": "st.openCompanyPage",
        "companyUrl": "https://www.linkedin.com/company/techcorp",
        "basicInfo": True,
        "then": {
            "actionType": "st.retrieveCompanyEmployees",
            "filter": {
                "position": "Manager",
            },
            "then": {
                "actionType": "st.doForPeople",
                "then": {
                    "actionType": "st.openPersonPage",
                    "basicInfo": True,
                    "then": [
                        {
                            "actionType": "st.retrievePersonEducation",
                        },
                        {
                            "actionType": "st.sendConnectionRequest",
                        },
                    ],
                },
            },
        },
    }
)
custom_workflow_result = linkedapi.custom_workflow.result(custom_workflow.workflow_id)
```
