As we are currently preparing everything for the PowerShell Conference Asia, we decided to open up our Slack team to the general public. In order to do this we had to set up an automated Slack inviter. My initial search for examples of how to set this up resulted in a lot of old blog post, because of that I went back to the drawing board and took a look at what I thought I needed:
- An online form
- Trigger when form is filled in
- A method of inviting
Because I have an Office 365 account I decided to use a combination of Microsoft Forms and Microsoft Flow for this purpose. Microsoft Forms is similar to many other online forms, but the combination with Microsoft Flow was what won me over. Microsoft Flow allows for setting up automated workflows in Office 365. It can also use webhooks, which happens to be an excellent method of working with Slack.
I then found this post on Stack Overflow, in the Slack API team invitation question, covering an undocumented feature in the Slack API that allows for invitations to be send out by webhooks. With that we filled in the have matched the requirements for setting up automatic invites for Slack.
So first things first, in order to use the Slack API we require a token, for this purpose I requested a Legacy token, which can be done at the following URI:
After clicking create token you will get a string that resembles this:
We will need this to authenticate with Slack once we setup the webhook, because of this it is important you do not share this token with anyone, or store this in a public repository.
The next step is to setup a form in Microsoft Forms, to keep sign up simple we will just request users to enter their email address. They can choose to fill in the rest of their details when they click the registration link that will be send out by Slack. I created the following:
Next up we want to create a sharing link for this Form, make sure you set the sharing option to, Anyone with the link can respond, as the default sharing option is that only people within your Office 365 organization are able to access the Form. This can be done as shown in the following screenshot.
Now that we have this setup it is time to create our Flow. For the purpose of this blog post I created a simple Flow that triggers when a response has been received:
Then we configure the HTTP webhook to trigger Slack to send an invitation email to that email address:
After saving and enabling this flow the automatic invitations will be send out as soon as someone fills out the form. Because we made the the sharing link public to the Microsoft Form you can now use social media to share out and promote your Slack team.
Let me know how this works for you and if you have become curious about the PowerShell Conference Asia or you want to network with some of the attendees and speakers of that conference you can sign up here: