Tray Platform / Getting Started / Intro Tutorials / Webform / Slack (easy)
Webform / Slack (easy)
This tutorial will guide you through building a simple workflow and introduce you to the basic concepts of working with the Tray platform.
It will introduce you to:
The Form Trigger
The Slack connector
Using the 'connector snake' to pull the data from one connector to another
A Slack account
A tray.io account (you can sign up here)
We're going to create a Suggestions Box where the user can provide their suggestions for how to improve the office. We'll then send those suggestions to a Slack channel for review.
The steps involved in creating the workflow are:
Set up the web form using the Form Trigger
Concatenate the text using the Text Helpers connector
Use the connector snake to grab the email and the suggestions from the form
Configure the Slack connector to send the concatenated message
Let's get started...
Set up the web form
To set up the webform follow the below steps:
Step 1. Create a new Tray.io workflow using the Create new workflow button. Give it any name you like the sound of.
Step 2. Select the Form Trigger from the provided list of triggers. 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 "#" in the Description field value because the Form Trigger supports markdown and we want to make this a title.
Step 4. Click the Add to Input Fields button to add input fields on the form.
Each input field on the form has the following five attributes:
Field Types: It defines the type of content that appears in the specific field.
Name: It is a unique ID of the field.
Label: It is a text that appears on the form.
Description: It is a message that describes what information to provide into the field.
Required: If this option is checked it indicates the form field is mandatory.
For the suggestion form we are adding two fields email and suggestions with the following values for their attributes:
Field Types | Name | Label | Description | Required | |----------------|------------|------------|---------------------------------|----------| | Short Text | email | Email | Please enter your email address | Yes | | Multiline Text | suggestion | Suggestion | Please enter your suggestion | Yes | | | | | | |
Step 5. Click the Show advanced properties button.
Add a Call To Action and a Thanks Message as shown in the image below:
Step 6. Click the Enable button on the bottom right corner. This enables the workflow.
Step 7. Get the URL for your form. Using this URL you can access your webform. To get the URL click the horizontal hamburger icon on the top left corner of the screen. Select Workflow settings.
Now, copy the workflow public URL available on the Workflow settings window.
Step 8. Use the copied URL to view your form on the browser. Now, since you can view your form let’s check the functioning.
Fill in the fields on the form and click the Submit suggestion button.
Step 9. Click on the Debug tab on the Tray platform to check the debug logs of your form. You can see the output of your form as JSON.
Concatenate the text using the Text Helpers connector
Once you are done setting up the web form, let’s add the Text Helpers connector to the workflow. Using the Text Helpers connector we are going to create a message for Slack by concatenating the values from email and suggestion fields. To do so:
Step 10. Add the Text Helpers connector to your workflow. Select the Concatenate operation from the drop-down.
Use the connector snake to grab the email and results from the form
This is one of the fundamentals of using the Tray platform. Every step has access to the output of all the previous steps. In this way, any data that is output from a previous step can be used as the input in any following steps.
You can learn more about this in our page on working with data and jsonpaths
Step 11. Use the connector snake to import the fields from the Form Trigger and add a text string between them. To do so follow the sub-steps mentioned below:
Email output field
Click the Add to Values button, to add a field on the Text Helpers property panel.
Connect the first field from the Text Helpers property panel to the form trigger. To do so just drag the snake connector from one point to another and then release.
3. Select the email output field from the drop-down.
4. Now, add another field with a concatenation text string as ‘has suggested:’ to the Text Helpers property panel.
Add one more field and connect this field from the Text Helpers property panel to the form trigger.
2. Select the suggestion output field from the drop-down.
The data paths are auto-entered in the respective fields.
Configure the Slack Connector
We are done constructing our message. The next step is to send the message via Slack. To do so configure the slack connector by following the steps below:
Step 12. Add a Slack Connector to your workflow.
Step 13. Select the Slack Connector and click the Add new authentication link from the properties panel. You need to authenticate the slack connector so that it can use your Slack account.
The link guides you through the authentication process. Follow the guidelines to complete the authentication. When asked for the service permissions uncheck all the permission 'scopes' except the following:
Chat:write:bot (Send messages as tray.io)
Channels:read (Access information about user’s public channels)
Im:read (Access information about user’s direct messages)
Upon successful creation of the Authentication, a confirmation message is received at the bottom left of the screen saying ‘Authentication for Tray-Slack Workflow Authentication successfully created’
Step 14. Select the channel you wish to send your suggestions to.
Use the connector snake to select the output of the Text Helpers as your message.
We are done with the complete setup, let’s check if the workflow functions properly.
Step 15. Go to the webform URL, fill in the form again, and submit it.
If you see your message appear in Slack it means the workflow is working successfully! If you don't, then click on the 'Debug' tab to inspect your logs and see if you can find what the problem is.