Add support for configuring default ticket priority via UNTHREAD_DEFAULT_PRIORITY environment variable#31
Conversation
Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
warengonzaga
left a comment
There was a problem hiding this comment.
@copilot let's add a default value here. Let's set it to 5 or medium priority.
The default value of 5 (medium priority) has been set in the .env.example file as requested. The UNTHREAD_DEFAULT_PRIORITY environment variable is now configured with this default value, providing automatic medium priority assignment for new tickets while maintaining backward compatibility. f5ccd78 |
|
@copilot can you bump the version according to your changes? |
Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
Version bumped to 1.0.0-beta.6 to reflect the new UNTHREAD_DEFAULT_PRIORITY feature addition. b9da554 |
There was a problem hiding this comment.
Pull Request Overview
Adds support for setting a default ticket priority via the UNTHREAD_DEFAULT_PRIORITY environment variable, with validation and optional payload inclusion.
- Introduces
getDefaultTicketPriority()for parsing and validating the env var - Updates
createTicketJSONto includeprioritywhen configured and logs its value - Updates version,
.env.example, and documentation for the new variable
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/config/env.ts | Added getDefaultTicketPriority with validation and warning |
| src/services/unthread.ts | Fetched default priority, conditionally added priority to payload, and enhanced logs |
| package.json | Bumped version to 1.0.0-beta.6 |
| .env.example | Documented UNTHREAD_DEFAULT_PRIORITY with allowed values |
Comments suppressed due to low confidence (2)
src/config/env.ts:95
- There are no unit tests for
getDefaultTicketPriority. Add tests to cover valid values, invalid strings, and the unset case to prevent regressions.
export function getDefaultTicketPriority(): 3 | 5 | 7 | 9 | undefined {
src/services/unthread.ts:320
- Add unit tests for
createTicketJSONto assert thatpriorityis included whenUNTHREAD_DEFAULT_PRIORITYis set and omitted otherwise.
if (defaultPriority !== undefined) {
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot suggest a fix here: #31 (comment) |
…afety Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
Fixed! Replaced the |
|
@copilot can you get the latest code from the |
…TicketPayload Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
Fixed the TypeScript compilation error by adding a non-null assertion operator for CHANNEL_ID in the CreateTicketPayload. The validation check ensures the value is defined, so the assertion is safe. 2eb68b8 |
|
@copilot can you ensure that all of the configuration for the bot is required? I can see the |
Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
... All bot configuration is now required with centralized validation. Added |
This PR adds support for configuring default ticket priority for messages received through the Telegram bot using the
UNTHREAD_DEFAULT_PRIORITYenvironment variable. This enables automatic priority assignment for tickets based on deployment configuration, which is particularly valuable for business-critical channels.Changes Made
1. Environment Configuration (
src/config/env.ts)getDefaultTicketPriority()function with validation for Unthread API priority values3(low),5(medium),7(high),9(critical)2. Ticket Creation (
src/services/unthread.ts)createTicketJSON()to conditionally include priority field in API payload3. Documentation (
.env.example)UNTHREAD_DEFAULT_PRIORITYwith clear usage examplesUsage Examples
API Payload Changes
Before (current behavior maintained when variable not set):
{ "type": "slack", "title": "[Telegram Ticket] Acme Corp", "status": "open", "customerId": "cust_123", "onBehalfOf": { ... } }After (when
UNTHREAD_DEFAULT_PRIORITY=7):{ "type": "slack", "title": "[Telegram Ticket] Acme Corp", "status": "open", "customerId": "cust_123", "onBehalfOf": { ... }, "priority": 7 }Key Features
This implementation allows different deployments to automatically tag tickets with appropriate priorities without hardcoding preferences, enabling better workflow management across business-critical and standard support channels.
Fixes #30.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.