I have created a slack bot using Bolt, and am trying to create a home page for it. I have subscribed to the app_home_opened
event and am publishing the view and getting a successful response, however the home page just spins in slack for a few seconds before saying "This is still a work in progress". I have another slack app which works fine and I can't figure out what the difference between the two apps could be.
Here's my code:
(async () => {
// Start your app
await app.start(process.env.PORT || 3020);
app.event('app_home_opened', async ({ event, context }) => {
const yourView = {
"type": "home",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "This is a mrkdwn section block :ghost: *this is bold*, and ~this is crossed out~, and <https://google.com|this is a link>"
}
}
]
};
const result = await app.client.views.publish({
token: context.botToken,
user_id: event.user,
view: yourView
});
console.log(result);
});
console.log('⚡️ Bolt app is running!');
})();
Here's my app logs:
[DEBUG] ack() begin
[DEBUG] ack() response sent
[DEBUG] web-api:WebClient:0 apiCall('views.publish') start
[DEBUG] web-api:WebClient:0 will perform http request
[DEBUG] web-api:WebClient:0 http response received
{
ok: true,
view: {
id: '***',
team_id: '***',
app_id: '***',
app_installed_team_id: '***',
bot_id: '***',
type: 'home',
blocks: [ [Object] ],
state: { values: {} },
hash: '1631738063.S4t8Cj2H',
private_metadata: '',
callback_id: '',
root_view_id: '***',
external_id: '',
title: { type: 'plain_text', text: 'View Title', emoji: true },
close: null,
submit: null,
previous_view_id: null,
clear_on_close: false,
notify_on_close: false
},
response_metadata: {
scopes: [
'reactions:read',
'chat:write',
'channels:history',
'commands',
'groups:history',
'users:read',
'channels:read',
'groups:read',
'im:read',
'mpim:read',
'users:read.email'
]
}
}
The log message looks successful to me. If I change the blocks to be invalid syntax for example, I see a real error. I can't figure out why I would get a successful response, but my app home won't load. I've tried adding all the scopes to my bot that it lists in the response_metadata
, but that does nothing.
Any ideas other things that could be going wrong?
Like @sandra suggested, this was in fact due to using the wrong token. I was using an token from a different app. Everything was working, I guess it was just getting published to the wrong place.