Building workflows
Workflows are constructed using building blocks called actions, each having its own purpose (you may learn more about actions on the actions overview page).
A workflow, after being successfully executed, produces a completion
, that contains the results of all actions. See the executing workflows page for details.
Here you'll learn how to build various workflows, from single-action to advanced.
Single-action workflows
Single-action workflows contain exactly one action. You can only use actions that allow root start in their constraints.
Example
Let's say you want to build a workflow to retrieve basic information about a company.
You only need to use openCompanyPage action to accomplish this.
Workflow:
{
"actionType": "openCompanyPage",
"companyUrl": "https://www.linkedin.com/company/company1",
"basicInfo": true
}
Completion:
{
"actionType": "openCompanyPage",
"success": true,
"data": {
"name": "TechCorp",
"publicUrl": "https://www.linkedin.com/company/company1",
"description": "TechCorp is a leading provider of innovative technology solutions for businesses worldwide.",
"location": "Cupertino, California",
"headquarters": "US",
"industry": "Information Technology",
"specialties": "Cloud Computing, AI, Software Development",
"website": "https://techcorp.com",
"employeeCount": 500,
"yearFounded": 2019,
"ventureFinancing": true,
"jobsCount": 12
}
}
Array workflows
Array workflows contain multiple actions executed sequentially. You can only use actions that allow root start in their constraints.
Example
Let's say you want to build a workflow to retrieve basic information about several people.
You need to use openPersonPage action multiple times to accomplish this.
Workflow:
[
{
"actionType": "openPersonPage",
"label": "person1",
"personUrl": "https://www.linkedin.com/in/person1",
"basicInfo": true
},
{
"actionType": "openPersonPage",
"label": "person2",
"personUrl": "https://www.linkedin.com/in/person2",
"basicInfo": true
}
]
Completion:
[
{
"actionType": "openPersonPage",
"label": "person1",
"success": true,
"data": {
"name": "John Doe",
"publicUrl": "https://www.linkedin.com/in/person1",
"hashedUrl": "https://www.linkedin.com/in/SInQBmjJ015eLr8OeJoj0mrkxx7Jiuy0",
"headline": "Software Engineer at TechCorp",
"location": "San Francisco, USA",
"countryCode": "US",
"position": "Software Engineer",
"companyName": "TechCorp",
"companyUrl": "https://www.linkedin.com/company/12345678"
}
},
{
"actionType": "openPersonPage",
"label": "person2",
"success": true,
"data": {
"name": "Jane Doe",
"publicUrl": "https://www.linkedin.com/in/person2",
"headline": "Product Manager at Cognito Inc.",
"location": "Lisbon, Portugal",
"countryCode": "PT",
"position": "Product Manager",
"companyName": "Cognito Inc.",
"companyUrl": "https://www.linkedin.com/company/87654321"
}
}
]
Advanced workflows
With Data API, you can build any workflow you can imagine by combining arrays and parent-child action relationships through then
parameter.
Only two rules apply:
- You must follow the constraints of all actions used.
- The final workflow cannot exceed 5 levels of nesting.
Example
Let's say you want to build a workflow that retrieves basic company information, finds all managers, gets their basic information and education details.
You need to use openCompanyPage, retrieveCompanyEmployees, doForPeople, openPersonPage and retrievePersonEducation actions to accomplish this.
Workflow:
{
"actionType": "openCompanyPage",
"companyUrl": "https://www.linkedin.com/company/techcorp",
"basicInfo": true,
"then": {
"actionType": "retrieveCompanyEmployees",
"filter": {
"position": "Manager"
},
"then": {
"actionType": "doForPeople",
"then": {
"actionType": "openPersonPage",
"basicInfo": true,
"then": {
"actionType": "retrievePersonEducation"
}
}
}
}
}
Completion:
{
"actionType": "openCompanyPage",
"success": true,
"data": {
"name": "TechCorp",
"publicUrl": "https://www.linkedin.com/company/techcorp",
"description": "TechCorp is a leading provider of innovative technology solutions for businesses worldwide.",
"location": "California",
"headquarters": "US",
"industry": "Information Technology",
"specialties": "Cloud Computing, AI, Software Development",
"website": "https://techcorp.com",
"employeeCount": 500,
"yearFounded": 2019,
"ventureFinancing": true,
"jobsCount": 12,
"then": {
"actionType": "retrieveCompanyEmployees",
"success": true,
"data": [
{
"name": "John Doe",
"hashedUrl": "https://www.linkedin.com/in/SInQBmjJ015eLr8",
"position": "Product Manager",
"location": "New York, USA",
"then": {
"actionType": "openPersonPage",
"success": true,
"data": {
"name": "John Doe",
"publicUrl": "https://www.linkedin.com/in/johndoe",
"hashedUrl": "https://www.linkedin.com/in/SInQBmjJ015eLr8",
"headline": "Product Manager at TechCorp",
"location": "New York, USA",
"countryCode": "US",
"position": "Product Manager",
"companyName": "TechCorp",
"hashedCompanyUrl": "https://www.linkedin.com/company/87654321",
"then": {
"actionType": "retrievePersonEducation",
"success": true,
"data": [
{
"schoolName": "Harvard University",
"schoolHashedUrl": "https://www.linkedin.com/company/12345678",
"details": "Master of Science in Computer Science, Artificial Intelligence"
},
{
"schoolName": "MIT",
"schoolHashedUrl": "https://www.linkedin.com/company/87654321",
"details": "Bachelor of Science in Electrical Engineering and Computer Science"
}
]
}
}
}
}
...
]
}
}
}