<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Ralf Elfving</title>
    <description>The latest articles on Forem by Ralf Elfving (@ralfelfving).</description>
    <link>https://forem.com/ralfelfving</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F831229%2F9daa0459-4df3-4ec3-92f7-a3ab15cab96b.jpg</url>
      <title>Forem: Ralf Elfving</title>
      <link>https://forem.com/ralfelfving</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ralfelfving"/>
    <language>en</language>
    <item>
      <title>I asked GPT-4 to build a Shopify app. In an hour. And it did.</title>
      <dc:creator>Ralf Elfving</dc:creator>
      <pubDate>Sat, 25 Mar 2023 15:20:59 +0000</pubDate>
      <link>https://forem.com/ralfelfving/i-asked-gpt-4-to-build-a-shopify-app-in-an-hour-and-it-did-3gd6</link>
      <guid>https://forem.com/ralfelfving/i-asked-gpt-4-to-build-a-shopify-app-in-an-hour-and-it-did-3gd6</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;“You’re a helpful Shopify app developer assistant, helping to code Shopify apps.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That’s what I typed into the system field of GPT-4 before I copy/pasted a &lt;a href="https://docs.gadget.dev/guides/tutorials/automated-product-tagger#build-your-tagging-script"&gt;Shopify app tutorial&lt;/a&gt; from &lt;a href="https://gadget.dev/?utm_source=devto&amp;amp;utm_campaign=gpt4-built-an-app"&gt;Gadget.dev&lt;/a&gt; into the prompt. Then I added my question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“What other kind of Shopify app tutorials do you think you could build with Gadget using the example tutorial above? Give five reasonable Shopify app projects you think we could complete together in less than an hour.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I wanted to know if it could do it. I assume it could, but I wanted to find out for myself. I wanted to experience it. About an hour later, I had a complete Shopify app that updated a newly created customer segmentation metafield based on custom spending tiers whenever customers places an order.&lt;/p&gt;

&lt;h2&gt;
  
  
  Watch me.. erh.. GPT-4 code
&lt;/h2&gt;

&lt;p&gt;I recorded a video of me going from prompt to finished app. Don't worry, I fast forward over the segments where GPT-4 is responding or where I'm debugging. &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/T0fGYDFjF0g"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;There's some resources and a longer write-up linked in the video as well if you want to get more details. &lt;/p&gt;

&lt;h2&gt;
  
  
  Some learnings from using GPT-4 to code
&lt;/h2&gt;

&lt;p&gt;I'm not a very good developer. I just have ideas that are outside of my current experience, and available time. I learned that the importance to developing with GPT-4 is primarily two things.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Understanding what GPT-4 has context of, and what is unique to your circumstance that you need to feed it context about (in my case I used a new platform called Gadget)&lt;/li&gt;
&lt;li&gt;Knowing enough to debug, or how to identify bugs and feed back the errors to GPT-4 to iterate.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I'm hoping my experience can inspire others to try this or something similar out. Time box an hour, and try something new you'd normally need many hours to complete. I think you'd be surprised what you can achieve. &lt;/p&gt;

</description>
      <category>openai</category>
      <category>shopify</category>
      <category>javascript</category>
      <category>chatgpt</category>
    </item>
    <item>
      <title>Build a GPT3-powered Shopify app that generates product descriptions (15 min tutorial)</title>
      <dc:creator>Ralf Elfving</dc:creator>
      <pubDate>Thu, 05 Jan 2023 00:04:21 +0000</pubDate>
      <link>https://forem.com/ralfelfving/build-a-gpt3-powered-shopify-app-that-generates-product-descriptions-1b94</link>
      <guid>https://forem.com/ralfelfving/build-a-gpt3-powered-shopify-app-that-generates-product-descriptions-1b94</guid>
      <description>&lt;p&gt;While waiting for a flight during the holidays, I decided to create a Shopify app that automatically generate product descriptions using GPT3. It took just 30 minutes from idea to finished app.&lt;/p&gt;

&lt;p&gt;After I &lt;a href="https://www.linkedin.com/feed/update/urn:li:activity:7010677365039136768/" rel="noopener noreferrer"&gt;posted a short clip&lt;/a&gt; of the app on LinkedIn, a lot of people reached out asking if I could show them how I built it.&lt;br&gt;
So here it is, a step-by-step video tutorial with the code needed to build your own GPT3-powered Shopify product description generator app. &lt;/p&gt;

&lt;p&gt;It’ll take you just 15 minutes from scratch, half the time it took me :)&lt;/p&gt;

&lt;p&gt;Below you’ll find the video, the code file, and links to all the free services you’ll need to build it.&lt;/p&gt;
&lt;h2&gt;
  
  
  Video
&lt;/h2&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/czs-uxO8FYo"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Code file
&lt;/h2&gt;

&lt;p&gt;This is the Javascript code I use in my video, which you can use as is. If you’re using a different framework than Gadget to build your app you’ll need to make some adjustments.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { Configuration, OpenAIApi } = require("openai");

module.exports = async ({ api, record, params, logger, connections }) =&amp;gt; {

  const configuration = new Configuration({
    apiKey: process.env.OPENAI_API_KEY,
  });

  const openai = new OpenAIApi(configuration);
  let newProductDescription;
  let productTags = params.shopifyProduct.tags;

  // Only generate a GPT3 product description if the product tag 'GPT3' exists
  if (productTags.includes('GPT3')) {

    try {
      const completion = await openai.createCompletion({
        model: "text-davinci-002",
        prompt: `This is a Shopify product titled "${params.shopifyProduct.title}" with  description: ${params.shopifyProduct.body}. Please make the description more imaginative and attractive to potential buyers. Use text speaking to the buyer, include a sentance with made up facts that will impress them, and two scenarios of why they would want to own this product. Return the new description with HTML markup &amp;lt;p&amp;gt; for paragraphs and &amp;lt;br&amp;gt; for line breaks. Use at most 200 words.`,
        temperature: 0,
        max_tokens: 250,
        top_p: 1,
        frequency_penalty: 0.0,
        presence_penalty: 0.0
      });

      // Store the GPT3 product description
      newProductDescription = completion.data.choices[0].text;

    } catch (error) {
      if (error.response) {
        console.log(error.response.status);
      } else {
        console.log(error.message);
      }
    }

    // Remove the GPT3 tag from array of product tags
    productTags.splice(productTags.indexOf('GPT3'), 1);

    // Set up the Shopify connection and write the new product description, and remove the GPT3 product tag
    const shopify = await connections.shopify.current;
    if (shopify) {
      await shopify.product.update(record.id, { tags: productTags, body_html: newProductDescription });

      console.log(`Updated product description for product ID ${record.id} to: ${newProductDescription}`)
    }

  }

};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Links to services used (free to sign-up)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.gadget.dev/?utm_source=medium&amp;amp;utm_medium=organic&amp;amp;utm_campaign=gpt3" rel="noopener noreferrer"&gt;Gadget.dev&lt;/a&gt; (fully hosted Shopify app backend)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.openai.com/" rel="noopener noreferrer"&gt;OpenAI.com&lt;/a&gt; (OpenAI/GPT3 API keys)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.shopify.com/partners" rel="noopener noreferrer"&gt;Shopify.com/partners&lt;/a&gt; (Create development store and app)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.npmjs.com/package/openai" rel="noopener noreferrer"&gt;NPMJS.com&lt;/a&gt; (OpenAI NPM package)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://beta.openai.com/docs/api-reference/completions/create" rel="noopener noreferrer"&gt;OpenAI Create Completion documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope this video inspires you to try building something with Shopify and GPT3, and I’d love to hear what.&lt;br&gt;
If you have any questions about the video, or how to build Shopify apps, leave a comment on the video, or reach out on &lt;a href="https://twitter.com/ralfelfving" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/ralf-elfving/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;, or &lt;a href="https://discord.gg/nAfNKMdwKh" rel="noopener noreferrer"&gt;Discord&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Want to learn more about how you can build Shopify apps using Gadget?
&lt;/h2&gt;

&lt;p&gt;If you want to learn more about Gadget, the platform I used to power the Shopify app, here’s a few useful links.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;TL;DR: &lt;a href="https://docs.gadget.dev/guides/what-gadget-gives-you?utm_source=dev.to&amp;amp;utm_medium=organic&amp;amp;utm_campaign=gpt3"&gt;What’s Gadget?&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.gadget.dev/guides/tutorials?utm_source=dev.to&amp;amp;utm_medium=organic&amp;amp;utm_campaign=gpt3"&gt;End-to-end Shopify app tutorials&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Examples how Gadget has been used by &lt;a href="https://gadget.dev/blog/case-study-onelive?utm_source=dev.to&amp;amp;utm_medium=organic&amp;amp;utm_campaign=gpt3"&gt;Shopify Plus merchants&lt;/a&gt; and &lt;a href="https://gadget.dev/blog/case-study-media-carry?utm_source=dev.to&amp;amp;utm_medium=organic&amp;amp;utm_campaign=gpt3"&gt;Shopify agencies&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>emptystring</category>
    </item>
  </channel>
</rss>
