Describe your issue here.
x in one of the [ ])x in each of the [ ])Filling out the following details about bugs will help us solve your issue sooner.
package version:
node version:
OS version(s):
const app = new App({
logLevel: LogLevel.DEBUG,
token: token,
signingSecret: sign_secret,
});
const result = await app.client.views.publish({
token: token,
user_id: userID,
view: view
});
New view updates on user home
TypeError: app.client.views.publish is not a function
NIL
Hey @johnsonyick!
What version of bolt are you running?
hi @stevengill
sorry for my late response.
my bolt version is 1.4.1
馃憢Hello @johnsonyick
Could you try the following example? It should work for you.
Although I'm not sure about what your actual code looks like, one thing I can suggest by checking the given information here is that app.client.views.publish needs to be called inside a listener as below. It doesn't work at the top level of your source code.
// subscribe an event and add a corresponding listener for it
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
});
});
hi @seratch
i was trying by the example before, but it states app.client.views.publish is not a function that's why I asked here.
@johnsonyick views.publish is available in @slack/web-api version 5.3.0 or newer. I believe your app depends on an older version of it. Upgrading the version of the npm module addresses the problem.
@seratch wow, you saved me a day! it's fixed by updating @slack/web-api . thanks very much!