it's my first time developing a Slack application, and I'm trying to communicate the results of a modal submission back to the user in the exact same channel/chat in which they executed the /slash command from (see full code at bottom).
Currently, the client.chat.postEphemeral sends the text message to the chat exclusively between the user and the bot, but I'd like to message to be displayed in the channel that the original slash command was executed from. I'm assuming my issue lies in assigning user to the channel parameter (see below), but I'm not sure how to specify the active channel w/o hardcoding the id.
channel: user,
user: user,
text: `*${wordEntry.word_input.value.toUpperCase()}* was added to Glossary :partying_face:`,
See photo of issue below, as well as what I'd like to accomplish:
Executed /lb-help in #random, which correctly displays message in #random (this is goal)

Executed /lb-add in #random, entering user info to submit

Once submitted, confirmation message is sent to chat between user and bot, not #random

Code
// Handle a view_submission request
app.view("view_1", async ({ ack, body, view, client, logger }) => {
// Acknowledge the view_submission request
await ack();
// Define user id for eventual user notification
const user = body["user"]["id"];
// Gather data from user submitted input text fields
const wordEntry = view["state"]["values"]["input_1"];
const defEntry = view["state"]["values"]["input_2"];
// Query for word the user inputted
const res = await db.query("SELECT * FROM dictionary WHERE word = $1", [
wordEntry.word_input.value.toUpperCase(),
]);
// If submitted word doesn't already exist...
if (res[0] == undefined) {
// Insert word into glossary
await db.query(
"INSERT INTO dictionary (word, definition) VALUES ($1, $2)",
[
wordEntry.word_input.value.toUpperCase(),
defEntry.definition_input.value,
]
);
//Notify user that word was added to glossary
await client.chat.postEphemeral({
channel: user,
user: user,
text: `*${wordEntry.word_input.value.toUpperCase()}* was added to Glossary :partying_face:`,
});
} else {
//Otherwise, notifiy user that word already exists
await client.chat.postEphemeral({
channel: user,
user: user,
text: `*${wordEntry.word_input.value.toUpperCase()}* already exists :shrug:. Try */lb-define* to see its definition`,
});
}
});
Please let me know if this was unclear, or if I could provide any further information - thank you!