Webform / Slack tutorial (easy)
This tutorial will guide you through building a very simple workflow and introduce you to the basic concepts of working with tray.
It will introduce you to:
- The Form Trigger
- The Slack connector
- The Text Helpers connector
- Using the Tray 'connector snake' to pull data from one connector to another
- A Slack account with admin permissions
- A tray.io account (you can sign up here)
We're going to create a Suggestions Box. We'll build a web form that a user can fill in with their suggestions for how to improve the office. We'll then send those suggestions to a Slack channel to be reviewed.
Let's get started...
Set up the web form
Step 1. Create a new tray workflow. Give it any name you like the sound of.
Step 2. Select the Form Trigger. You can find more information about the Form Trigger here.
Step 3. Give your form a title and a description. Note that we use a leading "#" here because the Form Trigger supports markdown and we want to make this a title.
Step 4. Add a Short Text Input Field to the form to capture the user's email address. Give it a name (this is its ID that we will use to refer to the field), a label (this is the text that will appear on the form), and a description (this description will also appear on the form to clarify what the user should enter into the field).
Step 5. Add a Multiline Text Input Field to the form to capture the user's suggestion.
Step 6. Select Show Advanced Settings.
Then add a call to action and a thank you message to your form.
Step 7. Enable your workflow. We need to enable the workflow so that the form will work properly. Click the ENABLE button in the bottom right corner of the builder.
Step 8. Get the URL for your form. You can find it by clicking on the cog in the top left corner of the workflow editor.
Visit the URL in your browser to make sure that it looks right. Fill in the fields and click the submit button.
Step 9. Check the Debug tab to see the output of your form in the logs. You will see the output of your form as JSON:
Add the Text Helper to compose the message to Slack
Step 10. Next, we're going to create the message to send over slack. Add a Text Helper connector to your workflow. This is now a new "step" in your workflow. We'll use the Text Helper's concatenate function to join up the email and suggestions fields from the form.
Use the Connector Snake to grab email and result from the form
Step 11. Use the connector snake to import the fields from the Form Trigger and add a text string in between them. This is one of the fundamentals of using Tray. Every step has access to all of the output from the steps that came before it - you just have to join up the output of one step with the input of the next.
You can do this first for the Email output field (click on the sequence of tabs to see the process in order):
And then for the Suggestion field:
Configure the Slack Connector
Step 12. Now that we've constructed our message we're going to send it via Slack. Add a Slack connector to your workflow.
Step 13. You need to authenticate the Slack connector so that it can use your Slack account. Select the Slack connector and click Add Authentication.
This will guide you through the authentication process. You only need to grant permissions for (Uncheck all of the other boxes):
- Chat:write:user (Send messages as user);
- Channels:read (Access information about user’s public channels);
- Im:read (Access information about user’s direct messages);
Step 14. Select the channel you wish to send your suggestions to. Use the connector snake to select the output of the Text Helper as our message.
Step 15. Go to the form URL, fill in the form again, and submit it. You should now see a message appear in Slack! If you don't - have a look in the logs and see if you can find what the problem is.