0
# Service Desk
1
2
JIRA Service Desk functionality for customer request management and service desk operations. This enables automation of IT service management workflows and customer support processes.
3
4
## Capabilities
5
6
### Service Desk Detection
7
8
Check if JIRA Service Desk is available and supported.
9
10
```python { .api }
11
def supports_service_desk(self) -> bool:
12
"""
13
Check if JIRA Service Desk is supported on this instance.
14
15
Returns:
16
Boolean indicating Service Desk support
17
"""
18
```
19
20
Usage example:
21
```python
22
# Check Service Desk availability
23
if jira.supports_service_desk():
24
print("Service Desk is available")
25
# Proceed with Service Desk operations
26
else:
27
print("Service Desk is not available on this JIRA instance")
28
```
29
30
### Service Desk Management
31
32
Operations for managing Service Desk instances.
33
34
```python { .api }
35
def service_desks(self) -> list[ServiceDesk]:
36
"""
37
Get all Service Desk instances.
38
39
Returns:
40
List of ServiceDesk objects
41
"""
42
43
def service_desk(self, id: str) -> ServiceDesk:
44
"""
45
Get a specific Service Desk by ID.
46
47
Parameters:
48
- id: Service Desk ID
49
50
Returns:
51
ServiceDesk object
52
"""
53
```
54
55
Usage examples:
56
```python
57
# Get all service desks
58
service_desks = jira.service_desks()
59
for desk in service_desks:
60
print(f"Service Desk: {desk.projectName} (ID: {desk.id})")
61
print(f"Key: {desk.projectKey}")
62
print(f"Links: {desk._links}")
63
64
# Get specific service desk
65
it_desk = jira.service_desk('1')
66
print(f"IT Service Desk: {it_desk.projectName}")
67
```
68
69
### Customer Management
70
71
Operations for managing Service Desk customers.
72
73
```python { .api }
74
def create_customer(self, email: str, displayName: str) -> Customer:
75
"""
76
Create a Service Desk customer.
77
78
Parameters:
79
- email: Customer email address
80
- displayName: Customer display name
81
82
Returns:
83
Created Customer object
84
"""
85
```
86
87
Usage examples:
88
```python
89
# Create new customer
90
customer = jira.create_customer(
91
email='customer@example.com',
92
displayName='John Customer'
93
)
94
print(f"Created customer: {customer.displayName}")
95
print(f"Customer ID: {customer.accountId}")
96
97
# Create multiple customers
98
customers_data = [
99
{'email': 'alice@company.com', 'name': 'Alice Johnson'},
100
{'email': 'bob@company.com', 'name': 'Bob Smith'},
101
{'email': 'carol@company.com', 'name': 'Carol Wilson'}
102
]
103
104
for customer_data in customers_data:
105
customer = jira.create_customer(
106
email=customer_data['email'],
107
displayName=customer_data['name']
108
)
109
print(f"Created customer: {customer.displayName}")
110
```
111
112
### Request Type Management
113
114
Operations for managing Service Desk request types.
115
116
```python { .api }
117
def request_types(self, service_desk: str) -> list[RequestType]:
118
"""
119
Get request types for a Service Desk.
120
121
Parameters:
122
- service_desk: Service Desk ID
123
124
Returns:
125
List of RequestType objects
126
"""
127
128
def request_type_by_name(self, service_desk: str, name: str) -> RequestType:
129
"""
130
Get request type by name.
131
132
Parameters:
133
- service_desk: Service Desk ID
134
- name: Request type name
135
136
Returns:
137
RequestType object
138
"""
139
```
140
141
Usage examples:
142
```python
143
# Get all request types for a service desk
144
service_desk_id = '1'
145
request_types = jira.request_types(service_desk_id)
146
for req_type in request_types:
147
print(f"Request Type: {req_type.name}")
148
print(f"Description: {req_type.description}")
149
print(f"Issue Type: {req_type.issueTypeId}")
150
151
# Get specific request type by name
152
incident_type = jira.request_type_by_name(service_desk_id, 'Incident')
153
print(f"Incident request type ID: {incident_type.id}")
154
155
# Find request type for creating requests
156
access_request = jira.request_type_by_name(service_desk_id, 'Access Request')
157
if access_request:
158
print(f"Found Access Request type: {access_request.id}")
159
```
160
161
### Customer Request Creation
162
163
Create customer requests (Service Desk tickets).
164
165
```python { .api }
166
def create_customer_request(
167
self,
168
fields: dict = None,
169
prefetch: bool = True,
170
**fieldargs
171
) -> dict:
172
"""
173
Create a customer request in Service Desk.
174
175
Parameters:
176
- fields: Dictionary of field values
177
- prefetch: Whether to fetch the created request details
178
- **fieldargs: Field values as keyword arguments
179
180
Returns:
181
Created customer request dictionary
182
"""
183
```
184
185
Usage examples:
186
```python
187
# Create incident request
188
incident_request = jira.create_customer_request(
189
serviceDeskId='1',
190
requestTypeId='10001', # Incident request type ID
191
summary='System is down',
192
description='The main application server is not responding',
193
reporter={'name': 'customer@example.com'}
194
)
195
print(f"Created incident: {incident_request['issueKey']}")
196
197
# Create access request with custom fields
198
access_request = jira.create_customer_request(
199
serviceDeskId='1',
200
requestTypeId='10002', # Access request type ID
201
summary='Network access for new employee',
202
description='Please provide network access for John Doe',
203
reporter={'name': 'hr@company.com'},
204
customfield_10010='John Doe', # Employee name field
205
customfield_10011='Engineering' # Department field
206
)
207
208
# Create request with attachments
209
hardware_request = jira.create_customer_request(
210
serviceDeskId='1',
211
requestTypeId='10003',
212
summary='Laptop replacement request',
213
description='Current laptop is failing, need replacement',
214
reporter={'name': 'employee@company.com'}
215
)
216
217
# Add attachment to the request after creation
218
with open('hardware_specs.pdf', 'rb') as f:
219
jira.add_attachment(hardware_request['issueKey'], f)
220
```
221
222
## Service Desk Workflow Examples
223
224
### Automated Incident Response
225
226
Automate common incident response workflows:
227
228
```python
229
def create_incident_with_priority(summary, description, priority='Medium'):
230
"""Create incident with automatic priority assignment."""
231
232
# Map priority to appropriate request type
233
priority_map = {
234
'Critical': '10001', # Critical incident type
235
'High': '10002', # High priority incident type
236
'Medium': '10003', # Standard incident type
237
'Low': '10004' # Low priority incident type
238
}
239
240
request_type_id = priority_map.get(priority, '10003')
241
242
incident = jira.create_customer_request(
243
serviceDeskId='1',
244
requestTypeId=request_type_id,
245
summary=summary,
246
description=description,
247
priority={'name': priority}
248
)
249
250
# Auto-assign critical incidents
251
if priority == 'Critical':
252
jira.assign_issue(incident['issueKey'], 'on-call-engineer')
253
254
# Add internal comment for critical incidents
255
jira.add_comment(
256
incident['issueKey'],
257
'Critical incident - escalated to on-call engineer',
258
is_internal=True
259
)
260
261
return incident
262
263
# Create incidents with different priorities
264
critical_incident = create_incident_with_priority(
265
'Database server crashed',
266
'Primary database server is not responding',
267
'Critical'
268
)
269
270
routine_request = create_incident_with_priority(
271
'Password reset request',
272
'User needs password reset for email account',
273
'Low'
274
)
275
```
276
277
### Bulk Customer Creation
278
279
Create multiple customers from a data source:
280
281
```python
282
import csv
283
284
def bulk_create_customers(csv_file_path):
285
"""Create customers from CSV file."""
286
created_customers = []
287
288
with open(csv_file_path, 'r') as file:
289
reader = csv.DictReader(file)
290
for row in reader:
291
try:
292
customer = jira.create_customer(
293
email=row['email'],
294
displayName=row['display_name']
295
)
296
created_customers.append(customer)
297
print(f"Created customer: {customer.displayName}")
298
except Exception as e:
299
print(f"Failed to create customer {row['email']}: {e}")
300
301
return created_customers
302
303
# CSV format: email,display_name
304
# customer1@company.com,John Smith
305
# customer2@company.com,Jane Doe
306
customers = bulk_create_customers('new_customers.csv')
307
```
308
309
### Service Level Agreement (SLA) Monitoring
310
311
Monitor and report on SLA compliance:
312
313
```python
314
def check_sla_breaches(service_desk_id, hours_threshold=24):
315
"""Check for potential SLA breaches."""
316
317
# Search for open requests older than threshold
318
from datetime import datetime, timedelta
319
320
threshold_date = datetime.now() - timedelta(hours=hours_threshold)
321
threshold_str = threshold_date.strftime('%Y-%m-%d %H:%M')
322
323
# Search for requests approaching SLA breach
324
jql = f'''
325
project = "{service_desk_id}" AND
326
status not in (Resolved, Closed) AND
327
created <= "{threshold_str}"
328
ORDER BY created ASC
329
'''
330
331
at_risk_requests = jira.search_issues(jql)
332
333
for request in at_risk_requests:
334
hours_open = (datetime.now() - datetime.strptime(
335
request.fields.created[:19], '%Y-%m-%dT%H:%M:%S'
336
)).total_seconds() / 3600
337
338
print(f"Request {request.key}: Open for {hours_open:.1f} hours")
339
340
# Add internal comment about SLA risk
341
if hours_open > hours_threshold:
342
jira.add_comment(
343
request,
344
f'SLA ALERT: Request has been open for {hours_open:.1f} hours',
345
is_internal=True
346
)
347
348
return at_risk_requests
349
350
# Check for SLA breaches daily
351
at_risk = check_sla_breaches('SD', hours_threshold=24)
352
print(f"Found {len(at_risk)} requests at risk of SLA breach")
353
```
354
355
## Service Desk Best Practices
356
357
### Request Type Mapping
358
359
Map request types to appropriate workflows:
360
361
```python
362
# Get and cache request types for efficiency
363
def get_request_type_mapping(service_desk_id):
364
"""Create mapping of request type names to IDs."""
365
request_types = jira.request_types(service_desk_id)
366
return {rt.name: rt.id for rt in request_types}
367
368
# Use mapping for request creation
369
request_type_map = get_request_type_mapping('1')
370
371
# Create different types of requests
372
request_configs = [
373
{
374
'type': 'Hardware Request',
375
'summary': 'New laptop needed',
376
'description': 'Employee needs laptop for remote work'
377
},
378
{
379
'type': 'Software Request',
380
'summary': 'Adobe Creative Suite license',
381
'description': 'Designer needs Creative Suite access'
382
},
383
{
384
'type': 'Incident',
385
'summary': 'Email server issues',
386
'description': 'Users cannot send emails'
387
}
388
]
389
390
for config in request_configs:
391
if config['type'] in request_type_map:
392
request = jira.create_customer_request(
393
serviceDeskId='1',
394
requestTypeId=request_type_map[config['type']],
395
summary=config['summary'],
396
description=config['description']
397
)
398
print(f"Created {config['type']}: {request['issueKey']}")
399
```
400
401
### Customer Portal Integration
402
403
Integrate with customer portals and external systems:
404
405
```python
406
def create_request_from_portal(portal_data):
407
"""Create Service Desk request from portal submission."""
408
409
# Validate required fields
410
required_fields = ['customer_email', 'summary', 'description', 'category']
411
for field in required_fields:
412
if field not in portal_data:
413
raise ValueError(f"Missing required field: {field}")
414
415
# Map portal categories to request types
416
category_mapping = {
417
'technical_issue': '10001',
418
'access_request': '10002',
419
'hardware_request': '10003',
420
'software_request': '10004'
421
}
422
423
request_type_id = category_mapping.get(
424
portal_data['category'],
425
'10001' # Default to technical issue
426
)
427
428
# Create the request
429
request = jira.create_customer_request(
430
serviceDeskId='1',
431
requestTypeId=request_type_id,
432
summary=portal_data['summary'],
433
description=portal_data['description'],
434
reporter={'name': portal_data['customer_email']}
435
)
436
437
# Add any attachments
438
if 'attachments' in portal_data:
439
for attachment_path in portal_data['attachments']:
440
with open(attachment_path, 'rb') as f:
441
jira.add_attachment(request['issueKey'], f)
442
443
return request
444
445
# Example portal submission
446
portal_submission = {
447
'customer_email': 'user@company.com',
448
'summary': 'Cannot access shared drive',
449
'description': 'Getting permission denied error when accessing \\\\server\\shared',
450
'category': 'technical_issue',
451
'attachments': ['error_screenshot.png']
452
}
453
454
request = create_request_from_portal(portal_submission)
455
print(f"Created request from portal: {request['issueKey']}")
456
```