Skip to content

Commit a6f8ed6

Browse files
authored
Merge pull request #1881 from callumalpass/integrate-pr-1838-1839
Merge default Base date and urgency fixes
2 parents bcaca13 + 4a923ac commit a6f8ed6

191 files changed

Lines changed: 6541 additions & 6313 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

PRIVACY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Plugin settings are stored in Obsidian's local plugin configuration.
1818
## Optional Network Features
1919

2020
TaskNotes is local-first. Network requests occur only when you enable features that require them.
21+
Some enabled integrations perform periodic background refreshes, such as calendar provider sync and ICS subscription updates.
2122

2223
Optional network features:
2324

Lines changed: 27 additions & 199 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,55 @@
11
# TaskNotes Webhook Transform Examples
22

3-
This directory contains example transform files that demonstrate how to customize webhook payloads for different services and formats. Transform files allow you to modify the structure and content of webhook payloads before they're sent to your endpoints.
3+
This directory contains JSON transform templates for customizing webhook payloads before TaskNotes sends them to an endpoint.
44

5-
## What are Transform Files?
5+
## What Are Transform Files?
66

7-
Transform files let you customize webhook payloads to match the specific format required by different services like Discord, Slack, Microsoft Teams, or custom APIs. TaskNotes supports two types of transform files:
7+
Transform files let you reshape webhook payloads for services like Slack, Microsoft Teams, or custom APIs. TaskNotes supports JSON templates (`.json`) with variable substitution.
88

9-
- **JavaScript files (`.js`)** - Maximum flexibility with custom logic
10-
- **JSON templates (`.json`)** - Simple variable substitution
9+
JavaScript transform files (`.js`) are no longer supported.
1110

1211
## Available Examples
1312

14-
### JavaScript Transforms
13+
### `simple-template.json`
1514

16-
#### `discord-webhook.js`
17-
Transforms TaskNotes webhooks into Discord-compatible embeds with:
18-
- Rich embed formatting with colors and emojis
19-
- Event-specific styling and information
20-
- Support for all TaskNotes webhook events including the new `recurring.instance.completed` event
21-
- Comprehensive error handling and fallback content
22-
23-
**Usage:** Copy to your vault and specify the file path in your webhook configuration.
24-
25-
#### `slack-webhook.js`
26-
Formats webhooks for Slack with:
27-
- Slack-compatible message formatting
28-
- Attachment-based layouts with color coding
29-
- Emoji reactions using Slack emoji syntax
30-
- Timestamp formatting for Slack
31-
32-
**Usage:** Copy to your vault and configure your webhook to use this transform.
33-
34-
### JSON Templates
35-
36-
#### `simple-template.json`
3715
A basic JSON template showing variable substitution:
3816
- Simple message formatting
3917
- All webhook events covered
40-
- Shows how to access nested payload properties
41-
- Good starting point for custom JSON APIs
18+
- Nested payload values such as `${data.task.title}`
19+
- A useful starting point for custom JSON APIs
20+
21+
### `minimal-slack.json`
22+
23+
A small Slack-compatible example:
24+
- Sends a text payload
25+
- Uses event-specific templates for task creation and completion
26+
- Includes a default fallback payload
27+
28+
### `teams-webhook.json`
4229

43-
#### `teams-webhook.json`
4430
Microsoft Teams connector card format:
4531
- MessageCard format for Teams webhooks
4632
- Color-coded cards by event type
4733
- Structured facts display
4834
- Schema.org compliance
4935

50-
## How to Use Transform Files
51-
52-
### 1. Copy to Your Vault
53-
Copy any example file to your Obsidian vault. You can place them anywhere, but consider creating a dedicated folder like `webhooks/transforms/`.
54-
55-
### 2. Configure Webhook
56-
When adding or editing a webhook in TaskNotes settings:
57-
1. Enter your webhook URL
58-
2. Select the events you want to receive
59-
3. In the "Transform File" field, enter the path to your transform file (e.g., `webhooks/transforms/discord-webhook.js`)
60-
4. Save the webhook
61-
62-
### 3. Test Your Integration
63-
Use the built-in test server or a service like webhook.site to verify your transform is working correctly.
36+
## How To Use Transform Files
6437

65-
## Creating Custom Transform Files
38+
1. Copy an example JSON file to your Obsidian vault. A dedicated folder such as `webhooks/transforms/` keeps these templates organized.
39+
2. Add or edit a webhook in TaskNotes settings.
40+
3. Enter the webhook URL and select the events you want to receive.
41+
4. In the "Transform File" field, enter the path to the JSON template, for example `webhooks/transforms/simple-template.json`.
42+
5. Save the webhook.
6643

67-
### JavaScript Transforms
44+
Use the built-in test server or a service like webhook.site to verify the payload shape.
6845

69-
JavaScript transforms give you maximum flexibility. Your file must export a `transform` function:
46+
## Creating Custom JSON Templates
7047

71-
```javascript
72-
function transform(payload) {
73-
const { event, data, timestamp, vault } = payload;
74-
75-
// Your custom logic here
76-
77-
return transformedPayload;
78-
}
79-
```
80-
81-
#### Available Payload Properties
82-
- `event` - The webhook event type (e.g., 'task.completed')
83-
- `data` - Event-specific data (task info, session data, etc.)
84-
- `timestamp` - ISO timestamp of when the event occurred
85-
- `vault` - Information about the Obsidian vault
86-
87-
#### JavaScript Features
88-
- Full JavaScript syntax support
89-
- Conditional logic and loops
90-
- Data transformation and enrichment
91-
- Error handling with try/catch
92-
- Return `null` to skip webhook delivery
93-
94-
#### Security Notes
95-
- JavaScript transforms run in a sandboxed environment
96-
- No access to Node.js APIs, file system, or network
97-
- No `console.log()` available (use return values for debugging)
98-
99-
### JSON Templates
100-
101-
JSON templates use simple variable substitution with `${path.to.value}` syntax:
48+
JSON templates use `${path.to.value}` variable substitution:
10249

10350
```json
10451
{
105-
"event-name": {
52+
"task.completed": {
10653
"message": "Task completed: ${data.task.title}",
10754
"priority": "${data.task.priority}",
10855
"vault": "${vault.name}"
@@ -113,123 +60,4 @@ JSON templates use simple variable substitution with `${path.to.value}` syntax:
11360
}
11461
```
11562

116-
#### Template Structure
117-
- Define templates for specific events using the event name as the key
118-
- Use `"default"` for a fallback template
119-
- Variables that don't exist remain as literal text
120-
121-
#### Variable Access
122-
- `${event}` - Event type
123-
- `${timestamp}` - Event timestamp
124-
- `${vault.name}` - Vault name
125-
- `${data.task.title}` - Task title (for task events)
126-
- `${data.task.priority}` - Task priority
127-
- `${data.task.status}` - Task status
128-
- `${data.date}` - Instance date (for recurring task completion)
129-
130-
## Webhook Events Reference
131-
132-
### Task Events
133-
- `task.created` - New task created
134-
- `task.updated` - Task modified (includes `data.previous` with old values)
135-
- `task.completed` - Task marked as complete
136-
- `task.deleted` - Task removed
137-
- `task.archived` - Task archived
138-
- `task.unarchived` - Task unarchived
139-
140-
### Time Tracking Events
141-
- `time.started` - Time tracking started
142-
- `time.stopped` - Time tracking stopped
143-
144-
### Pomodoro Events
145-
- `pomodoro.started` - Pomodoro session began
146-
- `pomodoro.completed` - Pomodoro session finished
147-
- `pomodoro.interrupted` - Pomodoro session interrupted
148-
149-
### Recurring Task Events
150-
- `recurring.instance.completed` - Recurring task instance marked complete
151-
152-
### Reminder Events
153-
- `reminder.triggered` - Task reminder fired
154-
155-
## Debugging Transform Files
156-
157-
### Testing Strategies
158-
1. Start with a simple transform that returns the original payload
159-
2. Add small changes incrementally
160-
3. Use webhook.site or the built-in test server to inspect outputs
161-
4. Check TaskNotes console for transformation errors
162-
163-
### Common Issues
164-
- **Syntax errors:** Validate JavaScript syntax and JSON format
165-
- **Missing variables:** Check that accessed properties exist in the payload
166-
- **Transform not applied:** Verify file path is correct and accessible
167-
- **Webhook failures:** Check endpoint compatibility with transformed payload
168-
169-
### Debug Information
170-
Add debug information to your transform output:
171-
172-
```javascript
173-
function transform(payload) {
174-
try {
175-
// Your transformation logic
176-
const result = { /* transformed data */ };
177-
178-
return {
179-
...result,
180-
_debug: {
181-
originalEvent: payload.event,
182-
transformedAt: new Date().toISOString()
183-
}
184-
};
185-
} catch (error) {
186-
return {
187-
error: error.message,
188-
originalPayload: payload
189-
};
190-
}
191-
}
192-
```
193-
194-
## Service-Specific Tips
195-
196-
### Discord
197-
- Use embeds for rich formatting
198-
- Colors should be hex values (e.g., `0xFF0000`)
199-
- Disable custom headers in webhook settings for Discord compatibility
200-
- Maximum embed description: 4096 characters
201-
202-
### Slack
203-
- Use attachments for structured content
204-
- Colors can be 'good', 'warning', 'danger', or hex values
205-
- Timestamp should be Unix timestamp
206-
- Use Slack emoji syntax (`:emoji_name:`)
207-
208-
### Microsoft Teams
209-
- Use MessageCard format for connector webhooks
210-
- Include `@type` and `@context` properties
211-
- Colors should be hex values without leading '#'
212-
- Facts array for key-value pairs
213-
214-
### Custom APIs
215-
- Check your API documentation for required fields
216-
- Consider rate limiting and authentication requirements
217-
- Use appropriate HTTP methods and content types
218-
- Handle webhook delivery failures gracefully
219-
220-
## Best Practices
221-
222-
1. **Keep transforms simple** - Complex logic can slow webhook delivery
223-
2. **Handle missing data** - Use fallbacks for optional fields
224-
3. **Test thoroughly** - Verify transforms work with all event types
225-
4. **Document custom fields** - Add comments explaining your logic
226-
5. **Version control** - Keep transforms in your vault for backup
227-
6. **Monitor failures** - Check webhook success/failure counts regularly
228-
229-
## Contributing
230-
231-
Found a bug in an example or have a new service integration? Contributions are welcome! Please ensure your examples:
232-
- Handle all webhook events appropriately
233-
- Include proper error handling
234-
- Are well-commented and documented
235-
- Follow the established patterns in existing examples
63+
Template keys match webhook event names. The `default` key is used when an event-specific template is not present. Missing variables remain as literal text.

0 commit comments

Comments
 (0)