When building a custom integration, babelforce offers task template that can be re-used as local or global automation. To keep private data secure, it is possible to store any secrets in the task vault (for details, see this article).
However, there are use cases where the same template should use a different set of secrets. There are two options to solve this problem:
- Parameterize the secrets as a required field: useful if no changes to the template's behavior are expected
- Create a copy of the template: should be applied if the task is adjusted/ should behavior differently
Parameterize secrets
In the example on using secrets, the reference to vault was added directly to the template. In the example, a secret is used for authorization.
"header": {
"Authorization": "{{secret.MyPrefix.token}}",
...Instead of hard coding the vault reference, create required fields for the secret and refer to those in the template.
- In our example add two new required fields. Then reference the two required fields in the template, in our case the parameter "Authorization" and "body" are referencing them.
{
"required_fields":[
"body.token",
"body.action"
],
"type": "some.type",
"body": {
...
},
"scheduled_at": "now",
"actions": {
"on_scheduled": [
{
"http": {
"var": "test",
"url": "myurl.test",
"method": "POST",
"header": {
"Authorization": "{{{task.body.token}}}",
"Content-Type": "application/json"
},
"body": "{{{task.body.action}}}"
}
}
],
"settings": [
{
...
}
]
}
}2. After adjusting the template, you can store the relevant secrets in vault as described in this article. For our use case, we stored these two secrets:
myAuth.tokenmyAuth.action
3. As templates are executed in either a local or a global automation, you now reference these two secrets in the automation. The placeholder follow this logic:
{taskrouter.secret.prefix.value}- This translates to this placeholder in our example:
{taskrouter.secret.myAuth.token}
4. If the same template is used with different credentials, new secrets have to be stored in vault and must be referenced in the respective automation.
Good to know: you can also overwrite the "type" of the template. This way, it is easier to find it in the task logs. Just add another "Request body" field in the task automation. The key should be "type". For the value, give it any name that makes sense for your process.
Creating a copy of a template
An alternative to parameterize a template is to create a copy. However, a copy is only advisable if the template has a different behavior than the original one. Otherwise, we suggest parameterization , as explained above.
These are the steps to copy the template.
- Go to this section:
Automations > Task automations{
"type": "some.new.type",
"body": {
...
},
"scheduled_at": "now",
"actions": {
"on_scheduled": [
{
"http": {
...
"header": {
"Authorization": "{{{secret.myPrefix.secondToken}}}",
"Content-Type": "application/json"
},
"body": "{{{task.body.secondAction}}}"
}
}
],
"settings": [
{
...
}
]
}
}
Comments
0 comments
Please sign in to leave a comment.