質問編集履歴
4
追加の文章
title
CHANGED
File without changes
|
body
CHANGED
@@ -94,6 +94,7 @@
|
|
94
94
|
}
|
95
95
|
|
96
96
|
```
|
97
|
+
すると、ダイアログが開きます。
|
97
98
|
###やりたいこと
|
98
99
|
"/hogehoge"と入力すると、ボタン付きメッセージが送られてきて、ボタンを押すとダイアログが立ち上がるようにしたい。
|
99
100
|
[https://www.slideshare.net/yasuyuki_ogawa/slack-apps](https://www.slideshare.net/yasuyuki_ogawa/slack-apps)
|
3
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -25,7 +25,7 @@
|
|
25
25
|
{
|
26
26
|
"text": "Are you ok?",
|
27
27
|
"fallback": "Sorry, no support for buttons.",
|
28
|
-
"callback_id": "
|
28
|
+
"callback_id": "lessonbutton",
|
29
29
|
"color": "#3AA3E3",
|
30
30
|
"attachment_type": "default",
|
31
31
|
"actions": [
|
2
コード追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -6,6 +6,94 @@
|
|
6
6
|
- Incoming Webhooks
|
7
7
|
- Slack API
|
8
8
|
- Slash Command
|
9
|
+
###現段階のコード
|
10
|
+
|
11
|
+
```javascript
|
12
|
+
//Slash Comandを受信
|
13
|
+
function doPost(e){
|
14
|
+
var response = send_Button(e);
|
15
|
+
return ContentService.createTextOutput(JSON.stringify(response)).setMimeType(ContentService.MimeType.JSON);
|
16
|
+
}
|
17
|
+
|
18
|
+
function send_Button(e) {
|
19
|
+
var input_text = e.parameter.text;
|
20
|
+
var slackUrl = "https://hooks.slack.com/services/xxxxx.....xxxxxxx";
|
21
|
+
// message text
|
22
|
+
var messageData = {
|
23
|
+
"text":"subject:"+input_text,
|
24
|
+
"attachments": [
|
25
|
+
{
|
26
|
+
"text": "Are you ok?",
|
27
|
+
"fallback": "Sorry, no support for buttons.",
|
28
|
+
"callback_id": "registerticketstoredmine",
|
29
|
+
"color": "#3AA3E3",
|
30
|
+
"attachment_type": "default",
|
31
|
+
"actions": [
|
32
|
+
{
|
33
|
+
"name": "button",
|
34
|
+
"text": "OK",
|
35
|
+
"style": "primary",
|
36
|
+
"type": "button",
|
37
|
+
"value": "ok"
|
38
|
+
}]
|
39
|
+
}]
|
40
|
+
}
|
41
|
+
|
42
|
+
|
43
|
+
// format for Slack
|
44
|
+
var options = {
|
45
|
+
'method' : 'post',
|
46
|
+
'contentType': 'application/json',
|
47
|
+
// Convert the JavaScript object to a JSON string.
|
48
|
+
'payload' : JSON.stringify(messageData)
|
49
|
+
};
|
50
|
+
|
51
|
+
// post to Slack
|
52
|
+
UrlFetchApp.fetch(slackUrl, options);
|
53
|
+
return input_text;
|
54
|
+
}
|
55
|
+
```
|
56
|
+
すると、Slackにボタン付きInteractive Messageが届きます。
|
57
|
+
```javascript
|
58
|
+
function Slack_Dialog(e) {
|
59
|
+
var text = e.parameter.text;
|
60
|
+
var response = {text: text};
|
61
|
+
var trigger_id = e.parameter.trigger_id;
|
62
|
+
var slackUrl = "https://hogehogehoge.slack.com/api/dialog.open";
|
63
|
+
var dialog = {
|
64
|
+
"token": "xoxxxxxxxxxxxxxxxxxxxxxxxxxxxxx....xxxx",
|
65
|
+
"trigger_id": trigger_id,
|
66
|
+
"dialog": JSON.stringify({
|
67
|
+
"callback_id": "wantdo3",
|
68
|
+
"title": "What do you want to do there?",
|
69
|
+
"submit_label": "Request",
|
70
|
+
"elements": [
|
71
|
+
{
|
72
|
+
"type": "text",
|
73
|
+
"label": "In The Morning",
|
74
|
+
"name": "dialg_morning"
|
75
|
+
},
|
76
|
+
{
|
77
|
+
"type": "text",
|
78
|
+
"label": "In The Afternoon",
|
79
|
+
"name": "dialg_afternoon"
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"type": "text",
|
83
|
+
"label": "In The Night",
|
84
|
+
"name": "dialg_night"
|
85
|
+
}
|
86
|
+
]
|
87
|
+
})
|
88
|
+
}
|
89
|
+
var options = {
|
90
|
+
'method' : 'post',
|
91
|
+
'payload' : dialog,
|
92
|
+
};
|
93
|
+
return response = UrlFetchApp.fetch(slackUrl, options);
|
94
|
+
}
|
95
|
+
|
96
|
+
```
|
9
97
|
###やりたいこと
|
10
98
|
"/hogehoge"と入力すると、ボタン付きメッセージが送られてきて、ボタンを押すとダイアログが立ち上がるようにしたい。
|
11
99
|
[https://www.slideshare.net/yasuyuki_ogawa/slack-apps](https://www.slideshare.net/yasuyuki_ogawa/slack-apps)
|
1
誤字
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
- Slack API
|
8
8
|
- Slash Command
|
9
9
|
###やりたいこと
|
10
|
-
"/hogehoge"と入力すると、ボタン付きメッセージが送られてきて、ボタンを押すと
|
10
|
+
"/hogehoge"と入力すると、ボタン付きメッセージが送られてきて、ボタンを押すとダイアログが立ち上がるようにしたい。
|
11
11
|
[https://www.slideshare.net/yasuyuki_ogawa/slack-apps](https://www.slideshare.net/yasuyuki_ogawa/slack-apps)
|
12
12
|
こちらのリンクのスライド(p14)にコールバックが大事云々とありました。
|
13
13
|
しかし、当方、まだコールバックを理解しておりません。
|