In order for AI Agents to generate insights you will need to provide them with read access to a SQL view containing the unstructured text data generated by your users, such as support tickets, call transcripts, or survey responses.
π€ The view must have AT LEAST the following columns in order to work:
id: The id of the document (ticket, survey, etc.)
text: The unstructured text to be analyzed
creation_date: The date of creation of the unstructured text
user_id: The id of the user that generated the unstructured text
Here is an example of a view created in Snowflake with the required format:β
-- Customize if needed
SET LANGAI_APP_NAME = 'LANGAI_APP';
-- Example of a view creation. Customize it to your data structure.
CREATE OR REPLACE VIEW $LANGAI_APP_DB.PUBLIC.$VIEW_NAME(
ID,
TEXT,
CREATION_DATE,
USER_ID,
PLAN
) as SELECT id, text as text, creation_date, user_id, plan
FROM LANGAI_DEMO.PUBLIC.CUSTOMER_REVIEWS;
--- Give the application access to the view
GRANT USAGE ON DATABASE "YOUR_DATABASE" TO APPLICATION IDENTIFIER($LANGAI_APP_NAME);
GRANT USAGE ON SCHEMA "YOUR_SCHEMA" TO APPLICATION IDENTIFIER($LANGAI_APP_NAME);
GRANT SELECT ON VIEW "YOUR_VIEW" TO APPLICATION IDENTIFIER($LANGAI_APP_NAME);
The USAGE privilege is required on the parent database and schema. This privilege doesn't provide SELECT access to the database rows. Learn more here.
Including additional columns as metadata
You may include additional columns that can be used by the AI agent to aggregate the insights generated. In the example above, the column called plan is not mandatory, but we included it so o the agent is able to group the insights by the user's subscription plan.
This is a preview of the view we created:
β
And this is how the plan column may be used as a filter for the insights:
If you have any question about creating and using views, please get in touch with your CSM.