質問編集履歴
4
追加の文章
test
CHANGED
File without changes
|
test
CHANGED
@@ -190,6 +190,8 @@
|
|
190
190
|
|
191
191
|
```
|
192
192
|
|
193
|
+
すると、ダイアログが開きます。
|
194
|
+
|
193
195
|
###やりたいこと
|
194
196
|
|
195
197
|
"/hogehoge"と入力すると、ボタン付きメッセージが送られてきて、ボタンを押すとダイアログが立ち上がるようにしたい。
|
3
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,7 +52,7 @@
|
|
52
52
|
|
53
53
|
"fallback": "Sorry, no support for buttons.",
|
54
54
|
|
55
|
-
"callback_id": "
|
55
|
+
"callback_id": "lessonbutton",
|
56
56
|
|
57
57
|
"color": "#3AA3E3",
|
58
58
|
|
2
コード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,6 +14,182 @@
|
|
14
14
|
|
15
15
|
- Slash Command
|
16
16
|
|
17
|
+
###現段階のコード
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
```javascript
|
22
|
+
|
23
|
+
//Slash Comandを受信
|
24
|
+
|
25
|
+
function doPost(e){
|
26
|
+
|
27
|
+
var response = send_Button(e);
|
28
|
+
|
29
|
+
return ContentService.createTextOutput(JSON.stringify(response)).setMimeType(ContentService.MimeType.JSON);
|
30
|
+
|
31
|
+
}
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
function send_Button(e) {
|
36
|
+
|
37
|
+
var input_text = e.parameter.text;
|
38
|
+
|
39
|
+
var slackUrl = "https://hooks.slack.com/services/xxxxx.....xxxxxxx";
|
40
|
+
|
41
|
+
// message text
|
42
|
+
|
43
|
+
var messageData = {
|
44
|
+
|
45
|
+
"text":"subject:"+input_text,
|
46
|
+
|
47
|
+
"attachments": [
|
48
|
+
|
49
|
+
{
|
50
|
+
|
51
|
+
"text": "Are you ok?",
|
52
|
+
|
53
|
+
"fallback": "Sorry, no support for buttons.",
|
54
|
+
|
55
|
+
"callback_id": "registerticketstoredmine",
|
56
|
+
|
57
|
+
"color": "#3AA3E3",
|
58
|
+
|
59
|
+
"attachment_type": "default",
|
60
|
+
|
61
|
+
"actions": [
|
62
|
+
|
63
|
+
{
|
64
|
+
|
65
|
+
"name": "button",
|
66
|
+
|
67
|
+
"text": "OK",
|
68
|
+
|
69
|
+
"style": "primary",
|
70
|
+
|
71
|
+
"type": "button",
|
72
|
+
|
73
|
+
"value": "ok"
|
74
|
+
|
75
|
+
}]
|
76
|
+
|
77
|
+
}]
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
// format for Slack
|
86
|
+
|
87
|
+
var options = {
|
88
|
+
|
89
|
+
'method' : 'post',
|
90
|
+
|
91
|
+
'contentType': 'application/json',
|
92
|
+
|
93
|
+
// Convert the JavaScript object to a JSON string.
|
94
|
+
|
95
|
+
'payload' : JSON.stringify(messageData)
|
96
|
+
|
97
|
+
};
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
// post to Slack
|
102
|
+
|
103
|
+
UrlFetchApp.fetch(slackUrl, options);
|
104
|
+
|
105
|
+
return input_text;
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
```
|
110
|
+
|
111
|
+
すると、Slackにボタン付きInteractive Messageが届きます。
|
112
|
+
|
113
|
+
```javascript
|
114
|
+
|
115
|
+
function Slack_Dialog(e) {
|
116
|
+
|
117
|
+
var text = e.parameter.text;
|
118
|
+
|
119
|
+
var response = {text: text};
|
120
|
+
|
121
|
+
var trigger_id = e.parameter.trigger_id;
|
122
|
+
|
123
|
+
var slackUrl = "https://hogehogehoge.slack.com/api/dialog.open";
|
124
|
+
|
125
|
+
var dialog = {
|
126
|
+
|
127
|
+
"token": "xoxxxxxxxxxxxxxxxxxxxxxxxxxxxxx....xxxx",
|
128
|
+
|
129
|
+
"trigger_id": trigger_id,
|
130
|
+
|
131
|
+
"dialog": JSON.stringify({
|
132
|
+
|
133
|
+
"callback_id": "wantdo3",
|
134
|
+
|
135
|
+
"title": "What do you want to do there?",
|
136
|
+
|
137
|
+
"submit_label": "Request",
|
138
|
+
|
139
|
+
"elements": [
|
140
|
+
|
141
|
+
{
|
142
|
+
|
143
|
+
"type": "text",
|
144
|
+
|
145
|
+
"label": "In The Morning",
|
146
|
+
|
147
|
+
"name": "dialg_morning"
|
148
|
+
|
149
|
+
},
|
150
|
+
|
151
|
+
{
|
152
|
+
|
153
|
+
"type": "text",
|
154
|
+
|
155
|
+
"label": "In The Afternoon",
|
156
|
+
|
157
|
+
"name": "dialg_afternoon"
|
158
|
+
|
159
|
+
},
|
160
|
+
|
161
|
+
{
|
162
|
+
|
163
|
+
"type": "text",
|
164
|
+
|
165
|
+
"label": "In The Night",
|
166
|
+
|
167
|
+
"name": "dialg_night"
|
168
|
+
|
169
|
+
}
|
170
|
+
|
171
|
+
]
|
172
|
+
|
173
|
+
})
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
var options = {
|
178
|
+
|
179
|
+
'method' : 'post',
|
180
|
+
|
181
|
+
'payload' : dialog,
|
182
|
+
|
183
|
+
};
|
184
|
+
|
185
|
+
return response = UrlFetchApp.fetch(slackUrl, options);
|
186
|
+
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
```
|
192
|
+
|
17
193
|
###やりたいこと
|
18
194
|
|
19
195
|
"/hogehoge"と入力すると、ボタン付きメッセージが送られてきて、ボタンを押すとダイアログが立ち上がるようにしたい。
|
1
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
###やりたいこと
|
18
18
|
|
19
|
-
"/hogehoge"と入力すると、ボタン付きメッセージが送られてきて、ボタンを押すと
|
19
|
+
"/hogehoge"と入力すると、ボタン付きメッセージが送られてきて、ボタンを押すとダイアログが立ち上がるようにしたい。
|
20
20
|
|
21
21
|
[https://www.slideshare.net/yasuyuki_ogawa/slack-apps](https://www.slideshare.net/yasuyuki_ogawa/slack-apps)
|
22
22
|
|