Reputation: 1087
Want to send Slack notification to a channel the user registers in Firebase Cloud Function. Actually, I want to send a notification when the field contents change in Firestore, but it occurs API Error.
Error: An API error occurred: not_in_channel
It might be not Cloud Function error, should be Slack API error.
Oauth Scope:
firestore
.collection("users")
.doc(id)
.get()
.then(snapshot => {
try {
const token = snapshot.data().token;
if (token) {
const result = new WebClient(token).chat.postMessage({
channel: snapshot.data().channel,
text: "Posted!"
});
console.log(`Successfully send message ${result.ts}`);
}
} catch (error) {
console.log(`Not authenticated to slack ${error}`);
}
});
});
Upvotes: 1
Views: 1543