You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/blink/src/cli/setup-slack-app.ts
+29-10Lines changed: 29 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -195,6 +195,7 @@ export async function setupSlackApp(
195
195
letbotToken="";
196
196
letdmReceived=false;
197
197
letdmChannel="";
198
+
letdmTimestamp="";
198
199
letsignatureFailureDetected=false;
199
200
letlastFailedChannel: string|undefined;
200
201
@@ -261,6 +262,7 @@ export async function setupSlackApp(
261
262
){
262
263
dmReceived=true;
263
264
dmChannel=payload.event.channel;
265
+
dmTimestamp=payload.event.ts;
264
266
}
265
267
266
268
returnnewResponse("OK");
@@ -350,15 +352,27 @@ export async function setupSlackApp(
350
352
constslackAppUrl=createSlackApp(manifest);
351
353
352
354
log.info(
353
-
`Opening browser to create Slack app...\n\n${chalk.gray(slackAppUrl)}`
355
+
`Please visit this URL to create your Slack app and return here after finishing:\n\n${chalk.gray(slackAppUrl)}\n`
354
356
);
355
357
356
-
try{
357
-
awaitopen(slackAppUrl);
358
-
}catch(error){
359
-
log.warn(
360
-
`Could not automatically open browser. Please visit the URL manually.`
361
-
);
358
+
constshouldOpen=awaitconfirm({
359
+
message: "Open this URL in your browser automatically?",
360
+
initialValue: true,
361
+
});
362
+
363
+
if(isCancel(shouldOpen)){
364
+
log.warn("Skipping Slack app setup");
365
+
return;
366
+
}
367
+
368
+
if(shouldOpen){
369
+
try{
370
+
awaitopen(slackAppUrl);
371
+
}catch(error){
372
+
log.warn(
373
+
`Could not automatically open browser. Please visit the URL manually.`
374
+
);
375
+
}
362
376
}
363
377
364
378
// Ask for app ID
@@ -379,7 +393,7 @@ export async function setupSlackApp(
379
393
380
394
// Ask for signing secret with direct link
381
395
signingSecret=(awaitpassword({
382
-
message: `Paste your Signing Secret from https://api.slack.com/apps/${appId}/general:`,
396
+
message: `Paste your Signing Secret from the same page:`,
383
397
validate: (value)=>{
384
398
if(!value||value.trim().length===0){
385
399
return"Signing secret is required";
@@ -396,7 +410,7 @@ export async function setupSlackApp(
396
410
lettokenValid=false;
397
411
while(!tokenValid){
398
412
botToken=(awaitpassword({
399
-
message: `Paste your Bot Token from https://api.slack.com/apps/${appId}/install-on-team:`,
413
+
message: `Install your app and paste your Bot Token from ${chalk.cyan(`https://api.slack.com/apps/${appId}/install-on-team`)}:`,
400
414
validate: (value)=>{
401
415
if(!value||value.trim().length===0){
402
416
return"Bot token is required";
@@ -479,7 +493,7 @@ export async function setupSlackApp(
479
493
480
494
// Prompt user to re-enter the signing secret
481
495
constnewSigningSecret=awaitpassword({
482
-
message: `The signing secret appears to be incorrect. Please paste the correct Signing Secret from https://api.slack.com/apps/${appId}/general:`,
496
+
message: `The signing secret appears to be incorrect. Please paste the correct Signing Secret from ${chalk.cyan(`https://api.slack.com/apps/${appId}/general`)}:`,
483
497
validate: (value)=>{
484
498
if(!value||value.trim().length===0){
485
499
return"Signing secret is required";
@@ -517,6 +531,7 @@ export async function setupSlackApp(
517
531
},
518
532
body: JSON.stringify({
519
533
channel: dmChannel,
534
+
thread_ts: dmTimestamp,
520
535
text: `Congrats, your app is now installed and ready to use! Run \`${runDevCommand}\` to use your agent.`,
521
536
}),
522
537
});
@@ -537,4 +552,8 @@ export default async function setupSlackAppCommand(
537
552
intro("Setting up Slack app");
538
553
539
554
awaitsetupSlackApp(directory);
555
+
556
+
// the devhook takes a while to clean up, so we exit the process
0 commit comments