Automatically start your airSlate workflows from inside your HubSpot organization. Just set up a HubSpot workflow that will be triggered once certain conditions (for example, creating a record) are met. Once the specified workflow is triggered, the airSlate workflow will run automatically.
Let’s consider an example where we need to automatically start an airSlate workflow once a new Ticket record in HubSpot has been created.
Before configuring your HubSpot workflow, you will need:
A workflow in airSlate that contains the necessary documents with fillable fields
The Pre-fill from HubSpot records bot to transfer data from the HubSpot record to the airSlate documents
Note: Do not select a HubSpot starting record when setting up the Pre-fill from HubSpot records bot - the system will define it automatically using a record ID parameter that was specified in the HubSpot workflow code. If a starting record is specified, it will be ignored by the system.
Now let’s proceed with configuring the HubSpot workflow.
The following instruction is intended for Hubspot administrators only.
1. Navigate to the Automation tab. Then, select Workflows from the list.
Then, create a new workflow from scratch.
Next, select the record type that your HubSpot workflow is based on. Here we select the ticket-based type as we need the airSlate workflow to trigger after a new Ticket record is created. For starting your HubSpot workflow, choose Blank workflow.
Once done, click Next.
2. The Workflow builder will open. Select Set up triggers. Then, select the trigger you need for your HubSpot workflow. In the current example, we’ll choose the When an event occurs trigger.
Next, select Object created for the event that will trigger your HubSpot workflow.
Once a triggering event has been selected, save your settings.
3. In the HubSpot workflow builder, add a new step. Then, select a Custom code action for this step.
In the Custom code settings, select Python 3.9 for the language.
Then, proceed with adding secret keys. You need to add three secret keys with an airSlate workflow ID, airSlate workflow domain, and airSlate workflow access token. To do so, in the Secret section, click Choose secret.
Then, select Add new.
To create a secret key with the airSlate workflow ID, in the Add secret modal window, enter the secret key name (airSlate_workflow_ID in the example). Then, enter the airSlate workflow ID. Once done, save your settings.
Tip: To retrieve the airSlate workflow ID, navigate to airSlate and select the workflow you need to run automatically. Copy the workflow ID from the URL.
To create a secret key with the airSlate domain, in the Add secret modal window, enter the secret key name (airSlate_domain in the example). Then, enter your airSlate domain.
To retrieve the airSlate workspace domain ID, navigate to your airSlate workspace. Then, copy the workspace domain name from the URL without any slashes or dots (somecompany in the example).
To create a secret key with the airSlate access token, in the Add secret modal window, enter the secret key name (access_token in the example). Then, enter the access token value. Once done, save your settings. This allows the HubSpot organization to access the airSlate API.
To get the airSlate workspace token, go to https://dashboard.airslate.io and log in with your airSlate credentials. Navigate to the Application tab. Then, select Add App.
In the Add API application modal window, enter an application name. Then, add the link to your airSlate application workspace that you need to provide access to. Once done, save your settings.
Once the airSlate application has been added, select it from the list to proceed with the configuration.
On the next page, skip to the JWT Grant tab. Then, select Create RSA to generate your airSlate workspace JWT token.
In the Create an RSA keypair modal window, copy the private key in the Private key section.
Then, after closing the modal window, select Generate token.
The Generate key modal window will open. Paste the copied private key into the Private key box. Be sure to discard the token expiration date by selecting No expiration, as it is set to seven days by default. Once done, select Generate JWT.
Then, copy the generated token and use it to set up the access_token secret key.
Now add properties that will be included in the code:
First row: hs_object_id (is added automatically after selecting record ID) → Record ID
Second row: createdate (is added automatically after selecting create date) → Create date.
Proceed to the Code section and replace the code in the box with the following code. Be sure to replace the names of the secrets that you have added to the workflow (airSlate_workflow_ID, airSlate_domain, access_token in the example) as well as the record type (tickets in the current example).
import os
import hashlib
import requests, json
def main(event):
record_type = 'tickets';
accessToken = os.getenv('access_token');
flow = os.getenv('airSlate_workflow_ID');
domain = os.getenv('airSlate_domain');
record_id = event["inputFields"]["hs_object_id"]
create_date = event["inputFields"]["createdate"]
endpointAirslateOAuth = 'https://oauth.airslate.com/public/oauth/token';
dataOAuth = 'grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer&assertion=' + accessToken;
sign = hashlib.md5(record_id.encode() + create_date.encode()[:-3]).hexdigest()
headersOAuth = {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/json'
}
auth = requests.post(endpointAirslateOAuth, data=dataOAuth, headers=headersOAuth)
endpointAirslate = 'https://' + domain + '.airslate.com/api/v1/flows/' + flow + '/packets/blank';
payload = {
'data': {
'type': 'packets',
'attributes': {
'additional_data': {
'hubspot_data': {
'record_id': record_id,
'sign': sign,
'record_type': record_type
}
}
}
}
};
headers = {
'Authorization': 'Bearer ' + auth.json()['access_token'],
'Content-Type': 'application/json',
'organization-domain': domain
};
r = requests.post(endpointAirslate, data=json.dumps(payload), headers=headers)
print(r.text)
print(r.status_code, r.reason)
return {
"outputFields": {
"record_id": record_id
}
}
In the Data Outputs section, add new data output with the following values:
Data type: string → Name: record_id
Once finished, save your settings.
4. Once you’ve finished setting up your HubSpot workflow, select Review and publish.
Check your settings before activating your HubSpot workflow. Then, select Turn on.
That’s it! When you’ve finished configuring every setting, you can proceed to create a new Ticket record to trigger the HubSpot workflow.
Once the HubSpot workflow is triggered, the airSlate workflow you have specified in the HubSpot workflow settings will be automatically started. The Pre-fill from HubSpot records bot will use the ID of the record that started the workflow as the starting record ID.



























