forked from Nutlope/llamacoder
-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.py
362 lines (343 loc) · 11.8 KB
/
script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
import requests
import json
# GraphQL server URL
url = "http://zendesk.openapi-builder.ti.trilogy.com/graphql/"
# Headers for the request
headers = {
"Content-Type": "application/json",
}
def execute_mutation(mutation, variables=None):
payload = {
"query": mutation,
"variables": variables
}
response = requests.post(url, json=payload, headers=headers)
if response.status_code == 200:
result = response.json()
if 'errors' in result:
print(f"GraphQL Errors: {json.dumps(result['errors'], indent=2)}")
return None
return result
else:
print(f"HTTP Error: {response.status_code}")
print(f"Response: {response.text}")
return None
# # Create Organizations
# org_mutation = """
# mutation CreateOrganization($name: String!, $externalId: String!, $details: String!, $domainNames: String!, $notes: String!, $sharedComments: Boolean!, $sharedTickets: Boolean!, $tags: String!) {
# CreateOrganization(
# name: $name
# external_id: $externalId
# details: $details
# domain_names: $domainNames
# notes: $notes
# shared_comments: $sharedComments
# shared_tickets: $sharedTickets
# tags: $tags
# ) {
# id
# name
# }
# }
# """
# organizations = [
# {
# "name": "Acme Corporation",
# "externalId": "ACME001",
# "details": "A leading provider of innovative solutions",
# "domainNames": "acme.com,acmecorp.com",
# "notes": "Key account, high priority",
# "sharedComments": True,
# "sharedTickets": True,
# "tags": "enterprise,manufacturing"
# },
# {
# "name": "TechNova Solutions",
# "externalId": "TECHNOVA001",
# "details": "Cutting-edge technology consulting firm",
# "domainNames": "technova.com,technovasolutions.com",
# "notes": "Growing account, focus on AI and ML",
# "sharedComments": True,
# "sharedTickets": True,
# "tags": "technology,consulting"
# },
# {
# "name": "GreenLeaf Eco Products",
# "externalId": "GREENLEAF001",
# "details": "Sustainable and eco-friendly product manufacturer",
# "domainNames": "greenleaf.com,greenleafeco.com",
# "notes": "Emphasize sustainability in all interactions",
# "sharedComments": True,
# "sharedTickets": True,
# "tags": "eco-friendly,manufacturing"
# }
# ]
# org_ids = []
# for org in organizations:
# result = execute_mutation(org_mutation, org)
# if result and 'data' in result and 'CreateOrganization' in result['data']:
# org_ids.append(result['data']['CreateOrganization']['id'])
# print(f"Created organization: {result['data']['CreateOrganization']['name']}")
# else:
# print(f"Failed to create organization: {org['name']}")
# print(f"Result: {json.dumps(result, indent=2)}")
# # Create Groups
# group_mutation = """
# mutation CreateGroup($name: String!, $description: String!, $isPublic: Boolean!) {
# CreateGroup(
# name: $name
# description: $description
# is_public: $isPublic
# ) {
# id
# name
# }
# }
# """
# groups = [
# {
# "name": "Customer Support",
# "description": "Front-line support team handling general inquiries",
# "isPublic": True
# },
# {
# "name": "Technical Support",
# "description": "Specialized team handling complex technical issues",
# "isPublic": True
# },
# {
# "name": "Account Management",
# "description": "Team responsible for managing key accounts and relationships",
# "isPublic": False
# }
# ]
# group_ids = []
# for group in groups:
# result = execute_mutation(group_mutation, group)
# if result and 'data' in result and 'CreateGroup' in result['data']:
# group_ids.append(result['data']['CreateGroup']['id'])
# print(f"Created group: {result['data']['CreateGroup']['name']}")
# else:
# print(f"Failed to create group: {group['name']}")
# print(f"Result: {json.dumps(result, indent=2)}")
# # Create Users (Agents)
# user_mutation = """
# mutation CreateUser($name: String!, $email: String!, $role: String!, $phone: String!, $timeZone: String!, $tags: String!) {
# CreateUser(
# name: $name
# email: $email
# role: $role
# phone: $phone
# time_zone: $timeZone
# tags: $tags
# ) {
# id
# name
# email
# }
# }
# """
# users = [
# {
# "name": "John Doe",
# "email": "john.doe@example.com",
# "role": "agent",
# "phone": "+1234567890",
# "timeZone": "America/New_York",
# "tags": "customer-support,technical"
# },
# {
# "name": "Jane Smith",
# "email": "jane.smith@example.com",
# "role": "agent",
# "phone": "+1987654321",
# "timeZone": "America/Los_Angeles",
# "tags": "technical-support,senior"
# },
# {
# "name": "Mike Johnson",
# "email": "mike.johnson@example.com",
# "role": "agent",
# "phone": "+1122334455",
# "timeZone": "Europe/London",
# "tags": "account-management,enterprise"
# }
# ]
# user_ids = []
# for user in users:
# result = execute_mutation(user_mutation, user)
# if result and 'data' in result and 'CreateUser' in result['data']:
# user_ids.append(result['data']['CreateUser']['id'])
# print(f"Created user: {result['data']['CreateUser']['name']}")
# else:
# print(f"Failed to create user: {user['name']}")
# print(f"Result: {json.dumps(result, indent=2)}")
# Create Tickets
ticket_mutation = """
mutation CreateTicket($subject: String!, $description: String!, $priority: String!, $status: String!, $type: String!, $tags: String!) {
CreateTicket(
subject: $subject
description: $description
priority: $priority
status: $status
type: $type
tags: $tags
) {
id
subject
}
}
"""
tickets = [
{
"subject": "Unable to access account",
"description": "I'm having trouble logging into my account. It says my password is incorrect, but I'm sure it's right.",
"priority": "high",
"status": "open",
"type": "incident",
"tags": "account-access,login"
},
{
"subject": "Feature request: Dark mode",
"description": "It would be great if you could add a dark mode to the application. It's easier on the eyes when working late.",
"priority": "low",
"status": "new",
"type": "task",
"tags": "feature-request,ui"
},
{
"subject": "Billing discrepancy on latest invoice",
"description": "The amount on our latest invoice seems to be higher than expected. Can someone please review and explain the charges?",
"priority": "normal",
"status": "open",
"type": "problem",
"tags": "billing,invoice"
},
{
"subject": "Product not functioning as expected",
"description": "The new widget I purchased isn't working correctly. It keeps shutting off unexpectedly.",
"priority": "high",
"status": "open",
"type": "incident",
"tags": "product-issue,malfunction"
},
{
"subject": "Request for additional user licenses",
"description": "We need to add 5 more user licenses to our account. Can you please provide a quote?",
"priority": "normal",
"status": "new",
"type": "task",
"tags": "account-management,licensing"
},
{
"subject": "Integration with third-party software",
"description": "We're looking to integrate your product with our CRM system. Do you have any documentation or APIs available?",
"priority": "low",
"status": "open",
"type": "question",
"tags": "integration,api"
},
{
"subject": "Slow performance during peak hours",
"description": "We've noticed that the system becomes very slow between 2-4 PM daily. Can you investigate?",
"priority": "high",
"status": "open",
"type": "problem",
"tags": "performance,optimization"
},
{
"subject": "Training request for new team members",
"description": "We have 3 new team members who need training on your software. What options do you offer?",
"priority": "normal",
"status": "new",
"type": "task",
"tags": "training,onboarding"
},
{
"subject": "Data export functionality not working",
"description": "When trying to export our data, the process fails halfway through. We need this resolved urgently.",
"priority": "high",
"status": "open",
"type": "incident",
"tags": "data-export,bug"
},
{
"subject": "Request for custom report",
"description": "We need a custom report that shows user activity over the last 6 months. Is this possible?",
"priority": "low",
"status": "new",
"type": "task",
"tags": "reporting,customization"
},
{
"subject": "Security concern: Unusual login activity",
"description": "We've noticed some suspicious login attempts from unfamiliar IP addresses. Can you help us investigate?",
"priority": "high",
"status": "open",
"type": "problem",
"tags": "security,login-activity"
},
{
"subject": "Feature request: Mobile app",
"description": "It would be incredibly helpful if you could develop a mobile app version of your software.",
"priority": "low",
"status": "new",
"type": "task",
"tags": "feature-request,mobile"
},
{
"subject": "Assistance with bulk data import",
"description": "We're trying to import a large dataset into the system, but keep encountering errors. Can you provide guidance?",
"priority": "normal",
"status": "open",
"type": "question",
"tags": "data-import,bulk-operations"
}
]
ticket_ids = []
for ticket in tickets:
result = execute_mutation(ticket_mutation, ticket)
if result and 'data' in result and 'CreateTicket' in result['data']:
ticket_ids.append(result['data']['CreateTicket']['id'])
print(f"Created ticket: {result['data']['CreateTicket']['subject']}")
else:
print(f"Failed to create ticket: {ticket['subject']}")
print(f"Result: {json.dumps(result, indent=2)}")
# Create Ticket Comments
# comment_mutation = """
# mutation CreateTicketComment($ticketId: String!, $authorId: String!, $body: String!, $public: Boolean!) {
# CreateTicketComment(
# ticket_id: $ticketId
# author_id: $authorId
# body: $body
# public: $public
# ) {
# id
# body
# }
# }
# """
# comments = [
# {
# "body": "I've reset your password. Please try logging in with the temporary password I've sent to your email.",
# "public": True
# },
# {
# "body": "Thank you for your feature request. We've added it to our product roadmap and will consider implementing it in a future release.",
# "public": True
# },
# {
# "body": "I've reviewed your invoice and found that there was an error in the calculation. I've issued a corrected invoice and applied a credit to your account. Please let me know if you have any questions.",
# "public": True
# }
# ]
# for i, comment in enumerate(comments):
# comment['ticketId'] = ticket_ids[i]
# comment['authorId'] = user_ids[i]
# result = execute_mutation(comment_mutation, comment)
# if result and 'data' in result and 'CreateTicketComment' in result['data']:
# print(f"Created comment: {result['data']['CreateTicketComment']['id']}")
# else:
# print(f"Failed to create comment: {comment['body']}")
# print(f"Result: {json.dumps(result, indent=2)}")
# print("Data creation completed successfully!")