-
Notifications
You must be signed in to change notification settings - Fork 1
/
slack_card.py
177 lines (173 loc) · 6.08 KB
/
slack_card.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
def construct_slack_card(channel_id, services: dict, escalations: dict, users: dict):
trimmed_services = {k: services[k] for i, k in enumerate(services) if i < 100}
slack_card = {
"private_metadata": channel_id,
"callback_id": "create_incident",
"type": "modal",
"title": {
"type": "plain_text",
"text": "Create an incident",
"emoji": True,
},
"submit": {"type": "plain_text", "text": "Submit", "emoji": True},
"close": {"type": "plain_text", "text": "Cancel", "emoji": True},
"blocks": [
{
"block_id": "service_id",
"type": "input",
"label": {
"type": "plain_text",
"text": "Select your Service",
"emoji": True,
},
"element": {
"type": "static_select",
"action_id": "service_id",
"placeholder": {
"type": "plain_text",
"text": "Select an item",
"emoji": True,
},
"options": [
{
"text": {
"type": "plain_text",
"text": service_name,
"emoji": True,
},
"value": str(service_id),
}
for service_id, service_name in trimmed_services.items()
],
},
},
{
"block_id": "urgency",
"type": "input",
"label": {
"type": "plain_text",
"text": "Select Urgency",
"emoji": True,
},
"element": {
"type": "static_select",
"action_id": "urgency",
"placeholder": {
"type": "plain_text",
"text": "Select urgency",
"emoji": True,
},
"options": [
{
"text": {
"type": "plain_text",
"text": "High",
"emoji": True,
},
"value": "1",
},
{
"text": {
"type": "plain_text",
"text": "Low",
"emoji": True,
},
"value": "0",
},
],
},
},
# {
# "block_id": "assigned_to_id",
# "type": "input",
# "label": {
# "type": "plain_text",
# "text": "Assign To",
# "emoji": True,
# },
# "element": {
# "type": "static_select",
# "action_id": "assigned_to_id",
# "placeholder": {
# "type": "plain_text",
# "text": "Select assignee",
# "emoji": True,
# },
# "options": [
# {
# "text": {
# "type": "plain_text",
# "text": f"{ep_name}",
# "emoji": True,
# },
# "value": f"ep-{ep_id}",
# }
# for ep_id, ep_name in escalations.items()
# ]
# + [
# {
# "text": {
# "type": "plain_text",
# "text": f"{fullname}",
# "emoji": True,
# },
# "value": f"user-{username}",
# }
# for username, fullname in users.items()
# ],
# },
# },
{
"block_id": "title",
"type": "input",
"label": {
"type": "plain_text",
"text": "Incident Title",
"emoji": True,
},
"element": {
"action_id": "title",
"type": "plain_text_input",
"multiline": False,
},
},
{
"block_id": "summary",
"type": "input",
"label": {
"type": "plain_text",
"text": "Summary",
"emoji": True,
},
"element": {
"action_id": "summary",
"type": "plain_text_input",
"multiline": True,
},
},
],
}
return slack_card
help_block = [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Hey there 👋 I'm the Zenduty bot. I'm here to help you create incidents",
},
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*1️⃣ Use the `/zenduty-bot create` command* and I'll ask for the incidents details in a dialog. Try it out by using the `/zenduty create` command in this channel.", # noqa
},
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*2️⃣ Use the `/zenduty-bot update services` command* and I'll fetch the services to create incidents", # noqa
},
},
]