Getting 'exchanged_trigger_id' error with Slack BoltJS when trying to reopen a modal

82 views Asked by At

Good day!

I'm working on a slack app where you open a modal to view a list of goals. Each goal has an edit button which pushes a new view onto the stack. When you submit that view it goes back to the first view and updates that with the new goal information.

When you click on the edit button again I get the 'exchanged_trigger_id' error because I've already used this trigger_id. I have no idea how to get a new trigger ID.

Hoping someone can point me in the right direction.

In the below code I fetch the trigger_id from the params.body. This is always the same for this button.

app.action(StandupActions.OPEN_EDIT_GOAL_MODAL, async (params) => {
    params.ack();

    const triggerId = params.body.trigger_id;
    if (!triggerId) {
        throw new Error("Can't open edit goal modal due to missing trigger id");
    }

     const goalId: number = Number(params.body.actions[0].value);
     if (!goalId) {
         throw new Error(`GoalID to edit not found -> ${goalId}`);
     }

    const goal = standupGoalStateManager.getGoalById(goalId);
    if (goal === null) {
        throw new Error(`Goal to edit not found -> ${goalId}`);
    }

    editGoalModal = EditGoalModal.getInstance(triggerId, goal);
    editGoalModal.push();
});
0

There are 0 answers