Skip to main content
All CollectionsSnowflake AI agentsInstalling Lang
Install the Native App with an SQL script
Install the Native App with an SQL script

This guide shows how to install the Lang's Native App manually

Updated over 2 months ago

πŸ’‘ Learn more
This guide shows the steps needed to install the app with SQL script. This gives more transparency and flexibility to the teams managing the provisioning.


​Additional resources

πŸ“• Full Installation Script: Check the full script here.
β€‹πŸ”’ Technical Overview: Get an overview of the security features here.

Overview

In this guide you will learn how to install our Snowflake AI agents app to empower data teams to create custom agents that derive actionable priorities from customer interaction, driving retention and growth. If you prefer to install it by using the UI, please follow this guide.

1. Install the app from the Snowflake Marketplace

2. Create databases, roles, network rules, and privileges for Lang

3. Launch the Native App

4. Create and give your AI Agent access to a View


​

1. Install the app from the Snowflake Marketplace

The first step is to request access to our Native App. Once done, our team will review your request and you will be able to start the installation.

The application will show up in Data Products > Apps > Recently Shared with You. After installing the app, a modal window will show up. Click on Configure to go to the next step.

2. Create databases, roles, network rules, and privileges for Lang

🀚 Heads up
Note that the following steps can only be done using the ACCOUNTADMIN role or by an user/role with the appropriate privileges.

Step 1: Set the warehouse to run the installation scripts

Set the warehouse that will be running the scripts to setup the application.

-- Set the warehouse to be used for the App setup
SET USER_WAREHOUSE = '<YOUR_WAREHOUSE>';

-- Set the name of the LangAI application
-- IMPORTANT: Ensure this matches the exact name used during installation
SET LANGAI_APP_NAME = 'LANGAI_APP';

-- Use the same role that installed the application with the appropriate privileges.
-- https://other-docs.snowflake.com/en/native-apps/consumer-installing#set-up-required-privileges
USE ROLE ACCOUNTADMIN;
USE WAREHOUSE IDENTIFIER($USER_WAREHOUSE);

Step 2. Grant necessary privileges

Grant the BIND SERVICE ENDPOINT privilege to the Lang application to enable network ingress and access to the Lang UI. Details of the privilege can be found here.

GRANT BIND SERVICE ENDPOINT ON ACCOUNT TO APPLICATION IDENTIFIER($LANGAI_APP_NAME);

​
Grant the EXECUTE TASK privilege to enable automatic generation of insights on a weekly basis (when activated).

GRANT EXECUTE TASK ON ACCOUNT TO APPLICATION IDENTIFIER($LANGAI_APP_NAME);

Step 3. Create database and schema to save configuration

Database and schema to hold network rules for the Lang application along with usage for the LangAI application.
​

SET LANGAI_APP_DB = CONCAT($LANGAI_APP_NAME, '_APP_DATA');

CREATE DATABASE IF NOT EXISTS IDENTIFIER($LANGAI_APP_DB);

GRANT USAGE ON DATABASE IDENTIFIER($LANGAI_APP_DB) TO APPLICATION IDENTIFIER($LANGAI_APP_NAME);

USE DATABASE IDENTIFIER($LANGAI_APP_DB);

CREATE SCHEMA IF NOT EXISTS CONFIGURATION;

GRANT USAGE ON SCHEMA CONFIGURATION TO APPLICATION IDENTIFIER($LANGAI_APP_NAME);

USE SCHEMA CONFIGURATION;

Step 4. Enable access to Snowflake Cortex

-------------------
-- CONFIGURE LLM --
-------------------
-- Llama Configuration
-- Necessary for the app to access to snowflake cortex
-- https://medium.com/snowflake/unlocking-the-power-of-snowflake-native-app-and-cortex-llm-building-applications-with-ease-61ef0d3b5296
GRANT IMPORTED PRIVILEGES ON DATABASE SNOWFLAKE TO APPLICATION IDENTIFIER($LANGAI_APP_NAME);

Our app needs access to an LLM provided by Snowflake Cortex. The data share with the LLM won't leave Snowflake.

Optional: Create external access integration for Slack

This integrations is necessary to allow the App to make requests to resources outside of Snowflake. They enable secure connections to external services and APIs required for the App's functionality. Learn more here.

The Slack connection is required to send the AI Agent insights to your selected Slack room. This step is not mandatory and may be completed later. Learn more about the Slack integration here.

---------------------
-- CONFIGURE Slack --
---------------------
-- Set up network rule to allow access to Slack
CREATE OR REPLACE NETWORK RULE SLACK_EXTERNAL_ACCESS_NETWORK_RULE
MODE = EGRESS
TYPE = HOST_PORT
VALUE_LIST = ('slack.com');

-- Create external access integration for Slack
-- This enables the app to send insights via Slack
CREATE OR REPLACE EXTERNAL ACCESS INTEGRATION SLACK_EXTERNAL_ACCESS_INTEGRATION
ALLOWED_NETWORK_RULES = (SLACK_EXTERNAL_ACCESS_NETWORK_RULE)
ENABLED = true;

-- Grant USAGE privilege on the external access integration to the app
GRANT USAGE ON INTEGRATION SLACK_EXTERNAL_ACCESS_INTEGRATION TO APPLICATION IDENTIFIER($LANGAI_APP_NAME);

-- Activate the Slack external access integration
SET ACTIVATE_SLACK_PROCEDURE = CONCAT($LANGAI_APP_NAME, '.CONFIG.ACTIVATE_SLACK_EXTERNAL_ACCESS');
CALL IDENTIFIER($ACTIVATE_SLACK_PROCEDURE)();

3. Launch the Native App

Step 1: Create the warehouse

Create a warehouse for the app to execute queries.

CREATE WAREHOUSE IF NOT EXISTS LANGAI_APP_WAREHOUSE
WAREHOUSE_SIZE = 'X-SMALL'
WAREHOUSE_TYPE = 'STANDARD'
AUTO_SUSPEND = 30
AUTO_RESUME = true
INITIALLY_SUSPENDED = true
COMMENT = 'Langai app warehouse';

-- Grant usage of the warehouse to the app
GRANT USAGE ON WAREHOUSE LANGAI_APP_WAREHOUSE TO APPLICATION IDENTIFIER($LANGAI_APP_NAME)

Step 2: Create the compute pools

Create the compute pools for the application services.

-- Create a compute pool for the app service
CREATE COMPUTE POOL IF NOT EXISTS LANGAI_APP_COMPUTE_POOL
FOR APPLICATION IDENTIFIER($LANGAI_APP_NAME)
MIN_NODES = 1
MAX_NODES = 1
AUTO_SUSPEND_SECS = 60
INSTANCE_FAMILY = CPU_X64_XS
AUTO_RESUME = true;

-- Grant usage of the compute pool to the app
GRANT USAGE ON COMPUTE POOL LANGAI_APP_COMPUTE_POOL TO APPLICATION IDENTIFIER($LANGAI_APP_NAME);

-- Create a compute pool for calculating insights
CREATE COMPUTE POOL IF NOT EXISTS LANGAI_APP_INSIGHTS_COMPUTE_POOL
FOR APPLICATION IDENTIFIER($LANGAI_APP_NAME)
MIN_NODES = 1
MAX_NODES = 1
AUTO_SUSPEND_SECS = 60
INSTANCE_FAMILY = HIGHMEM_X64_S
AUTO_RESUME = true
INITIALLY_SUSPENDED = true;

-- Grant usage of the compute pool to the app
GRANT USAGE ON COMPUTE POOL LANGAI_APP_INSIGHTS_COMPUTE_POOL TO APPLICATION IDENTIFIER($LANGAI_APP_NAME);

Step 3: Start the application

The last step is to activate and start the application.

Not that this operation may take several minutes to complete.

SET START_APP_PROCEDURE = CONCAT($LANGAI_APP_NAME, '.APP_PUBLIC.MANUAL_START_APP');
CALL IDENTIFIER($START_APP_PROCEDURE)();

Optional: Create a role to access the app

This step allows for more granular control over who can use the app.

-- Create a new role for LangAI app users if it doesn't already exist
CREATE ROLE IF NOT EXISTS LANGAI_APP_USER_ROLE;

-- Grant the app-specific user role to the newly created role
SET LANGAI_APP_USER = CONCAT($LANGAI_APP_NAME, '.APP_USER');
GRANT APPLICATION ROLE IDENTIFIER($LANGAI_APP_USER) TO ROLE LANGAI_APP_USER_ROLE;

-- Assign the new role to a ROLE or USER
GRANT ROLE LANGAI_APP_USER_ROLE TO USER|ROLE <YOUR_USER|YOUR_ROLE>;

If you want to test the application with sample data, follow this guide.

4. Create and give your AI Agent access to a View

In order for AI Agents to generate insights you will need to provide them with read access to a Snowflake view containing the unstructured text data generated by your users, such as support tickets, call transcripts, or survey responses.

Learn more here.

Appendix

Enabling event and logs sharing with Lang.ai

Be sure to share ALL events from the native app so that Lang.ai can provide any necessary operational support. You can examine the logs and events shared with Lang.ai using the event table configured for your account. See Snowflake's documentation for more details about event sharing.

Using Snowsight: If you have an existing Lang.ai app installation, you can easily enable events in Snowsight by going to Data Products -> Apps -> Snowflake AI agents -> Events and Logs. On the Events and Logstab, toggle the All events button in the Events and logs sharing section

Using SQL: The above event sharing can also be enabled using the following commands:

-- Set app name if it's different from the default.
SET LANGAI_APP_NAME = 'LANG_AI';

-- Enables event sharing for the Native app.
ALTER APPLICATION IDENTIFIER($LANGAI_APP_NAME) SET AUTHORIZE_TELEMETRY_EVENT_SHARING=true;

Deleting the Lang.ai Native App

You can reset your account and remove all objects associated with Lang.ai using the following script. Note that this will permanently delete all the data from the Native app and this cannot be reverted. Please reach out to support if you have any questions regarding the deletion of the app.

USE ROLE ACCOUNTADMIN;

SET USER_WAREHOUSE = '<YOUR_WAREHOUSE>';
USE WAREHOUSE IDENTIFIER($USER_WAREHOUSE);

-- Set the name of the LangAI application
-- IMPORTANT: This should be the default name of the application as it is installed
SET LANGAI_APP_NAME = 'LANGAI_APP';
SET LANGAI_APP_DB = CONCAT($LANGAI_APP_NAME, '_APP_DATA');

-- Delete the LangAi application and all associated objects.
DROP APPLICATION IF EXISTS IDENTIFIER($LANGAI_APP_NAME) CASCADE;
DROP WAREHOUSE IF EXISTS LANGAI_APP_WAREHOUSE;
DROP COMPUTE POOL IF EXISTS LANGAI_APP_COMPUTE_POOL;
DROP DATABASE IF EXISTS IDENTIFIER($LANGAI_APP_DB);

-- Drop the external access rule created for the LangAI app.
DROP EXTERNAL ACCESS INTEGRATION IF EXISTS OPENAI_EXTERNAL_ACCESS_INTEGRATION;
DROP EXTERNAL ACCESS INTEGRATION IF EXISTS SLACK_EXTERNAL_ACCESS_INTEGRATION;

-- Drop the role created for the user of LangAI app.
DROP ROLE IF EXISTS LANGAI_APP_USER_ROLE;


Additional resources:

Did this answer your question?