You can test out this extension right away!
-
Go to your Cloud Firestore dashboard in the Firebase console.
-
If it doesn't already exist, create the collection you specified during installation:
${param:SLACK_MESSAGE_COLLECTION}
. -
Add a document with a
authToken
field,channel
field and amessage
field with the following content:authToken: 'xoxb-your-token-here', message: { text: 'Hello from Firebase' }, channel: 'general'
-
In a few seconds, you'll see a
response
field appear in the document. The field will update after the extension gets the response from the Slack API. It contain the response from the Slack API. Additionally, a fieldstatus
will also be created with the valuessuccess
orerror
.
Note: You should use the Firebase Admin SDK to add a document since you need to specify Auth tokens in the document:
admin
.firestore()
.collection("${param:SLACK_MESSAGE_COLLECTION}")
.add({
authToken: 'xoxb-your-token-here',
message: {
text: 'Hello from Firebase'
},
channel: 'general'
})
.then(() => console.log("Queued Slack message for delivery!"));
After its installation, this extension monitors all document created in the ${param:SLACK_MESSAGE_COLLECTION}
collection. Slack messages are delivered based on the contents of the document's fields. The top-level fields specify the auth token and channel name. The message
field contains the details of the message to deliver.
The message
field of the document contains the content for the Slack message. This field should generally only be populated by trusted code running in your own servers or Cloud Functions (refer to the "Security rules and sending email" section below).
Available properties for the message
field are specified in the Slack API documentation.
This extension can be used to trigger Slack message delivery directly from client applications. However, you should carefully control client access to the ${param:SLACK_MESSAGE_COLLECTION}
collection to avoid potential abuse (you don't want users able to send arbitrary message using your company's Slack app!).
As a best practice, you can monitor the activity of your installed extension, including checks on its health, usage, and logs.