{"id":2538,"date":"2023-10-18T08:20:09","date_gmt":"2023-10-18T15:20:09","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/azure-sql\/?p=2538"},"modified":"2026-02-23T11:37:52","modified_gmt":"2026-02-23T19:37:52","slug":"how-i-built-a-session-recommender-in-1-hour-using-open-ai","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/azure-sql\/how-i-built-a-session-recommender-in-1-hour-using-open-ai\/","title":{"rendered":"How I built a session recommender in 1 hour using Open AI"},"content":{"rendered":"<p>As a developer, I often attend conferences to learn new skills and network with other professionals. However, conferences can be overwhelming, especially when they offer dozens of sessions on different topics. How can I decide which ones are worth my time and attention?<\/p>\n<p>That&#8217;s why I decided to use OpenAI to create a tool that can help me find the most relevant sessions for my interests. I used the session abstracts of a conference as input and converted them into embeddings using OpenAI&#8217;s natural language processing capabilities. Then, I used vector search to compare the embeddings with a query topic and rank the sessions by similarity.<\/p>\n<p>This way, I can quickly and easily discover the sessions that match my goals and preferences, without having to read all the abstracts manually. I built this tool in a couple of hours during the weekend, using simple, scalable, and fast technologies.<\/p>\n<p>Here&#8217;s how I did it. I hope you&#8217;ll find it useful.<\/p>\n<h2><a href=\"https:\/\/dev.to\/azure\/how-i-built-a-session-recommender-in-1-hour-using-open-ai-5419#the-architecture\" name=\"the-architecture\"><\/a>The Architecture<\/h2>\n<p>The entire solution is a mix of fullstack, jamstack to be more precise, and event-driven architecture pattern.<\/p>\n<p>Sessions&#8217; data, which is structured by nature, is saved into a relational database and the tables and stored procedures are made available to the fronted via REST and GraphQL.<\/p>\n<p>Each time a new session is added, a serverless function is executed to turn abstracts into a vector by using OpenAI model via a REST call.<\/p>\n<p>A (minimal) web frontend allows end users to type a text that will also be converted into a vector using OpenAI and then the most similar vectors &#8211; and thus the associated sessions &#8211; will be found using cosine similarity.<\/p>\n<p>That&#8217;s all. Simple, easy, elegant, and scalable: the architecture I love.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/session-recommender-1.png\"><img decoding=\"async\" class=\"aligncenter wp-image-2539 size-full\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/session-recommender-1.png\" alt=\"Image session recommender 1\" width=\"800\" height=\"484\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/session-recommender-1.png 800w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/session-recommender-1-300x182.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/session-recommender-1-768x465.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n<h2><a href=\"https:\/\/dev.to\/azure\/how-i-built-a-session-recommender-in-1-hour-using-open-ai-5419#implementation-details\" name=\"implementation-details\"><\/a>Implementation Details<\/h2>\n<p>I used Azure for everything. Thanks to the various free and trial offers it is possible to create such a solution completely for free.<\/p>\n<h3><a href=\"https:\/\/dev.to\/azure\/how-i-built-a-session-recommender-in-1-hour-using-open-ai-5419#the-frontend\" name=\"the-frontend\"><\/a>The Frontend<\/h3>\n<p>I used\u00a0<a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/static-web-apps\/overview\">Azure Static Web Apps<\/a>\u00a0to host the fronted, written using React. Simple, well-known and easy to create. I&#8217;m new to React, so using this project was an effective way to ramp-up my skills while doing something funny and cool at the same time. I&#8217;ve learned a lot around the ecosystem around it (for example\u00a0<a href=\"https:\/\/reactrouter.com\/en\/main\">react-router-dom<\/a>,\u00a0<a href=\"https:\/\/vite.js\/\">vite<\/a>) and the way it works internally.<\/p>\n<p>Azure Static Web Apps provides a fantastic on-prem development experience, and it is heavily integrated with GitHub, so that deployment is just a push to the target repository. Kind of obvious choice.<\/p>\n<h3><a href=\"https:\/\/dev.to\/azure\/how-i-built-a-session-recommender-in-1-hour-using-open-ai-5419#the-backend\" name=\"the-backend\"><\/a>The Backend<\/h3>\n<p>Azure Static Web Apps comes with a cool feature named\u00a0<a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/static-web-apps\/database-overview\">Database Connections<\/a>\u00a0that does a lot of heavy lifting for you. It automatically takes the database objects you configure and make them available via GraphQL and REST.<\/p>\n<p>Database Connections is powered by\u00a0<a href=\"https:\/\/aka.ms\/dab\">Data API builder<\/a>, which is open-source and available also on-premises. It is heavily integrated with Static Web Apps, and the on-prem development experience that they provide is honestly unmatched. I was able to do everything on my machine with no friction at all, no CORS worries, authentication provider emulation, integration with vite tools&#8230;it is absolutely amazing! Same as for the frontend, the deployment to Azure is done via a simple\u00a0<em>git push<\/em>.<\/p>\n<h3><a href=\"https:\/\/dev.to\/azure\/how-i-built-a-session-recommender-in-1-hour-using-open-ai-5419#the-database\" name=\"the-database\"><\/a>The Database<\/h3>\n<p>I used Azure SQL database. It now has a\u00a0<a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/new-azure-sql-database-free-offer\/\">free offer<\/a>, and it can easily scale to terabytes of data if needed. Not that I think I need a terabyte of data for now&#8230;but you never know \ud83d\ude42<\/p>\n<h4><a href=\"https:\/\/dev.to\/azure\/how-i-built-a-session-recommender-in-1-hour-using-open-ai-5419#about-vectors\" name=\"about-vectors\"><\/a>About vectors<\/h4>\n<p>Azure SQL database doesn&#8217;t have a native vector type, but a vector is nothing more than a list of numbers. Relational databases are in general pretty good at managing list of things (otherwise known as sets \ud83d\ude0a, otherwise known as\u00a0<em>relations<\/em>\u00a0\ud83d\ude01) efficiently.<\/p>\n<p>With a dataset the size of the one I&#8217;m using, doing a full scan of all available vectors is desirable approach, as it performs\u00a0<em>exact nearest neighbor<\/em>\u00a0search, which provides perfect\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Precision_and_recall\">recall<\/a>. There is no need to specialized indexes, so Azure SQL looks like a great choice.<\/p>\n<p>In fact, even if the amount of data is not huge, is not insignificant either. OpenAI text embeddings return a vector with 1536 (float) values, so even with just 100 sessions to store the number of calculations to do in order to compute the cosine distance quickly approaches hundreds of thousands, and they should be done in the quickest way possible to accommodate as many requests per second as possible.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/session-recommender-2.png\"><img decoding=\"async\" class=\"aligncenter wp-image-2540 size-full\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/session-recommender-2.png\" alt=\"Image session recommender 2\" width=\"800\" height=\"208\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/session-recommender-2.png 800w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/session-recommender-2-300x78.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/session-recommender-2-768x200.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n<p>Azure SQL uses vector calculations internally (SIMD and AVX512 CPU instructions), to speed up operations on sets of data, and offers a columnstore index that can make operations on sets of data even faster. Not that a columnstore would be really needed for the small amount of data I have, but I wanted to give it a try to see how it would perform. And you&#8217;ll see that the performances are great. The CPU usage is minuscule, and vector search is done in less than 50 msec on 100 of session abstracts. Impressive performance, and I don&#8217;t have to install, manage, and integrate another database or a third-party library. Perfect: simplicity for the win!<\/p>\n<p>If you want to dig more into in doing vector search with Azure SQL, read the\u00a0<a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/vector-similarity-search-with-azure-sql-database-and-openai\/\">Vector Similarity Search with Azure SQL database and OpenAI<\/a>\u00a0article.<\/p>\n<h4><a href=\"https:\/\/dev.to\/azure\/how-i-built-a-session-recommender-in-1-hour-using-open-ai-5419#openai-integration\" name=\"openai-integration\"><\/a>OpenAI integration<\/h4>\n<p>Finally, I wanted to keep the solution as simple as possible and as efficient as possible, so I wanted to use the new capability of Azure SQL to call a REST API directly to call OpenAI directly from inside the database to convert the searched text into a vector.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/session-recommender-3.png\"><img decoding=\"async\" class=\"aligncenter wp-image-2541 size-full\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/session-recommender-3.png\" alt=\"Image session recommender 3\" width=\"800\" height=\"178\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/session-recommender-3.png 800w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/session-recommender-3-300x67.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/session-recommender-3-768x171.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n<p>By doing it inside the database, I don&#8217;t have to create yet another Azure Function just for the purpose of calling the OpenAI REST endpoint and then storing the resulting vector in the database. This approach is something I can switch to in case I need more scalability, but there is no proof that such additional scalability is needed right now, so I decided to start with a simpler architecture.<\/p>\n<h2><a href=\"https:\/\/dev.to\/azure\/how-i-built-a-session-recommender-in-1-hour-using-open-ai-5419#the-result\" name=\"the-result\"><\/a>The Result<\/h2>\n<p>The result is here for you to test out, which is something it will not only be interesting but also helpful if you plan to attend the\u00a0<a href=\"https:\/\/www.dotnetconf.net\/\">.NET Conf 2023<\/a>. In fact, I populated the database of the published sample solution with their session abstracts.<\/p>\n<p>I spent more or less one hour building everything, mostly on React and the frontend side. Creating the database and publishing it as REST endpoint took probably no more than 10 minutes. \ud83d\ude0d<\/p>\n<p>Try it out yourself here:<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/Screenshot-2023-10-17-233039.png\"><img decoding=\"async\" class=\"alignnone wp-image-2545 size-large\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/Screenshot-2023-10-17-233039-1024x469.png\" alt=\"Image Screenshot 2023 10 17 233039\" width=\"640\" height=\"293\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/Screenshot-2023-10-17-233039-1024x469.png 1024w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/Screenshot-2023-10-17-233039-300x137.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/Screenshot-2023-10-17-233039-768x352.png 768w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/Screenshot-2023-10-17-233039-1536x704.png 1536w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/10\/Screenshot-2023-10-17-233039.png 1726w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/aka.ms\/dotnetconf2023-session-finder\">https:\/\/aka.ms\/dotnetconf2023-session-finder<\/a><\/p>\n<p>Of course, the OpenAI calls are limited (I&#8217;m using the smallest tier) so you might see throttling happening. Please be patient or deploy everything in our subscription to try it out yourself, using the code available here:<\/p>\n<p><a href=\"https:\/\/github.com\/azure-samples\/azure-sql-db-session-recommender\">https:\/\/github.com\/azure-samples\/azure-sql-db-session-recommender<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As a developer, I often attend conferences to learn new skills and network with other professionals. However, conferences can be overwhelming, especially when they offer dozens of sessions on different topics. How can I decide which ones are worth my time and attention? That&#8217;s why I decided to use OpenAI to create a tool that [&hellip;]<\/p>\n","protected":false},"author":24720,"featured_media":2539,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,597,582],"tags":[],"class_list":["post-2538","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-sql","category-data-api-builder-2","category-openai"],"acf":[],"blog_post_summary":"<p>As a developer, I often attend conferences to learn new skills and network with other professionals. However, conferences can be overwhelming, especially when they offer dozens of sessions on different topics. How can I decide which ones are worth my time and attention? That&#8217;s why I decided to use OpenAI to create a tool that [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts\/2538","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/users\/24720"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/comments?post=2538"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts\/2538\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/media\/2539"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/media?parent=2538"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/categories?post=2538"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/tags?post=2538"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}