As the title mentions, my bot isn't working when I install it into another workspace. I have oAuthv2 set up using this redirect url. When testing the bot in the workspace where it was created, everything works fine. However, when I use the slash command, I get a 'channel_not_found' error in the new workspace where the app was installed. This is the error log I'm getting. As far as code, I'm using the slack bolt api for javascript. Here is the snippet that breaks the bot:
app.command('/requestoff', async ({ body, ack, say }) => {
await ack(console.log(body));
// current date format
const d = new Date().toLocaleDateString().split('/');
user_name = body.user_name;
if (body.channel_name == 'directmessage') {
console.log(body.channel_name);
await say({
blocks: [
{
type: 'header',
text: {
type: 'plain_text',
text: 'Please Select Your Request',
emoji: true,
},
},
{
type: 'input',
element: {
type: 'datepicker',
initial_date: `${d[2]}-${d[0]}-${d[1]}`,
placeholder: {
type: 'plain_text',
text: 'Select a date',
emoji: true,
},
action_id: 'datepicker-action',
},
label: {
type: 'plain_text',
text: 'Shift Date',
emoji: true,
},
},
{
type: 'input',
element: {
type: 'timepicker',
initial_time: '00:00',
placeholder: {
type: 'plain_text',
text: 'Select time',
emoji: true,
},
action_id: 'time-start-action',
},
label: {
type: 'plain_text',
text: 'Start Shift Time',
emoji: true,
},
},
{
type: 'input',
element: {
type: 'timepicker',
initial_time: '00:00',
placeholder: {
type: 'plain_text',
text: 'Select time',
emoji: true,
},
action_id: 'time-end-action',
},
label: {
type: 'plain_text',
text: 'End Shift Time',
emoji: true,
},
},
{
type: 'actions',
elements: [
{
type: 'button',
text: {
type: 'plain_text',
emoji: true,
text: 'Confirm',
},
style: 'primary',
action_id: 'confirm_click',
},
{
type: 'button',
text: {
type: 'plain_text',
emoji: true,
text: 'Cancel',
},
style: 'danger',
action_id: 'cancel_click',
},
],
},
],
text: 'Please select your request for time off.',
});
} else {
// post a message only visible to user who called the command
app.client.chat.postEphemeral({
channel: body.channel_id,
user: body.user_id,
text: '*/requestoff* can only be called in your direct message with Availy',
});
}
});
It is able to see that the channel name is 'directmessage', but when it goes to post the message the error occurs. (This is my first slack bot, so I may be doing things that aren't good practice)
Any help would be appreciated!