December 14, 2020

Custom data for translation webhook

When creating webhooks, you can attach custom data to them - see hookAttribute here.

If you wanted to add data related to the translation of a specific file, then the above is not very useful: you would have to create a new webhook for each translation in order to achieve that using hookAttribute.

Instead, you can take advantage of workflowAttribute to provide file-specific data when POST-ing the translation job - see here.

You can easily test how this works using the Forge extension in Visual Studio Code.

There are many sites that you can use to test webhook calls - I used https://webhook.site/ and copied the URL it provided.

Inside Visual Studio Code you can use the Forge Extension to create a new webhook for extraction.finished event:

Create webhook

Make sure the Workflow Id you use follows the rule that "It needs to be no more than 36 chars, and only ASCII, decimal and hyphen are accepted" otherwise the webhook will not work - see workflow here.

Now we can kick off the translation for one of our files in our OSS bucket and provide custom data for it under Workflow Attributes:

POST translation job

Once the translation finished, the webhook will POST to the URL I previously provided, and the data I added shows up there:

Webhook callback

 

 

Related Posts