### Cloning Retool App Exchange Repository - Shell Source: https://github.com/tryretool/retool-app-exchange/blob/main/snowflake-resource-optimization/setup-guides/set-up-retool-app.md This command clones the `retool-app-exchange` GitHub repository to your local machine. It is a prerequisite for obtaining the `Snowflake-Resource-Optimization-Setup-Configuration.json` file, which is needed to import the application into Retool. The command requires Git to be installed and configured on your system. ```Shell git clone https://github.com/tryretool/retool-app-exchange.git ``` -------------------------------- ### Creating Review_Cycles Table in Snowflake (SQL) Source: https://github.com/tryretool/retool-app-exchange/blob/main/snowflake-uar-reviews/setup-guides/set-up-snowflake.md This SQL snippet creates the `REVIEW_CYCLES` table in Snowflake. This table defines the different review cycles, storing their unique ID, name, start and end dates, and a reference to the previous review cycle. The ID is automatically generated by a sequence. ```SQL create or replace TABLE ..REVIEW_CYCLES ( ID NUMBER(38,0) NOT NULL DEFAULT ..REVIEW_CYCLES_SEQ.NEXTVAL, NAME VARCHAR(16777216), START_DATE DATE, END_DATE DATE, PREVIOUS_CYCLE_ID NUMBER(38,0) ); ``` -------------------------------- ### Creating Employees Table in Snowflake (SQL) Source: https://github.com/tryretool/retool-app-exchange/blob/main/snowflake-uar-reviews/setup-guides/set-up-snowflake.md This SQL snippet creates the `EMPLOYEES` table in Snowflake. This table stores employee details relevant to the access review process, including their ID, email, name, and the email of their designated reviewer. ```SQL create or replace TABLE ..EMPLOYEES ( EMPLOYEE_ID NUMBER(38,0), EMAIL VARCHAR(16777216), NAME VARCHAR(16777216), REVIEWER_EMAIL VARCHAR(16777216) ); ``` -------------------------------- ### Cloning Retool App Exchange GitHub Repository - Shell Source: https://github.com/tryretool/retool-app-exchange/blob/main/snowflake-uar-reviews/setup-guides/set-up-retool-app.md This command clones the `retool-app-exchange` GitHub repository to your local machine, providing access to the application code files, including the Retool app JSONs. ```Shell git clone https://github.com/tryretool/retool-app-exchange.git ``` -------------------------------- ### Creating System_Roles Table in Snowflake (SQL) Source: https://github.com/tryretool/retool-app-exchange/blob/main/snowflake-uar-reviews/setup-guides/set-up-snowflake.md This SQL snippet creates the `SYSTEM_ROLES` table in Snowflake. This table is used to store a list of system roles, each identified by a unique ID and a name, which are referenced during the access review process. The ID is automatically generated by a sequence. ```SQL create or replace TABLE ..SYSTEM_ROLES ( ID NUMBER(38,0) NOT NULL DEFAULT ..SYSTEM_ROLES_SEQ.NEXTVAL, NAME VARCHAR(16777216) ); ``` -------------------------------- ### Creating Access_Reviews Table in Snowflake (SQL) Source: https://github.com/tryretool/retool-app-exchange/blob/main/snowflake-uar-reviews/setup-guides/set-up-snowflake.md This SQL snippet creates the `ACCESS_REVIEWS` table in Snowflake. This table stores information about individual access review decisions, including status, employee details, review cycle, system role, and timestamps for updates and submissions. It includes a default ID generated by a sequence. ```SQL create or replace TABLE ..ACCESS_REVIEWS ( ID NUMBER(38,0) NOT NULL DEFAULT ..ACCESS_REVIEWS_SEQ.NEXTVAL, STATUS VARCHAR(16777216), EMPLOYEE_EMAIL VARCHAR(16777216), REVIEW_CYCLE_ID NUMBER(38,0), SYSTEMROLE_ID VARCHAR(16777216), INITIALDECISIONREASON VARCHAR(16777216), UPDATED_AT TIMESTAMP_NTZ(9), SUBMITTED_AT TIMESTAMP_NTZ(9), ACTION VARCHAR(16777216), REASON VARCHAR(16777216), CLOSED_BY_EMAIL VARCHAR(16777216), CLOSED_AT TIMESTAMP_NTZ(9) ); ``` -------------------------------- ### Cloning the Retool App Exchange GitHub Repository (Shell) Source: https://github.com/tryretool/retool-app-exchange/blob/main/incident-central/setup-guides/set-up-retool-apps.md This shell command initiates the cloning process for the `retool-app-exchange` GitHub repository. The repository contains all the necessary JSON files for the Incident Central Retool applications and modules, serving as the primary method to obtain the application's source code. ```Shell git clone https://github.com/tryretool/retool-app-exchange.git ``` -------------------------------- ### Configuring PagerDuty API Resource Headers in Retool Source: https://github.com/tryretool/retool-app-exchange/blob/main/incident-central/setup-guides/set-up-retool-resources.md This snippet outlines the HTTP headers required for authenticating and interacting with the PagerDuty API. It includes headers for content type, API versioning, and authorization using a token, ensuring proper communication with the PagerDuty service. ```Configuration = Headers = Accept: application/vnd.pagerduty+json;version=2 Authorization: Token token= Content-Type: application/json ``` -------------------------------- ### Configuring Slack API Resource Headers in Retool Source: https://github.com/tryretool/retool-app-exchange/blob/main/incident-central/setup-guides/set-up-retool-resources.md This snippet details the HTTP headers required for secure and correct communication with the Slack API. It includes headers for content type with UTF-8 encoding and authorization using a bearer token, facilitating proper API requests. ```Configuration = Headers = Content-Type: application/json; charset=utf-8 Authorization: Bearer ``` -------------------------------- ### Creating PL/pgSQL Timestamp Trigger Function Source: https://github.com/tryretool/retool-app-exchange/blob/main/incident-central/setup-guides/set-up-database.md This PL/pgSQL function, `trigger_set_timestamp`, is designed to automatically update the `updated_at` column of a table to the current timestamp (`NOW()`) whenever a row is modified. It is intended to be used with a `BEFORE UPDATE` trigger. ```PL/pgSQL CREATE OR REPLACE FUNCTION trigger_set_timestamp() RETURNS TRIGGER AS $$ BEGIN NEW.updated_at = NOW(); RETURN NEW; END; $$ LANGUAGE plpgsql; ``` -------------------------------- ### Configuring Incident Database Resource in Retool Source: https://github.com/tryretool/retool-app-exchange/blob/main/incident-central/setup-guides/set-up-retool-resources.md This snippet presents the configuration fields for the 'Incident Database' resource in Retool, typically a Postgres database. It lists placeholders for critical connection details such as host, port, database name, username, and password, which users must fill with their specific database credentials. ```Configuration Name: Incident Database Host: Port: Database name: Database username: Database password: ``` -------------------------------- ### Configuring Snowflake DB - Account Admin Resource in Retool Source: https://github.com/tryretool/retool-app-exchange/blob/main/snowflake-resource-optimization/setup-guides/set-up-retool-resource.md This configuration snippet outlines the required settings for creating a 'Snowflake DB - Account Admin' resource in Retool. It specifies the resource name, Snowflake account details, database name, user role (ACCOUNTADMIN), password authentication, and crucially, the disabling of prepared statements for compatibility with the Retool app. This resource acts as a reusable connection to Snowflake. ```Retool Resource Configuration Name: Snowflake DB - Account Admin Account name: Database name: SNOWFLAKE Database schema: [leave blank] Database warehouse: [leave blank] User role: ACCOUNTADMIN (this role is required) Authentication: Password (you must use password authentication) Database username: Database password: [X] Disable converting queries to prepared statements (you must check this box) ``` -------------------------------- ### Configuring Snowflake UAR Resource in Retool Source: https://github.com/tryretool/retool-app-exchange/blob/main/snowflake-uar-reviews/setup-guides/set-up-retool-resource.md This configuration block defines the parameters required to set up a 'Snowflake UAR' resource in Retool. It specifies the account details, database information, user role, and authentication method (password-based) for connecting to a Snowflake database. The resource name 'Snowflake UAR' is crucial as it's expected by the provided app code. ```Configuration Name: Snowflake UAR Account name: Database name: SNOWFLAKE Database schema: Database warehouse: User role: ACCOUNTADMIN (this role is required) Authentication: Password (you must use password authentication) Database username: Database password: ``` -------------------------------- ### Configuring Slack API Resource Name and Base URL in Retool Source: https://github.com/tryretool/retool-app-exchange/blob/main/incident-central/setup-guides/set-up-retool-resources.md This snippet provides the configuration for the Slack API resource in Retool, setting its name and the base URL for Slack API interactions. The specified name 'Slack API for Incident Central' is necessary for the Retool app's expected behavior. ```Configuration Name: Slack API for Incident Central Base URL: https://slack.com/api ``` -------------------------------- ### Configuring Slack Bot Token Scopes Source: https://github.com/tryretool/retool-app-exchange/blob/main/incident-central/setup-guides/set-up-slack.md This snippet specifies the required Bot Token Scopes for the Slack app to function correctly with Incident Central. These scopes grant the app permissions to manage channels and read user information, including email addresses, which are crucial for incident response automation. ```Configuration Bot Token Scopes: - channels:manage - users:read - users:read.email ``` -------------------------------- ### Configuring PagerDuty API Resource Name and Base URL in Retool Source: https://github.com/tryretool/retool-app-exchange/blob/main/incident-central/setup-guides/set-up-retool-resources.md This snippet defines the essential configuration for the PagerDuty API resource in Retool, specifying its name and the base URL for API calls. The resource name 'PagerDuty API for Incident Central' is critical for the Retool app's functionality. ```Configuration Name: PagerDuty API for Incident Central Base URL: https://api.pagerduty.com ``` -------------------------------- ### Creating Incidents Table and Update Trigger in PostgreSQL Source: https://github.com/tryretool/retool-app-exchange/blob/main/incident-central/setup-guides/set-up-database.md This SQL snippet creates the `incidents` table with a predefined schema for storing incident metadata, including `id`, `created_at`, `updated_at`, and various PagerDuty and Slack related fields. It also sets up a trigger, `set_updated_at_on_incidents`, to automatically call the `trigger_set_timestamp` function before each update on the `incidents` table, ensuring the `updated_at` column is always current. ```SQL CREATE TABLE IF NOT EXISTS incidents ( id TEXT PRIMARY KEY, created_at TIMESTAMP NOT NULL DEFAULT NOW(), updated_at TIMESTAMP NOT NULL DEFAULT NOW(), pagerduty_id TEXT, pagerduty_url TEXT, slack_channel_id TEXT, slack_channel_name TEXT, slack_channel_url TEXT, reporter_email TEXT, incident_commander_email TEXT ); CREATE TRIGGER set_updated_at_on_incidents BEFORE UPDATE ON incidents FOR EACH ROW EXECUTE PROCEDURE trigger_set_timestamp(); ``` -------------------------------- ### Cloning Retool App Exchange GitHub Repository Source: https://github.com/tryretool/retool-app-exchange/blob/main/usage-viewer/README.md This Bash command initiates the cloning process for the `retool-app-exchange` GitHub repository. This action downloads all repository contents, including the JSON file containing the Retool Usage Analytics app code, which is essential for importing the application into your Retool instance. ```Bash git clone https://github.com/tryretool/retool-app-exchange.git ``` -------------------------------- ### Cloning Retool App Exchange GitHub Repository Source: https://github.com/tryretool/retool-app-exchange/blob/main/embed-url-generator/README.md This command clones the `retool-app-exchange` GitHub repository to your local machine, allowing you to download the application code, specifically `embed_url_generator.json`, for importing into Retool. This is an alternative to manually downloading the JSON file. ```Shell git clone https://github.com/tryretool/retool-app-exchange.git ``` -------------------------------- ### Creating Read-Only PostgreSQL User for Retool DB Source: https://github.com/tryretool/retool-app-exchange/blob/main/usage-viewer/README.md This SQL command is used to create a new user in the PostgreSQL database. This user will be specifically configured with read-only access to Retool's internal storage database, which is crucial for securely retrieving usage analytics data without modifying any system configurations. ```SQL CREATE USER WITH PASSWORD ; ``` -------------------------------- ### Assigning Read-Only Permissions to PostgreSQL User Source: https://github.com/tryretool/retool-app-exchange/blob/main/usage-viewer/README.md These SQL commands grant the newly created user the necessary read-only permissions on specific tables within the Retool storage database. This includes `CONNECT` to the database, `USAGE` on the `public` schema, and `SELECT` privileges on tables like `page_saves`, `users`, and `audit_trail_events`, enabling the analytics app to access relevant data. ```SQL GRANT CONNECT ON DATABASE `` TO ; GRANT USAGE ON SCHEMA public TO ; GRANT SELECT ON page_saves TO ; GRANT SELECT ON pages TO ; GRANT SELECT ON folders TO ; GRANT SELECT ON users TO ; GRANT SELECT ON audit_trail_events TO ; GRANT SELECT ON groups to ; GRANT SELECT ON resources to ; GRANT SELECT ON groups to ; GRANT SELECT ON resources to ; GRANT SELECT ON organizations to ; GRANT SELECT ON workflow_save to ; GRANT SELECT ON workflow to ; GRANT SELECT ON workflow_run to ; ``` -------------------------------- ### Managing Twilio Client and Conversation Lifecycle in Retool - JavaScript Source: https://github.com/tryretool/retool-app-exchange/blob/main/applets/twilio-conversations/code/retool/retool-custom-component.html This comprehensive snippet defines the core logic within the `window.Retool.subscribe` function, which reacts to changes in the Retool component model. It handles the instantiation of the `Twilio.Conversations.Client` when a token is available, sets up `stateChanged` event listeners for client status updates, creates and joins a new conversation if one doesn't exist, establishes an `messageAdded` listener for inbound messages, and sends outbound messages based on the Retool model's `outbound` property. ```JavaScript window.Retool.subscribe(async function (model) { // If a chat token is passed into the model, and the Client object is not yet available... if (model.token && !client && model.conversationsCleared) { client = new Twilio.Conversations.Client(model.token); // Instantiate a new Client: http://media.twiliocdn.com/sdk/js/conversations/releases/2.1.0/docs/#instantiating-and-using // Set event handlers on the new Client which trigger log messages: http://media.twiliocdn.com/sdk/js/conversations/releases/2.1.0/docs/classes/Client.html#stateChanged client.on("stateChanged", (state) => { if (state === "failed") { window.Retool.modelUpdate({ // Update the model with the error: https://docs.retool.com/docs/custom-components#non-react-javascript error: "The client failed to initialize" }); } if (state === "initialized") { window.Retool.modelUpdate({ status: "The client successfully initialized!" }); } }); } // If the Client is inititialized and no Conversation has been created... if (client && !conversation) { conversation = "initializing"; conversation = await client.createConversation(); // Create a Conversation: http://media.twiliocdn.com/sdk/js/conversations/releases/2.1.0/docs/classes/Client.html#createConversation await conversation.join(); // Join the Conversation: http://media.twiliocdn.com/sdk/js/conversations/releases/2.1.0/docs/classes/Conversation.html#join window.Retool.modelUpdate({ conversationSid: conversation.sid }); // Pass the Conversation SID to the component model } // If the Client is initialized, a customer number has been passed to the model, and no inbound message listener has been defined... if (client && model.customerNumber && !inboundListener) { client.on("messageAdded", (message) => { // When a message is added to the conversation: http://media.twiliocdn.com/sdk/js/conversations/releases/2.1.0/docs/classes/Client.html#messageAdded if ( // If the message author is the customer, and we haven't processed the message already... message.state.author === model.customerNumber && message.state.body != inboundMessage ) { // Push the message to the component model. inboundMessage = message.state.body; window.Retool.modelUpdate({ inbound: message.state.body }); } }); inboundListener = true; } // If the Client and Conversations are initialized, there is an outbound message on the model, and we haven't procesed it yet... if ( client && conversation && model.outbound && model.outbound != outboundMessage ) { outboundMessage = model.outbound; await conversation.sendMessage(outboundMessage); // Send the message: http://media.twiliocdn.com/sdk/js/conversations/releases/2.1.0/docs/classes/Conversation.html#sendMessage } }); ``` -------------------------------- ### Initializing Global Variables for Twilio Client - JavaScript Source: https://github.com/tryretool/retool-app-exchange/blob/main/applets/twilio-conversations/code/retool/retool-custom-component.html This snippet declares global variables (`client`, `conversation`, `inboundListener`, `outboundMessage`, `inboundMessage`) that will be used to store instances of the Twilio Conversations Client, the active conversation, and state related to message handling within the Retool custom component. These variables are initialized outside the `window.Retool.subscribe` function to maintain their state across model updates. ```JavaScript var client; var conversation; var inboundListener; var outboundMessage; var inboundMessage; ``` -------------------------------- ### Initializing Twilio Call Variables (JavaScript) Source: https://github.com/tryretool/retool-app-exchange/blob/main/applets/twilio-dialer/code/retool/retool-custom-component.html This snippet declares and initializes key variables used globally within the custom component's scope. These variables, `device`, `currentPhoneNumber`, and `call`, are essential for managing the Twilio Device instance, tracking the active phone number, and holding the current Twilio Call object, respectively. ```javascript // Initialize variables to be used inside of the window.Retool.subscribe function var device; var currentPhoneNumber; var call; ``` -------------------------------- ### Logging Activity in Twilio Dialer (JavaScript) Source: https://github.com/tryretool/retool-app-exchange/blob/main/applets/twilio-dialer/code/retool/retool-custom-component.html This JavaScript function provides a utility for displaying messages within the dialer's activity log. It appends new messages as paragraph elements to a designated 'log' div and automatically scrolls to the bottom to show the latest entries, ensuring real-time feedback to the user. ```javascript /* eslint-disable */ // Activity log function log(message) { var logDiv = document.getElementById("log"); logDiv.innerHTML += "

> " + message + "

"; logDiv.scrollTop = logDiv.scrollHeight; } ``` -------------------------------- ### Styling the Twilio Dialer UI (CSS) Source: https://github.com/tryretool/retool-app-exchange/blob/main/applets/twilio-dialer/code/retool/retool-custom-component.html This CSS snippet defines the visual appearance of the embedded Twilio dialer within the Retool custom component. It sets basic padding, margins, background color, text alignment, font styles, and controls the layout and scroll behavior of the activity log area. ```css body, p { padding: 0; margin: 0; } body { background: #272726; } label { text-align: left; font-family: Helvetica, sans-serif; font-size: 1.25em; color: #777776; display: block; } div#controls { padding: 1em; margin: 0 auto; } div#controls div#call-controls, div#controls div#info { margin: 0 1.5em; text-align: center; } div#controls div#log { border: 1px solid #686865; width: 100%; height: 9.5em; text-align: left; overflow-y: scroll; } div#controls div#log p { color: #686865; font-family: "Share Tech Mono", "Courier New", Courier, fixed-width; font-size: 1.25em; line-height: 1.25em; margin-left: 1em; text-indent: -1.25em; width: 90%; } ``` -------------------------------- ### Handling Retool Model Updates for Twilio Calls (JavaScript) Source: https://github.com/tryretool/retool-app-exchange/blob/main/applets/twilio-dialer/code/retool/retool-custom-component.html This core JavaScript snippet subscribes to changes in the Retool custom component's model, enabling dynamic interaction with the Twilio Voice SDK. It instantiates the Twilio Device when a voice token is provided, initiates calls when a phone number and 'retool_called' status are detected, and disconnects calls when the 'retool_ended' status is received, updating the Retool model accordingly. ```javascript window.Retool.subscribe(async function (model) { // subscribes to model updates // all model values can be accessed here if (model.data && model.data.token && !device) { // If a voice token is passed into the model, and the device object is not yet available... device = new Twilio.Device(model.data.token); // Instantiate a new Device: https://www.twilio.com/docs/voice/sdks/javascript/twiliodevice#instantiate-a-device // Set event handlers on the new Device which trigger log messages: https://www.twilio.com/docs/voice/sdks/javascript/twiliodevice#deviceoneventname-listener device.on("error", (error) => { log("Twilio.Device Error: " + error.message); }); } if ( model.phoneNumber && model.status === "retool_called" && currentPhoneNumber != model.phoneNumber ) { // If a phone number is passed into the model, and the user clicked the Call button in the UI... currentPhoneNumber = model.phoneNumber; // get the phone number to connect the call to var params = { params: { To: currentPhoneNumber } }; log("Calling " + currentPhoneNumber + "..."); if (device) { call = await device.connect(params); // Instantiate a new Call object, passing in the phone number: https://www.twilio.com/docs/voice/sdks/javascript/twiliodevice#deviceconnectconnectoptions // Set event handlers on the new Call: https://www.twilio.com/docs/voice/sdks/javascript/twiliocall#events call.on("accept", (call) => { log("Successfully established call!"); }); call.on("disconnect", (call) => { // When the call is disconnected (either by the Retool user or the called party)... log("Call ended."); currentPhoneNumber = null; // Set the currentPhoneNumber back to null and... window.Retool.modelUpdate({ status: "ready_for_call" }); // Update the model with new status: https://docs.retool.com/docs/custom-components#non-react-javascript }); if (call.status() === "connecting") { log("Connecting..."); } } } if (model.status === "retool_ended") { // If the user clicked the End button in the UI... log("Hanging up..."); if (device) { device.disconnectAll(); // Disconnect the call: https://www.twilio.com/docs/voice/sdks/javascript/twiliodevice#devicedisconnectall } } }); ``` -------------------------------- ### Detecting Browser Type and Updating Retool Model - JavaScript Source: https://github.com/tryretool/retool-app-exchange/blob/main/applets/twilio-conversations/code/retool/retool-custom-component.html This snippet checks if the user's browser is Chrome by inspecting the `navigator.userAgent` string. It then updates the Retool custom component model with the detected browser type ('Chrome' or 'Not Chrome'), which is important because non-Chrome browsers might restrict WebSocket access required by the Twilio SDK. ```JavaScript if (navigator.userAgent.indexOf("Chrome") > -1) { window.Retool.modelUpdate({ browser: "Chrome" }); } else { window.Retool.modelUpdate({ browser: "Not Chrome" }); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.