question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Slack bolt slack_webapi_platform_error `trigger_id` expired

See original GitHub issue

Description

Hello folks, i am using slack@bolt 2.0.1 with “express”: “^4.17.1” in a slack app which i built 1 year ago.

In my local slack bot i am having this issue with instantiating a command,

app.command(global.config.slack.commandConfig.createTicket, createTicketCommand(app));

export const createTicketCommand = (app: App): Middleware<SlackCommandMiddlewareArgs> => async ({
  ack,
  body,
  context,
}): Promise<void> => {
  // Acknowledge the command request
  await ack();

 app.client.views.open({
      token: context.botToken,
      trigger_id: body.trigger_id,
      view: {
        type: 'modal',
        title: {
          type: 'plain_text',
          text: 'Workplace check-in',
        },
        close: {
          type: 'plain_text',
          text: 'Cancel',
        },
        blocks: [
          {
            type: 'section',
            text: {
              type: 'plain_text',
              text: ':man-biking: Now loading...',
            },
          },
        ],
      },
    });

 
  } catch (error) {
   console.log(error);
  }
};

And i get this error, it looks to me there is something wrong with trigger_id.

{“level”:1,“time”:“2021-04-23T07:44:39.725Z”,“msg”:{“code”:“slack_webapi_platform_error”,“data”:{“ok”:false,“error”:“invalid_arguments”,“response_metadata”:{“messages”:[“[ERROR] trigger_id expired [json-pointer:/trigger_id]”],“scopes”:[“channels:history”,“chat:write”,“commands”,“files:read”,“groups:history”,“im:history”,“incoming-webhook”,“mpim:history”,“users:read”]}},“name”:“Error”,“message”:“An API error occurred: invalid_arguments”,“stack”:“Error: An API error occurred: invalid_arguments\n at Object.platformErrorFromResult (/usr/src/app/node_modules/@slack/web-api/src/errors.ts:94:5)\n at WebClient.apiCall (/usr/src/app/node_modules/@slack/web-api/src/WebClient.ts:188:13)\n at processTicksAndRejections (internal/process/task_queues.js:93:5)”}}

Any help, any suggestion what it might be?

Does reinstalling the app and refreshing the new slack bot token and signin secrets would help?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
seratchcommented, Apr 26, 2021

bolt-js v3 does not have any breaking changes but if you have some reason to keep using v2, you can have the following global middleware to print received requests.

// you can remove this if statement if you want to always enable this
if (process.env.SLACK_REQUEST_LOG_ENABLED === "1") {
  app.use(async (args) => {
    const copiedArgs = JSON.parse(JSON.stringify(args));
    copiedArgs.context.botToken = 'xoxb-***';
    if (copiedArgs.context.userToken) {
      copiedArgs.context.userToken = 'xoxp-***';
    }
    copiedArgs.client = {};
    copiedArgs.logger = {};
    args.logger.debug(
      "Dumping request data for debugging...\n\n" +
      JSON.stringify(copiedArgs, null, 2) +
      "\n"
    );
    const result = await args.next();
    args.logger.debug("next() call completed");
    return result;
  });
}
0reactions
seratchcommented, Jun 19, 2021

👋 @erkand-imeri Let us know if you have anything further to ask/discuss here. I will close this issue after waiting for your response for a few days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Slack bolt: trigger_id expired when trying to trigger app.client ...
Note that I am getting this error when I use app.client.views.open . I am making a guess that the app is taking more...
Read more >
trigger_id expired #1131 - slackapi/node-slack-sdk - GitHub
Hey @xiuleiyy,. trigger_id expires after 3 seconds. That means you need to open the modal within that timeframe. In general, if a user...
Read more >
Error troubleshooting - Slack API
Slack CLI errors reference. ... The new Slack platform and the features described below are in beta and ... The provided trigger type...
Read more >
Handling user interaction in your Slack apps
Triggers expire in three seconds. Use them before you lose them. You'll receive a trigger_expired error when using a method with an expired...
Read more >
views.open method - Slack API
Open a modal with a user by exchanging a trigger_id received from another interaction. See the modals documentation to learn how to obtain...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found