質問編集履歴
1
「送信した値の部分」をより詳細なコードに修正しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -60,7 +60,7 @@
|
|
60
60
|
|
61
61
|
{
|
62
62
|
|
63
|
-
token: 'XXXXXX
|
63
|
+
token: 'QxsXXXXXX',
|
64
64
|
|
65
65
|
team_id: 'YYYYYY',
|
66
66
|
|
@@ -104,79 +104,101 @@
|
|
104
104
|
|
105
105
|
```javascript
|
106
106
|
|
107
|
+
const AWS = require("aws-sdk");
|
108
|
+
|
109
|
+
const docClient = new AWS.DynamoDB.DocumentClient();
|
110
|
+
|
111
|
+
const { App } = require('@slack/bolt');
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
exports.handler = async (event, context, callback) => {
|
116
|
+
|
117
|
+
const obj = JSON.parse(JSON.stringify(event));
|
118
|
+
|
119
|
+
const posted_url = obj.event.links[0].url;
|
120
|
+
|
121
|
+
|
122
|
+
|
107
|
-
const postMessage = async (data) => {
|
123
|
+
const postMessage = async (data) => {
|
108
|
-
|
124
|
+
|
109
|
-
const app = new App({
|
125
|
+
const app = new App({
|
110
|
-
|
126
|
+
|
111
|
-
token: USER_OAUTH_TOKEN,
|
127
|
+
token: process.env.USER_OAUTH_TOKEN,
|
112
|
-
|
128
|
+
|
113
|
-
signingSecret: SIGNING_SECRET
|
129
|
+
signingSecret: process.env.SIGNING_SECRET
|
114
|
-
|
130
|
+
|
115
|
-
});
|
131
|
+
});
|
116
|
-
|
132
|
+
|
117
|
-
try {
|
133
|
+
try {
|
118
|
-
|
134
|
+
|
119
|
-
const result = app.client.chat.unfurl(data);
|
135
|
+
const result = app.client.chat.unfurl(data);
|
120
|
-
|
136
|
+
|
121
|
-
return await result;
|
137
|
+
return await result;
|
122
|
-
|
123
|
-
}
|
124
|
-
|
125
|
-
catch (error) {
|
126
|
-
|
127
|
-
console.error(error);
|
128
|
-
|
129
|
-
}
|
130
|
-
|
131
|
-
};
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
const unfurling = {
|
136
|
-
|
137
|
-
"token": USER_OAUTH_TOKEN,
|
138
|
-
|
139
|
-
"channel": 上記channel,
|
140
|
-
|
141
|
-
"ts": 上記event_ts,
|
142
|
-
|
143
|
-
"source": "composer",
|
144
|
-
|
145
|
-
"unfurl_id": 上記unfurl_id,
|
146
|
-
|
147
|
-
"unfurls": {
|
148
|
-
|
149
|
-
posted_url: {
|
150
|
-
|
151
|
-
"blocks": [
|
152
|
-
|
153
|
-
{
|
154
|
-
|
155
|
-
"type": "section",
|
156
|
-
|
157
|
-
"text": {
|
158
|
-
|
159
|
-
"type": "mrkdwn",
|
160
|
-
|
161
|
-
"text": "AAAAAA"
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
}
|
166
|
-
|
167
|
-
]
|
168
138
|
|
169
139
|
}
|
170
140
|
|
141
|
+
catch (error) {
|
142
|
+
|
143
|
+
console.error(error);
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
};
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
const setResnponse = async(userName) => {
|
152
|
+
|
153
|
+
const text = userName + "AAAA";
|
154
|
+
|
155
|
+
const unfurling = {
|
156
|
+
|
157
|
+
"token": process.env.USER_OAUTH_TOKEN,
|
158
|
+
|
159
|
+
"channel": obj.event.channel,
|
160
|
+
|
161
|
+
"ts": obj.event.message_ts,
|
162
|
+
|
163
|
+
"source": "composer",
|
164
|
+
|
165
|
+
"unfurl_id": obj.event.unfurl_id,
|
166
|
+
|
167
|
+
"unfurls": {
|
168
|
+
|
169
|
+
posted_url: {
|
170
|
+
|
171
|
+
"blocks": [
|
172
|
+
|
173
|
+
{
|
174
|
+
|
175
|
+
"type": "section",
|
176
|
+
|
177
|
+
"text": {
|
178
|
+
|
179
|
+
"type": "mrkdwn",
|
180
|
+
|
181
|
+
"text": text
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
]
|
186
|
+
|
187
|
+
}
|
188
|
+
|
171
|
-
},
|
189
|
+
},
|
172
|
-
|
190
|
+
|
173
|
-
};
|
191
|
+
};
|
192
|
+
|
193
|
+
|
194
|
+
|
174
|
-
|
195
|
+
const data = setResnponse("BBB")
|
175
|
-
|
176
|
-
|
196
|
+
|
177
|
-
const res = await postMessage(
|
197
|
+
const res = await postMessage(data);
|
178
|
-
|
198
|
+
|
179
|
-
return res;
|
199
|
+
return res;
|
200
|
+
|
201
|
+
};
|
180
202
|
|
181
203
|
|
182
204
|
|