Inspiration

The inspiration for Targeted Marketing Messenger came from the desire to help small businesses effectively target their marketing efforts without requiring extensive technical knowledge. I envisioned a way for a business to quickly and easily send messages to a specified subset of their customers. The idea is that users would have their preferred method of communication and the app sends the messages out through the proper channels. The message drafting feature allows the business owner to focus on defining the subset and the information to be included in the message, so they don't have to have any knowledge of sql or think about marketing copyrighting to get a quick message out.

What it does

Allows users to:

  • Easily find specific customer segments based on natural language criteria.
  • Generate SQL queries and receive plain English explanations for verification.
  • Explore customer subsets, spending breakdowns, and order history through interactive tabs.
  • Craft and send personalized promotional messages directly to selected customer segments.

How I built it and challenges

At first I wasn't sure what Arctic would be great at. But then I realized it was great at writing sql so I focused on that. I couldn't find a good dataset available for my use case, so I spent some time to generate artificial sales data for demo purposes. After that, the challenge was ensuring the LLM understood the dataset format correctly and creating diverse examples to cover various potential queries. I really love tinkering with Streamlit UI so that was my favorite part!

Accomplishments that I'm proud of

I am proud of the clean UI and layout of the app. I'm am also happy to have added the llm's explanation of the query as a verification for the user to make sure the sql query was generated properly. This explanation can also be a better input to reproduce the same queries again. I like the st.popover for the query so that the layman user doesn't need to focus on it.

What I learned

I learned a lot about Snowflake Arctic's capabilities in writing and interpreting SQL queries. I think Arctic will be my go to llm for writing sql. I haven't written sql in a few years so I was verifying the generations with ChatGPT and at one point Arctic wrote a different query and when I asked ChatGPT if it was correct, it stated that it was actually "a more intuitive" way of writing the query than how ChatGPT suggested.

I also learned of a limitation of the Streamlit UI that I hadn't run into before. I like using st.columns to center widgets and add spacing, but when I tried to have all the names in the customer subset list use a middle column of 3 columns, it slowed my app loading significantly that I couldn't use it. I have been testing with 2000 customers and the list loads fine without putting each name into a middle column. That being said, I'm looking forward to the "Speed + performance initiative" in the Streamlit roadmap.

What's next

Next features to add:

  • Use Arctic Embed to integrate RAG with the data fields so that more vague user requests can be matched to the data properly, like matching products names.
  • Add ability for users to update their own data schemas and update the prompts to work with them.
  • Add more robust data to the dataset and push the llm sql query generation to handle more complex schemas, like ingredients for each product so a subset can be made for customer who like a certain ingredient.
  • Add functionality to actually send messages.
  • Save templates and automations of subset and message criteria.
  • Better error handling and add subset orders to session state.

Built With

  • python
  • replicate
  • snowflake
  • streamlit
Share this project:

Updates