Form Trigger

Build a GUI form and run your script when the form data is submitted.

Setup

Title and Description

You can add a title and description to your form to create context for your users.

Once your trigger is activated, you can press the 'View Form' button to be taken to the live, public endpoint for your form. This form can be shared with others you want to use your form.

Adding Form Inputs

In order to add an input, press + Add a Form Element. You can add as many form elements as you want.

There are four input types you can currently choose from:

1) Text Input

Sample Text Input

Title - There are a few different parts of the element to notice. First, you can create a title for the input (in the example image we are asking 'What is your name?'.

Required - You can set required to On/Off - if on, a user is required to enter an answer before they can submit the form.

Placeholder - This is just placeholder text you can enter for the text input.

2) Text Area

The Text Area element behaves identically to the Text Input element. The key difference is it provides space for a longer form answer.

3) Selector

The Selector element can be used to give users of the form a set of choices to choose from. In order to add options to your selector, press the + Add an Option button. You can add as many options as you want.

Setting up a Selector
Result on the Form

4) Radio Buttons

The Radio element behaves exactly like the Selector element above. The form will render the options as radio buttons.

Radio button example

Advanced Inputs

CSS - You can customize the CSS of your form for your own look and feel.

👁🗨 View Form

In order to view your live form, make sure your trigger is active and then press the View Form button.

Trigger is On, press View Form

Advanced Settings

🔗 Endpoints

When setting up the Form Trigger, you can create as many named endpoints as you like. If you don't provide a name for your endpoint, the trigger will match the root URL. All endpoint names must be unique throughout your script to prevent ambiguity.

To access your endpoints, use the program ID as a subdomain of wayscript.io. For example, in the image above, you can trigger your script by hitting either https://16233.wayscript.io/ or https://16233.wayscript.io/custom_endpoint.

Remember to activate your trigger before using the endpoint!

🔐 Password-Protect your Form

If you would like your form to require a login to view, enable the "Password Protection" toggle.

A button to "Manage Login Credentials" will appear.

Clicking this button will take you to "Login Credentials" section of the "Script Setup" tab, where you can manage the usernames and passwords that will allow people to log in to your endpoints.

When you click "Add a credential," a new login will be automatically generated for you, including a username and randomly-generated password. You can choose to use these values, or edit them as you see fit.

When a user goes to access your form for the first time, they will now be prompted to login.

Form Login Prompt

Basic Authentication

If you password-protect your endpoints, you can use the credentials added above to access your endpoints by including an Authorization: Basic header in your request.

This header should follow the standard for HTTP basic access authentication. For example, suppose your Username is "captain@wayscript.com" and your Password is "letmein," you would create the Authorization header by:

  1. Joining the Username and Password into a single string, separated by a semicolon: captain@wayscript.com:letmein

  2. Encoding that string in Base64: Y2FwdGFpbkB3YXlzY3JpcHQuY29tOmxldG1laW4=

  3. Passing that encoded string to your custom endpoint by including the Authorization: Basic Y2FwdGFpbkB3YXlzY3JpcHQuY29tOmxldG1laW4= header in your request.

These headers are also displayed for you under each password in the "Login Credentials" section of the "Script Setup" tab.

Authenticating Using Your API Key

If your endpoint is not public, you can also use your WayScript API Key to access your endpoints api call by including an Authorization: Bearer header in your request.

For example, if your WayScript API Key is fhAEdGT9EbFDh_migcrukZ1Vb28rLFKqt9AxOiq9bdQ, you would include the Authorization: Bearer fhAEdGT9EbFDh_migcrukZ1Vb28rLFKqt9AxOiq9bdQ header in your request.

📤 Output

The Form Trigger will output a Struct of the responses to your form.

Form = {
input_1 = 'Answer One',
input_2 = 'Answer Two',
...
}

🎓 Tutorial