This topic was automatically generated from Slack. You can find the original thread here.
Hi… I’ve been struggling to figure out what the issue is with the following code. I’m trying to debug an action by putting into a NodeJS Workflow step.
Nodejs workflow action
import pkg from '@slack/bolt';
// To use previous step data, pass the `steps` object to the run() function
export default {
'name': 'Test Zoho Create Lead Slack Bolt Form Action',
'description': 'Pipedream action for generating a Slack form for creation Zoho Leads',
'type': 'action',
'key': 'uniquesequence001',
'version': '0.0.1',
async run({ steps, $ }) {
const leadMessageCallback = async ({ message, say }) => {
try {
// say() sends a message to the channel where the event was triggered
console.log("processing message");
await say(`Hey there <@${message.user}>!`);
} catch (error) {
console.error(error);
}
};
const register = (app) => {
app.message('hello', leadMessageCallback);
};
// Return data to use it in future steps
const { App, ExpressReceiver } = pkg;
// Format for generating a receiver event
function generateReceiverEvent(payload) {
return {
body: payload,
ack: async (response) => {
return {
statusCode: 200,
body: response ?? ""
};
}
};
}
var app;
var appConfig = {
token: process.env.TEST_SLACK_BOT_TOKEN,
clientId: process.env.TEST_SLACK_CLIENT_ID,
signingSecret: process.env.TEST_SLACK_SIGNING_SECRET,
appToken: process.env.TEST_SLACK_APP_TOKEN
};
if (process.env['USE_SERVER'] == 'true') {
// Web socket mode
// add socketMode true and appToken for websockets
appConfig = {
...appConfig, socketMode: true,
appToken: process.env.TEST_SLACK_APP_TOKEN
};
app = new App(appConfig);
} else {
// Slack Event URL mode
// add expressReceiver
// Use Express Receiver
const expressReceiver = new ExpressReceiver({
signingSecret: process.env.TEST_SLACK_SIGNING_SECRET,
processBeforeResponse: true
});
appConfig = { ...appConfig, receiver: expressReceiver };
app = new App(appConfig);
}
// Register listener
register(app);
// Build payload from Event that triggered invocation
const payload = steps.trigger.event.body;
// Respond if Slack needs to verify the URL
// Comment out once URL is verified to not require import util.
/** if (util.isUrlVerificationRequest(payload)) {
return {
statusCode: 200,
body: payload?.challenge
};
}**/
// Detect if this is running as a Pipedream process, or as a local desktop process/using sockets
if (process.env['USE_SERVER'] == 'true') {
(async () => {
// Run as a listner
await app.start(process.env.PORT || 3000)
console.log('App is running; listening for events from Slack / the web')
})()
} else {
// Run as a single FaaS execution
const slackEvent = generateReceiverEvent(payload);
await app.processEvent(slackEvent);
console.log("completed processing event..\n");
return {
statusCode: 200,
body: ""
}
}
}
}
The error is
Error
Apps used in a single workspace can be initialized with a token. Apps used in many workspaces should be initialized with oauth installer options or authorize. Since you have not provided a token or authorize, you might be missing one or more required oauth installer options. See https://slack.dev/bolt-js/concepts#authenticating-oauth for these required fields.
at App.initAuthorizeIfNoTokenIsGiven (/tmp/__pdg__/dist/code/aa3a4149a3add1f4e5903633616a8768c9233a4576e59a1fa84108c556066102/node_modules/.pnpm/@slack+bolt@3.13.0/node_modules/@slack/bolt/dist/App.js:682:19)
at App.initAuthorizeInConstructor (/tmp/__pdg__/dist/code/aa3a4149a3add1f4e5903633616a8768c9233a4576e59a1fa84108c556066102/node_modules/.pnpm/@slack+bolt@3.13.0/node_modules/@slack/bolt/dist/App.js:697:43)
at [App.App](http://App.App) (/tmp/__pdg__/dist/code/aa3a4149a3add1f4e5903633616a8768c9233a4576e59a1fa84108c556066102/node_modules/.pnpm/@slack+bolt@3.13.0/node_modules/@slack/bolt/dist/App.js:159:35)
at Object.run (file:///tmp/__pdg__/dist/code/aa3a4149a3add1f4e5903633616a8768c9233a4576e59a1fa84108c556066102/component.mjs:73:19)
at global.executeComponent (/var/task/launch_worker.js:139:53)
at MessagePort.messageHandler (/var/task/launch_worker.js:598:28)
But when I modify the code and remove the ‘key’ in the props, it works without error.
I also tried to publish this from pd publish, which is does so without error, but when I insert from myactions, I get the oAuth error when running.
Is there something unique to a key props that is conflicting?
'name': 'Test Zoho Create Lead Slack Bolt Form Action',
'description': 'Pipedream action for generating a Slack form for creation Zoho Leads',
'type': 'action',
'version': '0.0.1',
Thanks for your help