[{"data":1,"prerenderedAt":605},["ShallowReactive",2],{"bootstrap":3,"blog-how-to-build-dynamic-pricing-with-external-prices-api-chatgpt-ai":277},{"navigation":4,"globalConfig":196,"forms":218},{"headerSections":5,"headerFooterLinks":67,"footer":76,"legalLinks":153,"socialLinks":176},[6,39,44,50,57,62],{"hasSubMenu":7,"title":8,"links":9,"columns":38},true,"Product",[10,20,26,32],{"showTag":11,"_modelApiKey":12,"text":13,"subtitle":14,"icon":15,"isExternal":11,"link":16,"openForm":11},false,"navigation_link","Universal checkout","Sell anywhere","globe-simple",{"_modelApiKey":17,"slug":18,"title":19},"page","universal-checkout","Universal Checkout",{"showTag":11,"_modelApiKey":12,"text":21,"subtitle":22,"icon":23,"isExternal":11,"link":24,"openForm":11},"Distributed OMS","Manage orders","package",{"_modelApiKey":17,"slug":25,"title":21},"distributed-oms",{"showTag":11,"_modelApiKey":12,"text":27,"subtitle":28,"icon":29,"isExternal":11,"link":30,"openForm":11},"Promotion engine","Automated discounts","seal-percent",{"_modelApiKey":17,"slug":31,"title":27},"promotion-engine",{"showTag":11,"_modelApiKey":12,"text":33,"subtitle":34,"icon":35,"isExternal":11,"link":36,"openForm":11},"POS system","Operate stores","devices",{"_modelApiKey":17,"slug":37,"title":33},"pos-system",2,{"hasSubMenu":11,"showTag":11,"_modelApiKey":12,"text":40,"isExternal":11,"link":41,"openForm":11,"title":40},"Pricing",{"_modelApiKey":42,"slug":43},"pricing_page","pricing",{"hasSubMenu":11,"showTag":11,"_modelApiKey":12,"text":45,"isExternal":11,"link":46,"openForm":11,"title":45},"Customers",{"_modelApiKey":47,"slug":48,"title":49},"customer_landing_page","customers","Customers page",{"hasSubMenu":11,"showTag":11,"_modelApiKey":12,"text":51,"isExternal":11,"link":52,"openForm":11,"form":54,"title":51},"Partners",{"_modelApiKey":17,"slug":53,"title":51},"partners",{"_modelApiKey":55,"slug":53,"name":56},"form","PartnersForm",{"hasSubMenu":11,"showTag":11,"_modelApiKey":12,"text":58,"label":59,"isExternal":7,"url":60,"openForm":11,"title":61},"Docs Hub","Learn more","https:\u002F\u002Fdocs.commercelayer.io\u002F","Docs",{"hasSubMenu":11,"showTag":11,"_modelApiKey":12,"text":63,"isExternal":11,"link":64,"openForm":11,"title":63},"Blog",{"_modelApiKey":65,"slug":66},"blog_landing_page","blog",[68,72],{"text":69,"link":70},"Sign in",{"_modelApiKey":12,"text":69,"isExternal":7,"url":71,"openForm":11},"https:\u002F\u002Fdashboard.commercelayer.io\u002Fsign_in",{"text":73,"link":74},"Sign up for free",{"_modelApiKey":12,"text":73,"isExternal":7,"url":75,"openForm":11},"https:\u002F\u002Fdashboard.commercelayer.io\u002Fsign_up",[77,89,109,132],{"hasSubMenu":7,"title":8,"links":78},[79,81,83,85,87],{"showTag":11,"_modelApiKey":12,"text":13,"subtitle":14,"icon":15,"isExternal":11,"link":80,"openForm":11},{"_modelApiKey":17,"slug":18,"title":19},{"showTag":11,"_modelApiKey":12,"text":21,"subtitle":22,"icon":23,"isExternal":11,"link":82,"openForm":11},{"_modelApiKey":17,"slug":25,"title":21},{"showTag":11,"_modelApiKey":12,"text":27,"subtitle":28,"icon":29,"isExternal":11,"link":84,"openForm":11},{"_modelApiKey":17,"slug":31,"title":27},{"showTag":11,"_modelApiKey":12,"text":33,"subtitle":34,"icon":35,"isExternal":11,"link":86,"openForm":11},{"_modelApiKey":17,"slug":37,"title":33},{"showTag":11,"_modelApiKey":12,"text":40,"isExternal":11,"link":88,"openForm":11},{"_modelApiKey":42,"slug":43},{"hasSubMenu":7,"title":90,"links":91},"Resources",[92,94,99,104,107],{"showTag":11,"_modelApiKey":12,"text":93,"isExternal":7,"url":60,"openForm":11},"Documentation",{"showTag":11,"_modelApiKey":12,"text":95,"label":95,"isExternal":11,"link":96,"openForm":11},"Agentic Commerce",{"_modelApiKey":17,"slug":97,"title":98},"agentic-commerce-whitepaper","Agentic Commerce Whitepaper",{"showTag":11,"_modelApiKey":12,"text":100,"isExternal":11,"link":101,"openForm":11},"Core concepts",{"_modelApiKey":17,"slug":102,"title":103},"headless-commerce","Headless commerce",{"showTag":11,"_modelApiKey":12,"text":105,"isExternal":7,"url":106,"openForm":11},"Changelog","https:\u002F\u002Fdocs.commercelayer.io\u002Fchangelog\u002F",{"showTag":11,"_modelApiKey":12,"text":63,"isExternal":11,"link":108,"openForm":11},{"_modelApiKey":65,"slug":66},{"hasSubMenu":7,"title":110,"links":111},"Company",[112,116,118,121,126],{"showTag":11,"_modelApiKey":12,"text":113,"isExternal":11,"link":114,"openForm":11},"Vision",{"_modelApiKey":17,"slug":115,"title":113},"vision",{"showTag":11,"_modelApiKey":12,"text":45,"isExternal":11,"link":117,"openForm":11},{"_modelApiKey":47,"slug":48,"title":49},{"showTag":11,"_modelApiKey":12,"text":51,"isExternal":11,"link":119,"openForm":11,"form":120},{"_modelApiKey":17,"slug":53,"title":51},{"_modelApiKey":55,"slug":53,"name":56},{"showTag":11,"_modelApiKey":12,"text":122,"isExternal":11,"link":123,"openForm":11},"Security",{"_modelApiKey":17,"slug":124,"title":125},"security","Security at Commerce Layer",{"showTag":11,"_modelApiKey":12,"text":127,"label":128,"isExternal":11,"openForm":7,"form":129},"Giveback","Giveback program",{"_modelApiKey":55,"slug":130,"name":131},"giveback","GivebackForm",{"hasSubMenu":7,"title":133,"links":134},"Get in touch",[135,140,145,149],{"showTag":11,"_modelApiKey":12,"text":136,"isExternal":11,"openForm":7,"form":137},"Contact",{"_modelApiKey":55,"slug":138,"name":139},"contact","ContactUsForm",{"showTag":11,"_modelApiKey":12,"text":141,"isExternal":11,"openForm":7,"form":142},"Book a demo",{"_modelApiKey":55,"slug":143,"name":144},"demo","RequestDemoForm",{"showTag":11,"_modelApiKey":12,"text":146,"label":147,"isExternal":7,"url":148,"openForm":11},"Support","Email support","mailto:support@commercelayer.io",{"showTag":11,"_modelApiKey":12,"text":150,"label":151,"isExternal":7,"url":152,"openForm":11},"Community","Discord community","https:\u002F\u002Fdiscord.gg\u002Fcommercelayer",{"hasSubMenu":7,"title":154,"links":155},"Legal",[156,161,165,169,173],{"showTag":11,"_modelApiKey":12,"text":157,"label":158,"isExternal":7,"url":159,"openForm":11,"htmlClassNames":160},"Terms","Terms and conditions","\u002Flegal-embed\u002Fterms-of-service","iubenda-nostyle no-brand iubenda-noiframe iubenda-embed",{"showTag":11,"_modelApiKey":12,"text":162,"label":163,"isExternal":7,"url":164,"openForm":11,"htmlClassNames":160},"Privacy","Privacy policy","\u002Flegal-embed\u002Fprivacy-policy",{"showTag":11,"_modelApiKey":12,"text":166,"label":167,"isExternal":7,"url":168,"openForm":11,"htmlClassNames":160},"Cookies","Cookie policy","\u002Flegal-embed\u002Fcookie-policy",{"showTag":11,"_modelApiKey":12,"text":170,"isExternal":7,"url":171,"openForm":11,"htmlClassNames":172},"Notice at collection","#","iubenda-cs-uspr-link",{"showTag":11,"_modelApiKey":12,"text":174,"isExternal":7,"url":171,"openForm":11,"htmlClassNames":175},"Privacy preferences","iubenda-cs-preferences-link",[177,180,184,188,192],{"title":178,"type":179,"url":152,"isExternal":7},"Discord","discord-logo",{"title":181,"type":182,"url":183,"isExternal":7},"Github","github","https:\u002F\u002Fgithub.com\u002Fcommercelayer",{"title":185,"type":186,"url":187,"isExternal":7},"Bluesky","bluesky-logo","https:\u002F\u002Fbsky.app\u002Fprofile\u002Fcommercelayer.io",{"title":189,"type":190,"url":191,"isExternal":7},"X","x-logo","https:\u002F\u002Fx.com\u002Fcommercelayer",{"title":193,"type":194,"url":195,"isExternal":7},"LinkedIn","linkedin","https:\u002F\u002Fwww.linkedin.com\u002Fcompany\u002Fcommerce-layer",{"pagesWithoutCtaPanel":197,"ctaPanel":198,"notification":208,"showApiResponseTime":11,"newsletterSignup":216},[],{"title":199,"subtitle":200,"ctas":201},"Ready to get started?","Discover how we can help your business.",[202,205],{"_modelApiKey":203,"text":204,"isExternal":7,"url":75,"openForm":11},"link","Get started for free",{"_modelApiKey":203,"text":206,"isExternal":11,"openForm":7,"form":207},"Contact us",{"_modelApiKey":55,"slug":138,"name":139},{"showNotification":7,"link":209,"linkText":210,"text":215},{"_modelApiKey":203,"text":210,"isExternal":11,"link":211,"openForm":11},"Read article",{"_modelApiKey":212,"slug":213,"title":214},"blog_post","payment-api-redesigned","Introducing our new Payments API. For humans and agents.","\u003Cp>Introducing our new Payments API. For humans and agents.\u003C\u002Fp>\n",{"ctaText":217},"Subscribe",[219,225,229,236,240,246,249,253,261,262,267,272,274],{"_modelApiKey":55,"slug":220,"pardotFormEmbedCode":221,"formEmbedMinHeight":222,"successTitle":223,"successCopy":224},"agentic-commerce","https:\u002F\u002Fcommercelayer.fillout.com\u002Ft\u002F5w4Khwgxr6us?whitepaper=agentic",520,"Thank you for your request!","We’ll be in touch soon to arrange a date and time for your personalized demo.",{"_modelApiKey":55,"slug":226,"pardotFormEmbedCode":227,"formEmbedMinHeight":228,"successTitle":223,"successCopy":224},"shopify","https:\u002F\u002Fform.fillout.com\u002Ft\u002FgVnLSmKZwRus",850,{"_modelApiKey":55,"slug":130,"pardotFormEmbedCode":230,"formEmbedMinHeight":231,"displayTitle":232,"copy":233,"successTitle":234,"successCopy":235},"https:\u002F\u002Fform.fillout.com\u002Ft\u002FmVDF8aAiofus",500,"We give back.","\u003Cp>Part of Commerce Layer&#39;s company ethos is to empathize and support one another: co-workers, customers, and community. We want to do our part to help nonprofit organizations and small businesses who may feel adversely affected by the current global economic climate, and as a result, need in-kind support to reach their customers.\u003C\u002Fp>\n\n\u003Cp>If this general description matches your organization’s needs, please tell us your story by completing the following form so we can consider helping your cause.\u003C\u002Fp>\n","Thank you!","We will contact you soon to learn more about your story.",{"_modelApiKey":55,"slug":237,"pardotFormEmbedCode":227,"formEmbedMinHeight":228,"displayTitle":238,"copy":239},"book-an-onboarding-session","Book an onboarding session","\u003Cp>Schedule some time and our devs will help you set up a Commerce Layer + Sanity store.\u003C\u002Fp>\n",{"_modelApiKey":55,"slug":241,"pardotFormEmbedCode":242,"formEmbedMinHeight":243,"displayTitle":244,"successTitle":234,"successCopy":245},"download-our-whitepaper","https:\u002F\u002Fform.fillout.com\u002Ft\u002F5YPWmy8oT7us?whitepaper=ComposableCommerce",450,"Download our whitepaper.","Check your inbox. You should receive a download link soon.",{"_modelApiKey":55,"slug":247,"pardotFormEmbedCode":248,"formEmbedMinHeight":243,"displayTitle":244,"successTitle":234,"successCopy":245},"download-the-content-and-commerce-whitepaper","https:\u002F\u002Fform.fillout.com\u002Ft\u002F5YPWmy8oT7us?whitepaper=ContentAndCommerce",{"_modelApiKey":55,"slug":250,"pardotFormEmbedCode":251,"formEmbedMinHeight":243,"displayTitle":244,"copy":252,"successTitle":234,"successCopy":245},"whitepaper","https:\u002F\u002Fform.fillout.com\u002Ft\u002F5YPWmy8oT7us?whitepaper=Jamstack","\u003Cp>Commerce Layer is the perfect platform for building commerce on the Jamstack. Convert any design into pixel perfect HTML pages. Connect a best-of-breed headless CMS. Go serverless and forget the hassle of managing complex infrastructures.\u003C\u002Fp>\n",{"_modelApiKey":55,"slug":254,"pardotFormEmbedCode":255,"formEmbedMinHeight":256,"displayTitle":257,"copy":258,"successTitle":259,"successCopy":260},"contact-links","https:\u002F\u002Fform.fillout.com\u002Ft\u002FeWPyhHGHT7us",750,"Contact us.","\u003Cp>Tell us about your project. Our team will reach out to you for a personalized offer.\u003C\u002Fp>\n","Thanks for your message!","We’ll be in touch soon to discuss your project details.",{"_modelApiKey":55,"slug":138,"pardotFormEmbedCode":255,"formEmbedMinHeight":256,"displayTitle":257,"copy":258,"successTitle":259,"successCopy":260},{"_modelApiKey":55,"slug":263,"pardotFormEmbedCode":227,"formEmbedMinHeight":228,"displayTitle":264,"successTitle":265,"successCopy":266},"demo-embed","Want to see it in action? Request a demo.","Thanks for your request!","We’ll be in touch soon to arrange a date and time for your free live demo.",{"_modelApiKey":55,"slug":53,"pardotFormEmbedCode":268,"formEmbedMinHeight":228,"displayTitle":269,"copy":270,"successTitle":234,"successCopy":271},"https:\u002F\u002Fform.fillout.com\u002Ft\u002F9MTkDWMUSqus","Become our partner.","\u003Cp>Join us and get our guidance in helping your clients succeed. Our partners are our ambassadors. We are committed to your success as much as you are.\u003C\u002Fp>\n","We will contact you soon to discuss the details of our partnership.",{"_modelApiKey":55,"slug":273,"pardotFormEmbedCode":268,"formEmbedMinHeight":228,"displayTitle":269,"copy":270,"successTitle":234,"successCopy":271},"partners-embed",{"_modelApiKey":55,"slug":143,"pardotFormEmbedCode":227,"formEmbedMinHeight":228,"displayTitle":275,"copy":276,"successTitle":265,"successCopy":266},"Get a free live demo.","\u003Cp>Get a personalized demo and learn more about what Commerce Layer can do for your company.\u003C\u002Fp>\n",{"_modelApiKey":212,"link":278,"subtitle":283,"date":283,"author":284,"additionalAuthors":294,"icon":295,"abstract":296,"tag":297,"displayTitle":279,"cardRatio":300,"featured":11,"seoMetaTags":301,"layout":365,"blogPostCarousel":515,"_seoMetaTags":566,"authors":600},{"text":279,"isExternal":11,"url":280,"link":281},"How to build a dynamic pricing engine with Commerce Layer's External Prices API and ChatGPT.","",{"_modelApiKey":212,"slug":282},"how-to-build-dynamic-pricing-with-external-prices-api-chatgpt-ai","January 23, 2024",{"name":285,"picture":286},"Fabrizio Picca",{"url":287,"alt":288,"title":288,"width":289,"height":289,"format":290,"focalPoint":291,"customData":293},"https:\u002F\u002Fwww.datocms-assets.com\u002F35053\u002F1614875259-commercelayeravatarsquare113f26.png","Fabrizio Picca —      Partnerships Manager at Commerce Layer",1280,"png",{"x":292,"y":292},0.5,{},[],"robot","In this article, we use OpenAI's ChatGPT to generate prices for articles (SKUs) added to a cart.  To do this, we utilize Commerce Layer's External Prices API and custom logic to get prices based on criteria we provided to ChatGPT.",{"color":298,"name":299},"gray","Tutorials","portrait",[302,306,310,313,317,320,323,327,331,335,338,342,346,350,354,357,361],{"attributes":303,"tag":304,"content":305},null,"title","Optimize pricing using our External Prices API and ChatGPT",{"attributes":307,"tag":309,"content":303},{"property":308,"content":305},"og:title","meta",{"attributes":311,"tag":309,"content":303},{"name":312,"content":305},"twitter:title",{"attributes":314,"tag":309,"content":303},{"name":315,"content":316},"description","Learn how to optimize your pricing strategy using Commerce Layer's External Prices API and an AI-service like ChatGPT.",{"attributes":318,"tag":309,"content":303},{"property":319,"content":316},"og:description",{"attributes":321,"tag":309,"content":303},{"name":322,"content":316},"twitter:description",{"attributes":324,"tag":309,"content":303},{"property":325,"content":326},"og:image","https:\u002F\u002Fwww.datocms-assets.com\u002F35053\u002F1706010336-cl_chatgpt-ai-external-pricing-option-02.jpg?auto=format&fit=max&w=1200",{"attributes":328,"tag":309,"content":303},{"property":329,"content":330},"og:image:width","1200",{"attributes":332,"tag":309,"content":303},{"property":333,"content":334},"og:image:height","630",{"attributes":336,"tag":309,"content":303},{"name":337,"content":326},"twitter:image",{"attributes":339,"tag":309,"content":303},{"property":340,"content":341},"og:locale","en",{"attributes":343,"tag":309,"content":303},{"property":344,"content":345},"og:type","article",{"attributes":347,"tag":309,"content":303},{"property":348,"content":349},"og:site_name","Commerce Layer",{"attributes":351,"tag":309,"content":303},{"property":352,"content":353},"article:modified_time","2025-10-08T16:51:21Z",{"attributes":355,"tag":309,"content":303},{"property":356,"content":280},"article:publisher",{"attributes":358,"tag":309,"content":303},{"name":359,"content":360},"twitter:card","summary_large_image",{"attributes":362,"tag":309,"content":303},{"name":363,"content":364},"twitter:site","@commercelayer",[366,372,385,388,391,394,403,406,416,419,424,427,429,432,434,437,439,442,445,448,450,453,455,458,460,463,472,475,484,487,489,492,494,497,499,502,512],{"_modelApiKey":367,"copy":368,"listStyle":369,"darkTheme":11,"buttons":370,"color":371,"indent":7},"wysiwyg","\u003Cp>Dynamic pricing has been used by household names like Amazon, Uber, and Airbnb for years. Businesses shift prices in real time based on factors like demand, competitive landscape, or specific attributes of the product or service being sold. Take Airbnb’s case. Their prices are influenced by factors like seasonality; location, particularly related to other factors like an event (e.g. Paris 2024 Olympics); property size; and so on. However, the advent of AI introduces new possibilities for all brands to utilize dynamic pricing. Specifically, OpenAI&#39;s ChatGPT has revolutionized the way a business can implement a dynamic pricing strategy.\u003C\u002Fp>\n\n\u003Cp>Because of the abundance of AI solutions now flooding the market across all verticals, we are often asked how a merchant might use our platform to leverage AI in their digital ecommerce experiences. To kickstart that conversation, we put together this blog post as a demo that anyone can use to integrate AI with Commerce Layer. The tutorial uses our \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fdocs.commercelayer.io\u002Fcore\u002Fexternal-resources\u002Fexternal-prices\">External Prices\u003C\u002Fa> API and leverages ChatGPT for pricing data, and can be used to implement an AI-driven dynamic pricing strategy for your business.\u003C\u002Fp>\n\n\u003Ch3>The goal: Implementing an AI based price engine using Chat GPT\u003C\u002Fh3>\n\n\u003Cp>The goal of this tutorial is to use ChatGPT to generate prices for SKUs that are added to a shopping cart. To do this, we&#39;ll set up external pricing in Commerce Layer and write some custom logic that will be deployed in the cloud using \u003Ca href=\"https:\u002F\u002Fwww.deno.com\u002F\">Deno\u003C\u002Fa> Runtime. Our code will use ChatGPT to get prices based on criteria we&#39;ll specify later in this post in more detail.\u003C\u002Fp>\n\n\u003Cp>The idea is pretty simple: every time a product is added to an order in Commerce Layer, the following will happen:\u003C\u002Fp>\n\n\u003Col>\n\u003Cli>Commerce Layer will make a POST request to our external price engine, and the payload will contain the line item that has been added to the cart.\u003C\u002Fli>\n\u003Cli>The price engine will extract the SKU&#39;s \u003Ccode>price\u003C\u002Fcode> and \u003Ccode>compare at price\u003C\u002Fcode> with the currency and send that to ChatGPT via API for evaluation based on a prompt that explains what we need.\u003C\u002Fli>\n\u003Cli>The ChatGPT API will return data in the form of a JSON object that will be sent back to Commerce Layer according to the \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fdocs.commercelayer.io\u002Fcore\u002Fexternal-resources\u002Fexternal-prices\">External Prices\u003C\u002Fa> specification.\u003C\u002Fli>\n\u003C\u002Fol>\n","checkbox",[],"red",{"_modelApiKey":373,"border":11,"caption":374,"image":375,"size":384,"darkTheme":11,"rounded":7,"color":371},"image_block","Commerce Layer External Pricing with an AI-based pricing engine",{"url":376,"alt":377,"title":378,"width":379,"height":380,"format":381,"focalPoint":382,"customData":383},"https:\u002F\u002Fwww.datocms-assets.com\u002F35053\u002F1706006895-commerce-layer-external-pricing-with-an-ai-based-price-engine.jpeg","Commerce Layer's External Pricing API allows any external service to send prices to Commerce Layer. In this example, the pricing is generated by the AI-service ChatGPT","Commerce Layer's External Pricing API with an AI-based pricing engine",4296,930,"jpeg",{"x":292,"y":292},{},"standard",{"_modelApiKey":367,"copy":386,"listStyle":369,"darkTheme":11,"buttons":387,"color":371,"indent":11},"\u003Ch3>Requirements\u003C\u002Fh3>\n\n\u003Cp>Before we dive into the tutorial, let&#39;s make sure we have all the necessary requirements in place:\u003C\u002Fp>\n\n\u003Cul>\n\u003Cli>A Commerce Layer Account (you can create one for free at our main website landing page \u003Ca target=\"_blank\" href=\"http:\u002F\u002Fcommercelayer.io\u002F\">commercelayer.io\u003C\u002Fa>\u003C\u002Fli>\n\u003Cli>A paid subscription to ChatGPT (you need an API key to access OpenAI APIs, and that is available only to paid subscriptions)\u003C\u002Fli>\n\u003Cli>A Deno account to host our code. It&#39;s free. You can create one at \u003Ca href=\"https:\u002F\u002Fdeno.com\u002Fdeploy\">https:\u002F\u002Fdeno.com\u002Fdeploy\u003C\u002Fa>\u003C\u002Fli>\n\u003Cli>A development environment set up with Deno, OpenAI libraries, Commerce Layer \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fgithub.com\u002Fcommercelayer\u002Fcommercelayer-sdk\">SDK\u003C\u002Fa> + \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fgithub.com\u002Fcommercelayer\u002Fcommercelayer-cli\">CLI\u003C\u002Fa>, and an IDE. In this tutorial, I&#39;ll be using Visual Studio Code.\u003C\u002Fli>\n\u003C\u002Ful>\n",[],{"_modelApiKey":367,"copy":389,"listStyle":369,"darkTheme":11,"buttons":390,"color":371,"indent":11},"\u003Ch3>Step-by-Step Tutorial\u003C\u002Fh3>\n\n\u003Ch4>Step 1: Setting up Commerce Layer environment\u003C\u002Fh4>\n\n\u003Cp>If you don&#39;t have a Commerce Layer account, now is the right time to create one. You can create one for free (and it will \u003Cem>always\u003C\u002Fem> be free) \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fdashboard.commercelayer.io\u002Fsign_up\">here\u003C\u002Fa>. To create a Commerce Layer account, you don&#39;t need a credit card. You just need to provide your first and last name, your email, and a password.\u003C\u002Fp>\n\n\u003Cp>Now that you have an account, you can follow the \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fdocs.commercelayer.io\u002Fdevelopers\u002Fwelcome\u002Fonboarding-tutorial\">Onboarding Tutorial\u003C\u002Fa> that explains how to create an organization and seed it with test data. If you already have an account, you can use an existing organisation or create a new one. It&#39;s up to you.\u003C\u002Fp>\n\n\u003Cp>Assuming everything goes smoothly, at the end of this step, you will have:\u003C\u002Fp>\n\n\u003Cul>\n\u003Cli>A Commerce Layer account\u003C\u002Fli>\n\u003Cli>An organization with some data\u003C\u002Fli>\n\u003Cli>The Commerce Layer CLI installed on your computer\u003C\u002Fli>\n\u003C\u002Ful>\n",[],{"_modelApiKey":367,"copy":392,"listStyle":369,"darkTheme":11,"buttons":393,"color":371,"indent":11},"\u003Ch4>Step 2: Creating the price engine\u003C\u002Fh4>\n\n\u003Cp>As we mentioned in the previous section, we will use Deno as a runtime to run our price engine. Deno is an alternative to Node.js that is quite handy thanks to its cloud runtime, which allows deploying TypeScript files that contain a microservices implementation. It offers a lot of \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fdocs.deno.com\u002Fruntime\u002Fmanual\">useful documentation\u003C\u002Fa> explaining how to create, deploy, and run projects.\u003C\u002Fp>\n\n\u003Cp>The first step is to create a Deno account, and \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fdeno.com\u002Fdeploy\">you can do that for free\u003C\u002Fa>.\u003C\u002Fp>\n",[],{"_modelApiKey":373,"border":11,"caption":395,"image":396,"size":384,"darkTheme":11,"rounded":7,"color":371},"The Deno Dashboard",{"url":397,"alt":398,"title":395,"width":399,"height":400,"format":290,"focalPoint":401,"customData":402},"https:\u002F\u002Fwww.datocms-assets.com\u002F35053\u002F1706008042-deno-dashboard.png","This is the dashboard view of Deno, which will be used to build the AI-based pricing engine with Commerce Layer and OpenAI's ChatGPT.",3134,910,{"x":292,"y":292},{},{"_modelApiKey":367,"copy":404,"listStyle":369,"darkTheme":11,"buttons":405,"color":371,"indent":11},"\u003Cp>After login, you have to create a project using the empty template so we can begin implementing our price engine.\u003C\u002Fp>\n\n\u003Cp>The price engine will:\u003C\u002Fp>\n\n\u003Col>\n\u003Cli>Receive a POST from Commerce Layer containing the line item we want to assign a price.\u003C\u002Fli>\n\u003Cli>Contact OpenAI APIs and send a prompt to instruct the model and the data.\u003C\u002Fli>\n\u003Cli>Get the result.\u003C\u002Fli>\n\u003Cli>Respond to the original POST call according to Commerce Layer&#39;s \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fdocs.commercelayer.io\u002Fcore\u002Fexternal-resources\u002Fexternal-prices\">External Pricing specification\u003C\u002Fa>.\u003C\u002Fli>\n\u003C\u002Fol>\n",[],{"_modelApiKey":373,"border":11,"caption":407,"image":408,"size":384,"darkTheme":11,"rounded":7,"color":371},"Create an empty project on Deno.",{"url":409,"alt":410,"title":411,"width":412,"height":413,"format":290,"focalPoint":414,"customData":415},"https:\u002F\u002Fwww.datocms-assets.com\u002F35053\u002F1706008319-deno-create-an-empty-project.png","To create the Commerce Layer AI-based pricing engine, you need to create an empty project on the Deno Dashboard.","Create an empty project on Deno",3140,1604,{"x":292,"y":292},{},{"_modelApiKey":367,"copy":417,"listStyle":369,"darkTheme":11,"buttons":418,"color":371,"indent":11},"\u003Cp>Our example implements the service using a single TypeScript file. As you build yours, you will see a number of specific details when you&#39;re setting it up. For this blog, we don&#39;t list all of them out. But here are the key points:\u003C\u002Fp>\n\n\u003Cul>\n\u003Cli>We are using Application and Router resources from \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fdeno.land\u002Fx\u002Foak\">oak\u003C\u002Fa>, a middleware built on top of the Deno native HTTP server. This manages all the I\u002FO with Commerce Layer.\u003C\u002Fli>\n\u003Cli>The communication with OpenAI is managed using \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fdeno.land\u002Fx\u002Fopenai@v4.24.1\">the official OpenAI library for Deno\u003C\u002Fa>. As mentioned in the requirements section, a paid subscription is needed to access the OpenAI API, so make sure to create an API key following the \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fplatform.openai.com\u002Fdocs\u002Fquickstart\">OpenAI instructions to get one\u003C\u002Fa>.\u003C\u002Fli>\n\u003C\u002Ful>\n",[],{"_modelApiKey":420,"code":421,"showLineNumbers":11,"highlightLines":280,"language":422,"size":423},"code_block","import { Application, Router } from \"https:\u002F\u002Fdeno.land\u002Fx\u002Foak\u002Fmod.ts\";\nimport { oakCors } from \"https:\u002F\u002Fdeno.land\u002Fx\u002Fcors\u002Fmod.ts\";\nimport { OpenAI } from \"https:\u002F\u002Fdeno.land\u002Fx\u002Fopenai@v4.24.0\u002Fmod.ts\";\n\nconst app = new Application();\nconst router = new Router();\nconst ENDPOINT = \"\u002Fapi\u002Fv1\u002FaiPriceOptimisation\";\n\nconst aiClient = new OpenAI({\n  apiKey: \"\u003C\u003CYOUR API KEY HERE>>\",\n});\n\nconst prompt = `You are an AI based price optimisation system designed to output JSON objects. \n   I'm going to send you a JSON object with four attributes: \n   product_description (containing the description of the product I need the price for), \n   actual_price (the current price expressed in cents), \n   currency (the country I need this price for) \n   and finally compared_at_price (the previous price expressed in cents). \n   As a response I need you to suggest me a price for a product in the form of a json object \n   containing an attribute optimised_price, \n   this price should be in the range compared_at_price - actual_price and should be expressed in cents. \n   The price optimisation should be done based on the product description and the current economical context  optimising the profit.`;\n\nasync function getAIPrice(\n  description: string,\n  actualPrice: number,\n  compareAtAmount: number,\n  currency: string\n): Promise\u003Cnumber | null> {\n  const completion = await aiClient.chat.completions.create({\n    model: \"gpt-3.5-turbo-1106\",\n    response_format: { type: \"json_object\" },\n    messages: [\n      { role: \"system\", content: prompt },\n      {\n        role: \"user\",\n        content: JSON.stringify({\n          product_description: description,\n          compare_at_amount: compareAtAmount,\n          actual_price: actualPrice,\n          currency: currency,\n        }),\n      },\n    ],\n  });\n\n  if (completion.choices[0].message.content) {\n    const response = JSON.parse(completion.choices[0].message.content);\n    const optimisedPrice: number = response.optimised_price as number;\n\n    return optimisedPrice;\n  }\n\n  return null;\n}\n\nconst PORT = 3000;\nrouter.options(ENDPOINT, oakCors());\n\nrouter.post(ENDPOINT, oakCors(), async (conn) => {\n  if (!conn.request.hasBody) {\n    conn.throw(415);\n  }\n  console.log(\"request received\");\n  const body = await conn.request.body().value;\n  const description: string = body.data.attributes.name;\n  const currency: string = body.data.attributes.currency_code;\n  const actual_price: number = body.data.attributes.unit_amount_cents as number;\n  const compare_at_amount_cents: number = body.data.attributes\n    .compare_at_amount_cents as number;\n\n  const optimisedPrice = await getAIPrice(\n    description,\n    compare_at_amount_cents,\n    actual_price,\n    currency\n  );\n  conn.response.body = {\n    success: true,\n    data: {\n      sku_code: body.data.attributes.sku_code,\n      unit_amount_cents: optimisedPrice\n        ? optimisedPrice\n        : body.data.attributes.unit_amount_cents,\n    },\n  };\n});\n\napp.use(oakCors());\napp.use(router.routes());\napp.use(router.allowedMethods());\n\nconsole.log(`Server running on port ${PORT}`);\nawait app.listen({ port: PORT });","typescript","Standard",{"_modelApiKey":367,"copy":425,"listStyle":369,"darkTheme":11,"buttons":426,"color":371,"indent":11},"\u003Cp>Let’s analyze the main parts of the code to understand how it works.\u003C\u002Fp>\n\n\u003Cp>\u003Cstrong>The request handler\u003C\u002Fstrong>\u003C\u002Fp>\n\n\u003Cp>The oak middleware offers a very easy way to manage incoming POST requests. Each of them will be managed with the following code:\u003C\u002Fp>\n",[],{"_modelApiKey":420,"code":428,"showLineNumbers":11,"highlightLines":280,"language":422,"size":423},"router.post(ENDPOINT, oakCors(), async (conn) => {\n  if (!conn.request.hasBody) {\n    conn.throw(415);\n  }\n  console.log(\"request received\");\n  const body = await conn.request.body().value;\n  const description: string = body.data.attributes.name;\n  const currency: string = body.data.attributes.currency_code;\n  const actual_price: number = body.data.attributes.unit_amount_cents as number;\n  const compare_at_amount_cents: number = body.data.attributes\n    .compare_at_amount_cents as number;\n\n  const optimisedPrice = await getAIPrice(\n    description,\n    compare_at_amount_cents,\n    actual_price,\n    currency\n  );\n  conn.response.body = {\n    success: true,\n    data: {\n      sku_code: body.data.attributes.sku_code,\n      unit_amount_cents: optimisedPrice\n        ? optimisedPrice\n        : body.data.attributes.unit_amount_cents,\n    },\n  };\n});",{"_modelApiKey":367,"copy":430,"listStyle":369,"darkTheme":11,"buttons":431,"color":371,"indent":11},"\u003Cp>For each line item created, Commerce Layer will send a POST request containing a payload of the line item data. The handler extracts from the payload:\u003C\u002Fp>\n\n\u003Cul>\n\u003Cli>a product description\u003C\u002Fli>\n\u003Cli>the currency used in the transaction\u003C\u002Fli>\n\u003Cli>the actual price\u003C\u002Fli>\n\u003Cli>the &quot;compare at&quot; price\u003C\u002Fli>\n\u003C\u002Ful>\n\n\u003Cp>This data will be sent to OpenAI API by means of the \u003Ccode>getAIPrice\u003C\u002Fcode> helper function, wrapping OpenAI API calls.\u003C\u002Fp>\n\n\u003Cp>\u003Cstrong>Getting data from OpenAI API\u003C\u002Fstrong>\u003C\u002Fp>\n\n\u003Cp>The price engine makes use of OpenAI ChatGPT to dynamically assign a price to a line item. To do so we need to instruct ChatGPT what is required. First, create a prompt that states the scenario and initialise the connection with ChatGPT. Let’s take a look at the prompt:\u003C\u002Fp>\n",[],{"_modelApiKey":420,"code":433,"showLineNumbers":11,"highlightLines":280,"language":422,"size":423},"const prompt = `You are an AI based price optimisation system designed to output JSON objects. \n   I'm going to send you a JSON object with four attributes: \n   product_description (containing the description of the product I need the price for), \n   actual_price (the current price expressed in cents), \n   currency (the country I need this price for) \n   and finally compared_at_price (the previous price expressed in cents). \n   As a response I need you to suggest a price for a product in the form of a json object \n   containing an attribute optimised_price, \n   this price should be in the range compared_at_price - actual_price and should be expressed in cents. \n   The price optimization should be based on both the product description and any relevant economic factors in order to optimize the profit.`;",{"_modelApiKey":367,"copy":435,"listStyle":369,"darkTheme":11,"buttons":436,"color":371,"indent":11},"\u003Cp>Yeah, you are reading that correctly. You need to \u003Cem>tell\u003C\u002Fem> ChatGPT what you want it to do just as you would in a usual chat session. The only difference here is that you store the prompt in a variable, and then send it to initialise the chat session. The request is pretty simple: When we send a product description, a price range, and a currency, return a price that optimizes profit and considers any other economic factors.\u003C\u002Fp>\n\n\u003Cp>ℹ️  \u003Cstrong>Keep in mind that this is just a PoC. The data returned by this price engine is not accurate. You will want to use a proprietary AI engine that is trained with historical pricing data. Our example shows how tools might be used in a real world scenario.\u003C\u002Fstrong>\u003C\u002Fp>\n\n\u003Cp>Now, let’s see how this is implemented.\u003C\u002Fp>\n",[],{"_modelApiKey":420,"code":438,"showLineNumbers":11,"highlightLines":280,"language":422,"size":423},"async function getAIPrice(\n  description: string,\n  actualPrice: number,\n  compareAtAmount: number,\n  currency: string\n): Promise\u003Cnumber | null> {\n  const completion = await aiClient.chat.completions.create({\n    model: \"gpt-3.5-turbo-1106\",\n    response_format: { type: \"json_object\" },\n    messages: [\n      { role: \"system\", content: prompt },\n      {\n        role: \"user\",\n        content: JSON.stringify({\n          product_description: description,\n          compare_at_amount: compareAtAmount,\n          actual_price: actualPrice,\n          currency: currency,\n        }),\n      },\n    ],\n  });\n\n  if (completion.choices[0].message.content) {\n    const response = JSON.parse(completion.choices[0].message.content);\n    const optimisedPrice: number = response.optimised_price as number;\n\n    return optimisedPrice;\n  }\n\n  return null;\n}",{"_modelApiKey":367,"copy":440,"listStyle":369,"darkTheme":11,"buttons":441,"color":371,"indent":11},"\u003Cp>The task is completed by the \u003Ccode>aiClient.chat.completions.create\u003C\u002Fcode> method that takes the prompt, inputs data as parameters, and returns a result.\u003C\u002Fp>\n\n\u003Cp>As you can see, we are telling the OpenAI API which model we want to use, in our case, \u003Ccode>gpt-3.5-turbo-1106\u003C\u002Fcode>. We want this specific version because it allows us to receive a JSON object in response. You can see this by looking at the \u003Ccode>response_format: { type: &quot;json_object&quot; }\u003C\u002Fcode> property we are passing).\u003C\u002Fp>\n\n\u003Cp>Pretty straightforward, isn’t it? \u003C\u002Fp>\n\n\u003Cp>\u003Cstrong>Deploying our function in the cloud.\u003C\u002Fstrong>\u003C\u002Fp>\n\n\u003Cp>Now that we have the code, we just need to deploy it in the cloud. Deno will help us with its cloud runtime:\u003C\u002Fp>\n",[],{"_modelApiKey":420,"code":443,"showLineNumbers":11,"highlightLines":280,"language":444,"size":423},"deployctl deploy --project=posh-bobcat-82 service.ts","shell",{"_modelApiKey":367,"copy":446,"listStyle":369,"darkTheme":11,"buttons":447,"color":371,"indent":11},"\u003Cp>The \u003Ccode>deployctl\u003C\u002Fcode> command will input both the project at the beginning of this section and the TypeScript file we created. Please refer to \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fdocs.deno.com\u002Fdeploy\u002Fmanual\">Deno documentation for deployment instructions\u003C\u002Fa>.\u003C\u002Fp>\n\n\u003Cp>The result is the following:\u003C\u002Fp>\n",[],{"_modelApiKey":420,"code":449,"showLineNumbers":11,"highlightLines":280,"language":444,"size":423},"C11RFPMAC:ai-price-generator % deployctl deploy --project=posh-bobcat-82 service.ts\nℹ Using config file '\u002FUsers\u002Ffabriziopicca\u002FSites\u002Fai-price-generator\u002Fdeno.json'\n✔ Deploying to project posh-bobcat-82.\n✔ Entrypoint: \u002FUsers\u002Ffabriziopicca\u002FSites\u002Fai-price-generator\u002Fservice.ts\nℹ Uploading all files from the current dir (\u002FUsers\u002Ffabriziopicca\u002FSites\u002Fai-price-generator)\n✔ Found 4 assets.\n✔ Uploaded 1 new asset.\n✔ Preview deployment complete.\n\nView at:\n - https:\u002F\u002Fposh-bobcat-82-kz1amga83abq.deno.dev",{"_modelApiKey":367,"copy":451,"listStyle":369,"darkTheme":11,"buttons":452,"color":371,"indent":11},"\u003Cp>Our service is now deployed in the cloud at the address \u003Ccode>https:\u002F\u002Fposh-bobcat-82-kz1amga83abq.deno.dev\u003C\u002Fcode>.\u003C\u002Fp>\n\n\u003Cp>ℹ️  \u003Cstrong>Deno will add to the base url a deployment identifier (\u003Ccode>kz1amga83abq\u003C\u002Fcode>). This allows having multiple versions deployed of the same service. If the deployment identifier is not provided (\u003Ccode>https:\u002F\u002Fposh-bobcat-82.deno.dev\u003C\u002Fcode> ), Deno will point to the last deployment.\u003C\u002Fstrong>\u003C\u002Fp>\n\n\u003Cp>Now we need to configure External Pricing in Commerce Layer so that it will point to the new endpoint:\u003C\u002Fp>\n",[],{"_modelApiKey":420,"code":454,"showLineNumbers":11,"highlightLines":280,"language":444,"size":423},"https:\u002F\u002Fposh-bobcat-82-kz1amga83abq.deno.dev\u002Fapi\u002Fv1\u002FaiPriceOptimisation",{"_modelApiKey":367,"copy":456,"listStyle":369,"darkTheme":11,"buttons":457,"color":371,"indent":11},"\u003Cp>Note the full endpoint name. that results from the setup we did in the service code:\u003C\u002Fp>\n",[],{"_modelApiKey":420,"code":459,"showLineNumbers":11,"highlightLines":280,"language":422,"size":423},"const app = new Application();\nconst router = new Router();\nconst ENDPOINT = \"\u002Fapi\u002Fv1\u002FaiPriceOptimisation\";\n...\nconst PORT = 3000;\nrouter.options(ENDPOINT, oakCors());\n...\napp.use(oakCors());\napp.use(router.routes());\napp.use(router.allowedMethods());\n\nconsole.log(`Server running on port ${PORT}`);\nawait app.listen({ port: PORT });",{"_modelApiKey":367,"copy":461,"listStyle":369,"darkTheme":11,"buttons":462,"color":371,"indent":11},"\u003Ch4>Step 3: Setting up Commerce Layer\u003C\u002Fh4>\n\n\u003Cp>Now that we implemented our AI-powered price engine, it’s time to integrate it with Commerce Layer. Commerce Layer allows prices to be fetched from an external systems using (\u003Ca target=\"_blank\" href=\"https:\u002F\u002Fdocs.commercelayer.io\u002Fcore\u002Fexternal-resources\u002Fexternal-prices\">External Pricing\u003C\u002Fa>. It’s pretty simple. When a line item is created using the \u003Ccode>_external_price\u003C\u002Fcode> flag set to \u003Ccode>true\u003C\u002Fcode>, Commerce Layer will contact the endpoint set in the market configuration to get the price for the specific line item. In our case we are going to use our AI-powered price engine as the external price resource. Here’s what the configuration looks like:\u003C\u002Fp>\n\n\u003Cp>In the organization that we set up in the Commerce Layer Dashboard, go to \u003Ccode>Settings → Markets\u003C\u002Fcode>.\u003C\u002Fp>\n",[],{"_modelApiKey":373,"border":11,"caption":464,"image":465,"size":384,"darkTheme":11,"rounded":7,"color":371},"Commerce Layer Settings where you can find Markets",{"url":466,"alt":467,"title":464,"width":468,"height":469,"format":290,"focalPoint":470,"customData":471},"https:\u002F\u002Fwww.datocms-assets.com\u002F35053\u002F1706009344-commerce-layer-settings-where-you-can-find-markets.png","Go to Settings -> Markets to set up your endpoint.",2842,1972,{"x":292,"y":292},{},{"_modelApiKey":367,"copy":473,"listStyle":369,"darkTheme":11,"buttons":474,"color":371,"indent":11},"\u003Cp>In the Market configuration (USA in this case), add the endpoint created in the previous step:\u003C\u002Fp>\n",[],{"_modelApiKey":373,"border":11,"caption":476,"image":477,"size":384,"darkTheme":11,"rounded":7,"color":371},"Adding an External Prices URL to your Markets configuration",{"url":478,"alt":479,"title":476,"width":480,"height":481,"format":290,"focalPoint":482,"customData":483},"https:\u002F\u002Fwww.datocms-assets.com\u002F35053\u002F1706009450-add-the-endpoint-from-deno-to-your-market-configuration.png","Add the endpoint from Deno to your Market configuration",2820,1984,{"x":292,"y":292},{},{"_modelApiKey":367,"copy":485,"listStyle":369,"darkTheme":11,"buttons":486,"color":371,"indent":11},"\u003Cp>Hit save and the Commerce Layer configuration is done. That’s it! From this point on, Commerce Layer will delegate price definition to our endpoint if the \u003Ccode>_external_price=true\u003C\u002Fcode> is added when creating a line item.\u003C\u002Fp>\n\n\u003Ch4>Step 4: Putting everything together\u003C\u002Fh4>\n\n\u003Cp>It’s time to test the set up and see the final result. Open a terminal and fire up Commerce Layer CLI. In the onboarding phase, you should have created an application for the CLI. It’s time to use it! Using the CLI with a Sales Channel access token, first create an empty order:\u003C\u002Fp>\n",[],{"_modelApiKey":420,"code":488,"showLineNumbers":11,"highlightLines":280,"language":444,"size":423},"C11RFPMAC:~ % cl create order\n...\nSuccessfully created new resource of type orders with id gojhLmzVkM",{"_modelApiKey":367,"copy":490,"listStyle":369,"darkTheme":11,"buttons":491,"color":371,"indent":11},"\u003Cp>Now, add a \u003Ccode>line_item\u003C\u002Fcode> to our order asking CL to use the external price.\u003C\u002Fp>\n",[],{"_modelApiKey":420,"code":493,"showLineNumbers":11,"highlightLines":280,"language":444,"size":423},"C11RFPMAC:~ % cl create line_item -r order=gojhLmzVkM -a quantity=1 _external_price=true -r item=skus\u002FZALKSwrbNy\n...\nSuccessfully created new resource of type lineitems with id mnptRrrMzq",{"_modelApiKey":367,"copy":495,"listStyle":369,"darkTheme":11,"buttons":496,"color":371,"indent":11},"\u003Cp>This is where we hit the AI-powered price engine and get an optimized price. If we want to see the resulting price, open a checkout page for the newly created order:\u003C\u002Fp>\n",[],{"_modelApiKey":420,"code":498,"showLineNumbers":11,"highlightLines":280,"language":444,"size":423},"C11RFPMAC:~ % cl checkout -O gojhLmzVkM --open",{"_modelApiKey":367,"copy":500,"listStyle":369,"darkTheme":11,"buttons":501,"color":371,"indent":11},"\u003Cp>Commerce Layer Hosted Checkout will be displayed showing the optimized price of $105 for our SKU…that has a standard price of $96!\u003C\u002Fp>\n",[],{"_modelApiKey":373,"border":11,"caption":503,"image":504,"size":384,"darkTheme":11,"rounded":7,"color":371},"Commerce Layer's checkout page with an AI-powered price. In this example, it's powered by OpenAI's ChatGPT.",{"url":505,"alt":506,"title":507,"width":508,"height":509,"format":290,"focalPoint":510,"customData":511},"https:\u002F\u002Fwww.datocms-assets.com\u002F35053\u002F1706009581-commerce-layer-checkout-with-an-ai-powered-price.png","The image shows the Commerce Layer checkout with a price generated from an AI-service. In this example, it's OpenAI's ChatGPT.","Commerce Layer's checkout page with an AI-powered price",2864,2332,{"x":292,"y":292},{},{"_modelApiKey":367,"copy":513,"listStyle":369,"darkTheme":11,"buttons":514,"color":371,"indent":11},"\u003Ch3>Conclusion\u003C\u002Fh3>\n\n\u003Cp>You might be asking if this is Commerce Layer&#39;s &quot;AI-solution&quot; amid all the AI buzz? First, we’ll refer you to a post written by Commerce Layer’s CEO and Cofounder, Filippo Conforti. He wrote a blog titled \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fcommercefordevs.org\u002Fai-demystified\u002F\">AI Demystified\u003C\u002Fa>. He wrote the post based on his expertise from his master’s degree in computer science that focused on artificial intelligence. In his post, he largely covers two things:\u003C\u002Fp>\n\n\u003Col>\n\u003Cli>How AI works, and\u003C\u002Fli>\n\u003Cli>How it might be applied in ecommerce.\u003C\u002Fli>\n\u003C\u002Fol>\n\n\u003Cp>Filippo offers up this provocation toward the end of the post:\u003C\u002Fp>\n\n\u003Cp>\u003Cem>Ecommerce can greatly benefit from similarity search and generative AI, based on the same vector and machine learning principles described above. You can use AI to generate product descriptions, automate search, make recommendations, personalise shopping experiences, or engage in conversational commerce.\u003C\u002Fem>\u003C\u002Fp>\n\n\u003Cp>\u003Cem>All these use cases have one thing in common: they all manipulate content. While AI is capable of giving users immersive and innovative ways to discover products, it might not have the same impact when it comes to showing a price, the availability of a product, or managing a shopping cart.\u003C\u002Fem>\u003C\u002Fp>\n\n\u003Cp>\u003Cem>I believe AI-generated prices and promotions are already being used in some industries (such as the airline industry), but AI cannot generate stock that doesn&#39;t exist in a warehouse or manipulate credit card transactions. You might be able to use AI to optimise the risk assessment of a transaction, but not the transaction itself.\u003C\u002Fem>\u003C\u002Fp>\n\n\u003Cp>You should read the entire post to get a firm understanding of how Filippo reaches this conclusion. And, if you’re not following Filippo’s blog, \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fcommercefordevs.org\u002F\">Commerce for Devs\u003C\u002Fa>, give it a try. It’s a great source for anyone in the ecommerce field, even non-devs.\u003C\u002Fp>\n\n\u003Cp>In closing, Commerce Layer’s External Prices API combined with a price optimization AI (OpenAI&#39;s ChatGPT is probably not your best choice) opens up a world of possibilities right now for businesses to get the most out of their pricing strategies. By leveraging the power of our unopinionated, yet extensible API, and artificial intelligence, any merchant can take advantage of the tools that exist in the market to offer data-driven pricing that adapts to changing market conditions and customer behavior. One caveat: “Your mileage may vary”. We recommend that you carefully monitor whatever you put in place to ensure effectiveness and avoid any unintended consequences (our \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fdocs.commercelayer.io\u002Fmetrics\u002F\">Metrics API\u003C\u002Fa> can help you with that). With this approach, dynamic pricing with an AI-service focused on price optmizations can help you maximise profitability.\u003C\u002Fp>\n",[],{"displayTitle":516,"cta":303,"ctaText":280,"cards":517},"Your next read",[518,537,552],{"_modelApiKey":212,"link":519,"subtitle":523,"date":523,"author":524,"additionalAuthors":532,"icon":533,"abstract":534,"tag":535,"displayTitle":520,"cardRatio":300,"featured":536},{"text":520,"isExternal":11,"url":280,"link":521},"Getting started with Commerce Layer JavaScript SDK.",{"_modelApiKey":212,"slug":522},"getting-started-with-commerce-layer-javascript-sdk","April 14, 2022",{"name":525,"picture":526},"Bolaji Ayodeji",{"url":527,"alt":528,"title":528,"width":289,"height":289,"format":529,"focalPoint":530,"customData":531},"https:\u002F\u002Fwww.datocms-assets.com\u002F35053\u002F1643036479-bolaji.jpg","Bolaji Ayodeji — Developer Advocate at Commerce Layer","jpg",{"x":292,"y":292},{},[],"code-block","Commerce Layer provides a JavaScript SDK that makes it quick and easy for developers to interact with our commerce APIs. In this article, we’ll look at some fundamental technical details about how it works.",{"color":298,"name":299},0,{"_modelApiKey":212,"link":538,"subtitle":542,"date":542,"author":543,"additionalAuthors":547,"icon":548,"abstract":549,"tag":550,"displayTitle":539,"cardRatio":11,"featured":551},{"text":539,"isExternal":11,"url":280,"link":540},"How to build an external promotion using lambda functions.",{"_modelApiKey":212,"slug":541},"how-to-build-an-external-promotion-using-lambda-functions","July 15, 2022",{"name":285,"picture":544},{"url":287,"alt":288,"title":288,"width":289,"height":289,"format":290,"focalPoint":545,"customData":546},{"x":292,"y":292},{},[],"gift","This tutorial will give you a little taste of how powerful Commerce Layer external promotions feature is, by showing an example where we use an AWS Lambda function to trigger a special discount on a customer's birthday.",{"color":298,"name":299},1,{"_modelApiKey":212,"link":553,"subtitle":557,"date":557,"author":558,"additionalAuthors":562,"icon":563,"abstract":564,"tag":565,"displayTitle":554,"cardRatio":11,"featured":38},{"text":554,"isExternal":11,"url":280,"link":555},"A comprehensive guide to Commerce Layer webhooks.",{"_modelApiKey":212,"slug":556},"a-comprehensive-guide-to-commerce-layer-webhooks","June 9, 2022",{"name":525,"picture":559},{"url":527,"alt":528,"title":528,"width":289,"height":289,"format":529,"focalPoint":560,"customData":561},{"x":292,"y":292},{},[],"webhooks-logo","We provides a list of specific events you can monitor and transmit real-time data from using webhooks. In this article, we will introduce our webhooks mechanism and guide you through a couple of simple demo examples so that you can see it in action.",{"color":298,"name":299},[567,568,570,572,574,576,578,580,582,584,586,588,590,592,594,596,598],{"attributes":303,"tag":304,"content":305},{"attributes":569,"tag":309,"content":303},{"property":308,"content":305},{"attributes":571,"tag":309,"content":303},{"name":312,"content":305},{"attributes":573,"tag":309,"content":303},{"name":315,"content":316},{"attributes":575,"tag":309,"content":303},{"property":319,"content":316},{"attributes":577,"tag":309,"content":303},{"name":322,"content":316},{"attributes":579,"tag":309,"content":303},{"property":325,"content":326},{"attributes":581,"tag":309,"content":303},{"property":329,"content":330},{"attributes":583,"tag":309,"content":303},{"property":333,"content":334},{"attributes":585,"tag":309,"content":303},{"name":337,"content":326},{"attributes":587,"tag":309,"content":303},{"property":340,"content":341},{"attributes":589,"tag":309,"content":303},{"property":344,"content":345},{"attributes":591,"tag":309,"content":303},{"property":348,"content":349},{"attributes":593,"tag":309,"content":303},{"property":352,"content":353},{"attributes":595,"tag":309,"content":303},{"property":356,"content":280},{"attributes":597,"tag":309,"content":303},{"name":359,"content":360},{"attributes":599,"tag":309,"content":303},{"name":363,"content":364},[601],{"name":285,"picture":602},{"url":287,"alt":288,"title":288,"width":289,"height":289,"format":290,"focalPoint":603,"customData":604},{"x":292,"y":292},{},1790593726806]