In this recipe, you’ll learn how to be automatically notified with the top activity happening on your website and app. In this example, we will be using top products (product viewed or page viewed event). However, this same recipe can be applied to other elements that receive traction throughout the day such as articles or popular posts. The members of your sales team will be able to quickly react to products that are high in demand.
In your Slack custom integration settings, create a new Incoming Webhook URL by selecting a Slack channel associated with your account.
In your Segment workspace, navigate to Reverse ETL -> Sources and click Add Source.
Select Snowflake and then name your source on the Basic Settings tab.
Have your Snowflake Account ID, Database Name, Warehouse, Username, and Password availableand follow the instructions on the Connection Settings tab to connect your Snowflake source.
In your Segment workspace, under Reverse ETL -> Sources, click into your newly created Snowflake source and select Add Model -> SQL Editor.
Create your SQL query to pull the data from your Snowflake table. An example query for this model would look like this: SELECT PRODUCT, COUNT(*) VIEWS, URL, ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS ID FROM ACME_MDWHO.ACME_PRODUCTION.POPULAR_PRODUCTS GROUP BY PRODUCT, URL LIMIT 3
Enter a unique identifier column. In this example, ROW_NUMBER
is being used named ID
so use ID as the unique identifier column in the box below the query.
Preview the results and make sure there are no errors.
Enter a name for the model, and set how frequently you would like it to be performed. If you want to receive the top 3 products being viewed every 2 hours, select ‘every 2 hours’.
In your Segment workspace, navigate to Reverse ETL -> Destinations and select Add Destination.
Select Slack and connect it to the Snowflake source.
Name the destination and click Create Destination.
Enable the destination and Save Changes.
Navigate to the Mappings tab of the Slack destination and select Add Mapping.
Select your model at the top, and then select the Post Message mapping.