To learn more about Tempo products, please visit our Help Center. For support, see our Support Portal.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Current »

Sometimes it can be helpful to add the description of worklogs as comments to issues. This gives users who have no permission to view the worklogs of others the option to see what work others have done. With this automation, users do not need to write a separate comment with information about what has been done on the issue.

Automation Trigger

For this automation, we select the “Work logged” trigger and select the “Created” and “Updated” option.
Even though the worklog is logged via the Tempo Log Time dialog, the Jira worklog event will get fired.


Making the REST call to get the Tempo worklog ID

As the worklog description is obfuscated when the worklog is synced to Jira (Why do the Jira worklogs appear with the author Tempo Timesheets instead of the user's name? ), it will need to be retrieved from Tempo via a Tempo REST API call.

First, you need to get Tempo worklog ID from Jira worklog properties. In the web request, you need to use smart values for Jira issue id {{issue.id}} and Jira worklog id {{worklog.id}}.

https://YOUR_JIRA.atlassian.net/rest/api/3/issue/{{issue.id}}/worklog/{{worklog.id}}?expand=properties

The response should be something like this:

{
    "self": "https://cops.atlassian.net/rest/api/3/issue/12868/worklog/23076",
    "author": {
        "self": "https://cops.atlassian.net/rest/api/3/user?accountId=557058:295406f3-xxxx-xxxx-xxxx-dd15d021bd79",
        "accountId": "557058:295406f3-xxxx-xxxx-xxxx-dd15d021bd79",
        "avatarUrls": {
            "48x48": "https://secure.gravatar.com/avatar/182fc208a1a2e6cc41393ab6c9363d9c?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FTT-6.png",
            "24x24": "https://secure.gravatar.com/avatar/182fc208a1a2e6cc41393ab6c9363d9c?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FTT-6.png",
            "16x16": "https://secure.gravatar.com/avatar/182fc208a1a2e6cc41393ab6c9363d9c?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FTT-6.png",
            "32x32": "https://secure.gravatar.com/avatar/182fc208a1a2e6cc41393ab6c9363d9c?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FTT-6.png"
        },
        "displayName": "Tempo Timesheets",
        "active": true,
        "timeZone": "America/Montreal",
        "accountType": "app"
    },
    "updateAuthor": {
        "self": "https://cops.atlassian.net/rest/api/3/user?accountId=557058:295406f3-xxxx-xxxx-xxxx-dd15d021bd79",
        "accountId": "557058:295406f3-xxxx-xxxx-xxxx-dd15d021bd79",
        "avatarUrls": {
            "48x48": "https://secure.gravatar.com/avatar/182fc208a1a2e6cc41393ab6c9363d9c?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FTT-6.png",
            "24x24": "https://secure.gravatar.com/avatar/182fc208a1a2e6cc41393ab6c9363d9c?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FTT-6.png",
            "16x16": "https://secure.gravatar.com/avatar/182fc208a1a2e6cc41393ab6c9363d9c?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FTT-6.png",
            "32x32": "https://secure.gravatar.com/avatar/182fc208a1a2e6cc41393ab6c9363d9c?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FTT-6.png"
        },
        "displayName": "Tempo Timesheets",
        "active": true,
        "timeZone": "America/Montreal",
        "accountType": "app"
    },
    "comment": {
        "version": 1,
        "type": "doc",
        "content": [
            {
                "type": "paragraph",
                "content": [
                    {
                        "type": "text",
                        "text": "time-tracking"
                    }
                ]
            }
        ]
    },
    "created": "2022-03-28T15:57:11.215-0400",
    "updated": "2022-04-05T15:07:02.492-0400",
    "started": "2022-03-02T03:00:00.000-0500",
    "timeSpent": "2h",
    "timeSpentSeconds": 7200,
    "id": "23076",
    "issueId": "12868",
    "properties": [
        {
            "key": "tempo",
            "value": {
                "shadow": "true",
                "tempo_id": 9701
            }
        }
    ]
}

Then, you need to store the Tempo worklog id (tempo_id) in a variable {{TempoWorklogId}}:

{{webhookResponse.body.properties.value.tempo_id}}

Making the REST call to get the Tempo worklog details

Second, you can get Tempo Worklog details with Tempo REST API. The Authorization to retrieve the worklog data needs to be done via the Tempo API Integration token (Bearer token).
Please make sure to check the
”Delay execution of subsequent rule actions until we've received a response for this web request” option.

You can get Tempo worklog with the variable {{TempoWorklogId}}:

https://api.tempo.io/4/worklogs/{{TempoWorklogId}}

Payload should look like this:

{
    "self": "https://api.tempo.io/4/worklogs/9701",
    "tempoWorklogId": 9701,
    "issue": {
        "self": "https://cops.atlassian.net/rest/api/2/issue/12868",
        "id": 12868
    },
    "timeSpentSeconds": 7200,
    "billableSeconds": 7200,
    "startDate": "2022-03-02",
    "startTime": "08:00:00",
    "description": "Working on issue BJT-10",
    "createdAt": "2022-03-28T19:57:10Z",
    "updatedAt": "2022-04-05T19:07:02Z",
    "author": {
        "self": "https://cops.atlassian.net/rest/api/2/user?accountId=xxxxxxxxxx49415c02f69600",
        "accountId": "xxxxxxxxxx49415c02f69600"
    },
    "attributes": {
        "self": "https://api.tempo.io/4/worklogs/9701/work-attribute-values",
        "values": [
            {
                "key": "_AccountasWorkAttribute_",
                "value": "BJT"
            }
        ]
    }
}

Adding the comment to the issue

In the last step, the worklog description that was retrieved from Tempo and the time logged (in minutes) are added as a comment to the issue.
To make sure that a new comment for each worklog is added, please make sure that the option to
”Prevent duplicates by only adding this comment once to a particular issue.” is unchecked.

{{webhookResponse.body.description}} -- Logged {{#=}} {{webhookResponse.body.timeSpentSeconds.divide(60).round}} {{/}} minutes were spent on this issue.

  • No labels