Skip to main content

Lab 0 - Automating Retool

Goal

Enterprises that adopt Retool look to automate as much as they can to create consistent onboarding / offboarding experiences. The following lab will focus on using the Retool API and Workflows to demonstrate one automation option.

The following steps require having Administrator permissions. If you do not have these please work with your admin contact.

Instructor creates Retool API Token

  • Go to Settings > Retool API > Create new.
  • Create a token with the name onboarding_class_token and scope of Users Read and Users Write.
  • Select Create token.
Create API Token
  • This will display the token.
View API Token
  • Copy the token and move to the next section.

Instructor creates a configuration variable

  • Go to Settings > Configuration Variables.
  • Specify the name onboarding_class_config_var, a description, enable Mark variable as secret, and for Values specify a production value equal to the previous access token.
  • Select Save Changes.
Create Configuration Variable
  • Configuration variables are then displayed as shown:
View Configuration Variable

Instructor creates a Resource using configuration variable

  • Go to Resource > REST API
  • Provide a name of Retool_API
  • Update the URL to use the following value:
  • Update the authentication to use a token and specify the value using the configuration variable.
    • {{ environment.variables.retool_api_list_users_token }}
List Users Resource

Instructor adds Resource to Permission Group

  • Go to Settings > Groups
  • Edit the Student Permission Group and add the newly created Resource with Edit access.
Permission Group

Create User Workflow

  • Go to Workflows > Folder > Create.
  • Name the workflow, user-mgmt-workflow.
  • Delete the code block.
  • Add a Resource Query block and specify the Resource created previously.
  • Name the resource listUsers and specify users.
List Users
  • To get a specific user we create another block.
  • Name the resource query block, getUser.
  • Update the URI portion to identify the user id. {{ listUsers.data.data[0].id}}
Get User
  • To create a user, we create another block.
  • Name the resource query block, createUser.
  • Change the Method to POST
  • Add users to the URL
  • Specify Headers Content-type = application/json and Accept = application/json
  • Specify RAW for the body and copy and paste the following:
{
"email": "<yourfirstname>@example.com",
"first_name": "<yourfirstname>",
"last_name": "Simple",
"active": true,
"metadata": {},
"user_type": "default"
}
Create User

Test User Workflow

  • Select Run to execute the workflow.
  • This will display the History panel and identify the tasks that completed.
  • Select listUsers, getUser, and createUser to view the output of each of these steps.
Workflow History