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.
// Predefined method to send a message
const workflowId = 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 result = await linkedapi.sendMessage.result(workflowId)
// Predefined method to check connection status
const workflowId = await linkedapi.checkConnectionStatus.execute({
personUrl: "https://www.linkedin.com/in/john-doe",
});
const result = await linkedapi.checkConnectionStatus.result(workflowId);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 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:
// Custom workflow to find managers at a company,
// retrieve their education, and send connection requests
const customWorkflowId = 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(customWorkflowId);