User-Assigned Tasks
Create tasks with automatic assignment based on PR author.
Use Case
Building on Bot Task Creation, automatically assign created tasks to the right team member using GitHub→Asana user mappings. This ensures:
- Tasks are created for PRs without Asana links
- Tasks are automatically assigned to the correct person
- Bot PRs route to specific team members
Complete Workflow
name: Asana Sync
on:
pull_request:
types: [opened]
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: planningcenter/asana-github-sync@main
with:
asana_token: ${{ secrets.ASANA_TOKEN }}
github_token: ${{ github.token }}
# Map GitHub usernames to Asana user GIDs
user_mappings: |
octocat: 1234567890
alice: 0987654321
bob: 1111111111
dependabot[bot]: 2222222222
renovate[bot]: 2222222222
rules: |
rules:
- when:
event: pull_request
action: opened
has_asana_tasks: false
then:
create_task:
project: '1234567890'
workspace: '0987654321'
title: '{{clean_title pr.title}}'
html_notes: '<a href="{{pr.url}}">{{pr.title}}</a>'
# Try PR assignee first, fallback to author
assignee: '{{or (map_github_to_asana pr.assignee) (map_github_to_asana pr.author)}}'How It Works
For PRs with Assignee
- PR opened by
octocat, assigned toalice - Task created and assigned to Alice (Asana GID
0987654321)
For PRs without Assignee
- PR opened by
bob, no assignee - Task created and assigned to Bob (Asana GID
1111111111)
For Bot PRs
- Dependabot opens PR
- Task created and assigned to mapped team member (GID
2222222222)
For Unmapped Users
- PR opened by
charlie(not in mappings) - Task created without assignee (mapping returns empty string)
Key Components
user_mappings Input
Maps GitHub usernames to Asana user GIDs:
user_mappings: |
github_username: asana_user_gid
octocat: 1234567890Format:
- GitHub username (exact, case-sensitive)
- Bot usernames include
[bot] - Asana user GID (numeric)
map_github_to_asana Helper
Looks up the mapping:
or Helper
Provides fallback logic:
Assignment Priority
assignee: '{{or (map_github_to_asana pr.assignee) (map_github_to_asana pr.author)}}'- Try PR assignee first
- If no assignee (or not mapped), use PR author
- If author not mapped, no assignment (empty string)
Finding Asana User GIDs
Method 1: User Tasks URL
When viewing a user's tasks:
https://app.asana.com/0/my_tasks/1234567890/list
^^^^^^^^^^
User GIDMethod 2: Asana API
curl "https://app.asana.com/api/1.0/workspaces/YOUR_WORKSPACE/users" \
-H "Authorization: Bearer YOUR_ASANA_TOKEN"Response:
{
"data": [
{
"gid": "1234567890",
"name": "Alice Smith",
"email": "alice@example.com"
}
]
}Variations
Assign to Self
Use "me" instead of GID:
assignee: 'me'Default Assignee
Provide fallback GID:
assignee: '{{or (map_github_to_asana pr.author) "9999999999"}}'
# If author not mapped, assign to GID 9999999999Only Assign if Mapped
Let tasks be unassigned if no mapping:
assignee: '{{map_github_to_asana pr.author}}'
# Empty string = no assignmentDifferent Mappings for Bots
Route different bots to different people:
user_mappings: |
dependabot[bot]: 1234567890 # Backend team
renovate[bot]: 0987654321 # Frontend team
snyk-bot: 1111111111 # Security teamExpected Behavior
PR by octocat (mapped to 1234567890):
- Task Created ✅
- Task Assigned to: User 1234567890
PR by charlie (not mapped):
- Task Created ✅
- Task Assigned to: (none)
PR by octocat, assigned to alice:
- Task Created ✅
- Task Assigned to: alice (0987654321)
Common Issues
Task Created But Not Assigned
Problem: User not in user_mappings
Solution: Add mapping:
user_mappings: |
username: their_asana_gidWrong Person Assigned
Problem: GID is incorrect
Solution: Verify user GID with Asana API (see above).
Bot Username Mismatch
Problem: Bot username in mapping doesn't match GitHub
Solution: Check exact format:
# GitHub shows: dependabot[bot]
user_mappings: |
dependabot[bot]: 1234567890 # ✅ Exact matchCase Sensitivity
Problem: Mapping uses different case than GitHub
Solution: Match GitHub's exact username:
# GitHub username: octocat (lowercase)
user_mappings: |
octocat: 1234567890 # ✅ Correct
Octocat: 1234567890 # ❌ Won't matchAssignment in update_fields
You can also use mapping to update assignee fields:
- when:
event: pull_request
action: opened
has_asana_tasks: true
then:
update_fields:
'1234567890': '{{map_github_to_asana pr.author}}'
# If field 1234567890 is an assignee fieldThough typically you'd use this in create_task.
Complete Example with Bots and Humans
user_mappings: |
alice: 1234567890
bob: 0987654321
dependabot[bot]: 1111111111
renovate[bot]: 1111111111
rules:
- when:
event: pull_request
action: opened
has_asana_tasks: false
then:
create_task:
project: '1234567890'
workspace: '0987654321'
title: '{{clean_title pr.title}}'
notes: 'PR: {{pr.url}}'
assignee: '{{map_github_to_asana pr.author}}'
# Alice PRs → Alice
# Bob PRs → Bob
# Dependabot PRs → User 1111111111
# Unknown users → UnassignedNext Steps
- Build Label Automation - React to labels
- Multi-Condition Filtering - Complex conditions
- map_github_to_asana - Complete reference
- or Helper - Fallback logic