質問編集履歴
8
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
実行した時のpayloadを見ると、タイムスタンプが含まれていませんでした。
|
18
18
|
おそらく、ダイアログが実行されてその結果がdoPostに返されるとき、返されるtsはaction_tsのため、
|
19
|
-
chat.updateに必要なtsを`var message_ts = json['
|
19
|
+
chat.updateに必要なtsを`var message_ts = json['message_ts'];`として得ようとするとダメなんでしょうか。
|
20
20
|
|
21
21
|
または、Slack への送信はwebhookを使っているため、chat.updateを書き換えのときだけ使用しているのがいけないのでしょうか。
|
22
22
|
chat.updateとresponse_urlのどちらかを使えとSlackの公式に書きてありましたが、response_urlの場合、制限があるようなので今回のプログラムには使いたくないです。
|
7
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -51,7 +51,7 @@
|
|
51
51
|
var url= 'https://hoge/slack.com/api/chat.update';
|
52
52
|
// get object elements
|
53
53
|
var user = json['user'].name;
|
54
|
-
var message_ts = json['
|
54
|
+
var message_ts = json['message_ts'];//ここがボタンを押したときのタイムスタンプでないとダメ?
|
55
55
|
var channel_id = json['channel'].id;
|
56
56
|
var payload = {
|
57
57
|
"token" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxb",
|
6
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -86,4 +86,16 @@
|
|
86
86
|
var result = UrlFetchApp.fetch(response_url, options);
|
87
87
|
return ContentService.createTextOutput();
|
88
88
|
}
|
89
|
+
```
|
90
|
+
###追記2
|
91
|
+
```json
|
92
|
+
//resultの結果
|
93
|
+
{"ok":false,"error":"message_not_found"}
|
94
|
+
|
95
|
+
//payloadの中身
|
96
|
+
{"type":"dialog_submission","token":"LXXXXXXXXXXXXX","action_ts":"1535445637.513198",
|
97
|
+
"team":{"id":"XXXXX","domain":"hogehoge"},"user":{"id":"XXXXXXX","name":"XXXX"},
|
98
|
+
"channel":{"id":"XXXXXX","name":"XXXXXX"},"submission":{"dialg_subject":"入力したものはちゃんと取得"},
|
99
|
+
"callback_id":"dialog","response_url":"https://hooks.slack.com/app/.....","state":""}
|
100
|
+
|
89
101
|
```
|
5
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -74,7 +74,7 @@
|
|
74
74
|
if (callback_id == 'hogehogehoge'){
|
75
75
|
var response_url = 'https://slack.com/api/chat.update';
|
76
76
|
var user = json['user'].name;
|
77
|
-
var message_ts = json['
|
77
|
+
var message_ts = json['message_ts'];
|
78
78
|
var channel_id = json['channel'].id;
|
79
79
|
var payload = {
|
80
80
|
'token':'xoxp-xxxxxxx-xxxxx...xxxc',
|
4
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -85,4 +85,5 @@
|
|
85
85
|
var options = {'method':'post','payload':payload};
|
86
86
|
var result = UrlFetchApp.fetch(response_url, options);
|
87
87
|
return ContentService.createTextOutput();
|
88
|
+
}
|
88
89
|
```
|
3
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -65,4 +65,24 @@
|
|
65
65
|
}
|
66
66
|
//以下略
|
67
67
|
}
|
68
|
+
```
|
69
|
+
|
70
|
+
###追記
|
71
|
+
chat.updateのpayloadの中身と周辺です。
|
72
|
+
buttonが押されたときのcallback_idで分岐しています。
|
73
|
+
```javascript
|
74
|
+
if (callback_id == 'hogehogehoge'){
|
75
|
+
var response_url = 'https://slack.com/api/chat.update';
|
76
|
+
var user = json['user'].name;
|
77
|
+
var message_ts = json['ts'];
|
78
|
+
var channel_id = json['channel'].id;
|
79
|
+
var payload = {
|
80
|
+
'token':'xoxp-xxxxxxx-xxxxx...xxxc',
|
81
|
+
'channel' : channel_id,
|
82
|
+
'ts' : message_ts,
|
83
|
+
'text' : '入力してください\n'+subject+'\n'+description+'\n'+words,
|
84
|
+
};
|
85
|
+
var options = {'method':'post','payload':payload};
|
86
|
+
var result = UrlFetchApp.fetch(response_url, options);
|
87
|
+
return ContentService.createTextOutput();
|
68
88
|
```
|
2
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -57,7 +57,7 @@
|
|
57
57
|
"token" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxb",
|
58
58
|
'channel' : channel_id,
|
59
59
|
'ts' : message_ts,
|
60
|
-
'text' :
|
60
|
+
'text' : subject+"\n"+description+"\n"+words,//書き換え後のテキスト
|
61
61
|
};
|
62
62
|
var options = {'method':'post','payload':payload};
|
63
63
|
|
1
誤字
title
CHANGED
File without changes
|
body
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
おそらく、ダイアログが実行されてその結果がdoPostに返されるとき、返されるtsはaction_tsのため、
|
19
19
|
chat.updateに必要なtsを`var message_ts = json['ts'];`として得ようとするとダメなんでしょうか。
|
20
20
|
|
21
|
-
または、Slack への送信は
|
21
|
+
または、Slack への送信はwebhookを使っているため、chat.updateを書き換えのときだけ使用しているのがいけないのでしょうか。
|
22
22
|
chat.updateとresponse_urlのどちらかを使えとSlackの公式に書きてありましたが、response_urlの場合、制限があるようなので今回のプログラムには使いたくないです。
|
23
23
|
|
24
24
|
```Javascript
|