# Building a flow: create promo cards of a product

Let's see an example. We're going to create a workflow that turns a single product photo into several stunning promo cards. By following this guide step-by-step, you can understand the logic and process of creating this workflow

<figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2F0Ui4nZHQNoMBsJeNvFer%2Fstart_2%20copy.png?alt=media&#x26;token=597cc85b-182f-4083-bb95-0996cbfa4046" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
[Video version](https://www.youtube.com/watch?v=rwda4iubP9A?utm_source=scade_gitbook\&utm_medium=organic\&utm_campaign=default) of this tutorial is available as well
{% endhint %}

1. Go to the [Flow](https://app.scade.pro/flow) and click the "Create" button. <br>

   <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FiipowdyCRpqDzUF4RPC5%2FScreenshot%202024-01-26%20at%2015.35.13.png?alt=media&#x26;token=bc9efacc-ed2f-43b8-8267-294dc02b1ee1" alt=""><figcaption></figcaption></figure>

2. It's a good practice to store all your input data in a single node. Start by typing `user input` in the search bar of the left panel. Locate **User-Defined Input Form** and drag it to the workspace.<br>

   <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FS0z0zL74DmZCSeEqjvBu%2FScreenshot%202024-01-24%20at%2022.27.35.png?alt=media&#x26;token=30f5c7bd-fe86-41a6-a2cd-e0e92913e224" alt=""><figcaption></figcaption></figure>

3. This node has no pre-configured fields, so we should set them ourselves. Dive into the node’s settings and select **Configure Fields**. <br>

   <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2F3cNnicgr9438zWVgyoq8%2FScreenshot%202024-01-24%20at%2022.39.01.png?alt=media&#x26;token=0188cba8-df1e-48aa-94d3-278c44934d38" alt=""><figcaption></figcaption></figure>

4. Add a field to store the input image. Let's name this field `image` and also change the type to **String / URI** to make it suitable for storing files.<br>

   <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FRRaQ5CA0nWCkg0Sti94m%2FScreenshot%202024-01-24%20at%2022.42.41.png?alt=media&#x26;token=d38702ec-1c07-43ff-ae95-1226d00e9c7e" alt=""><figcaption></figcaption></figure>

5. Let's add another field. I'm going to use **ChatGPT** to help me with the promo cards generation, so we will need the prompt for ChatGPT. Name this field `prompt`. This name is important in our case, so be careful. <br>

   <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2F0Vf80d5I8t1o78RvW71d%2FScreenshot%202024-01-30%20at%2010.20.03.png?alt=media&#x26;token=241001d5-d24d-4839-b618-a69e57e5051b" alt=""><figcaption></figcaption></figure>

   \
   After saving these changes, return to your **User-Defined Input Form** node. <br>

6. Upload your image and add instructions for ChatGPT. <br>

   <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2Fh1LKNM3NpJttsCDwvBE8%2FScreenshot%202024-01-30%20at%2009.00.15.png?alt=media&#x26;token=0847c563-361e-4920-9323-00673fb8aecc" alt=""><figcaption></figcaption></figure>

   \
   Here is my image:<br>

   <div align="left"><figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FE3rVknWNrDP6nV5Vzh0a%2Fshmp.png?alt=media&#x26;token=fd171b2b-d02e-4631-b967-2355d387aaf9" alt="" width="375"><figcaption></figcaption></figure></div>

   And here is my prompt:\
   \
   `Create a prompt for an image generation AI (like Midjourney) featuring a trendy shampoo bottle with a tropical texture background, natural shadows of the bottle. The prompt should only contain a description of the desired image and no commands like ‘create an image’. Describe the style as much as possible, write the prompt with the premise that the image should be cinematic and promotional. The output should not contain any additional words and headlines other than the prompt itself. The prompt should be no longer than 50 words.`\
   \
   Feel free to modify the input data as much as you like or use your own.<br>

7. Hit the **Execute** button and then click **Save and execute** to run this node and generate outputs. We need them to move further.<br>

   <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FF75f87DWxZ4NCyQ71vor%2FScreenshot%202024-01-24%20at%2023.04.47.png?alt=media&#x26;token=d2589cc2-9494-4b0a-afe9-67e9952af2e1" alt=""><figcaption></figcaption></figure>

   \ <br>

   <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FghhCztuNZJhbzBypjKvV%2FScreenshot%202024-01-24%20at%2023.07.02.png?alt=media&#x26;token=df5b7e99-7d69-4773-af60-d79aa114011f" alt=""><figcaption></figcaption></figure>

   <br>

8. Now, we want our image background to be transparent, not white. Not only can we use the search bar in the left panel, we can also just right-click on the workspace as well. Choose **Add processor**. <br>

   <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FgRpzgPDJ4NPZMyBnz94m%2FScreenshot%202024-01-24%20at%2023.11.55.png?alt=media&#x26;token=1191e695-f84a-4b61-ab31-005da73d4eb2" alt=""><figcaption></figcaption></figure>

   \
   \
   We want to remove the background, so start typing `remove` in the search bar. As you can see, you don't even have to finish the sentence: several models are already suggested. If you know what you need, just pick the model. In another case, you can rely on the description. Try and test different models.<br>

   <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2F6Q1NcdSMr3WCpBS8PXIB%2FScreenshot%202024-01-24%20at%2023.18.26.png?alt=media&#x26;token=52662cfa-9f15-4628-ba96-5f6b0374d852" alt=""><figcaption></figcaption></figure>

   \
   \
   We’ll use **Rembg** in this workflow.<br>

9. After adding **Rembg** to your workspace, access its settings. Enable the **Show on Node** to make the input appear on the node. <br>

   <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FRMVrmd2ASo9Fuz590q5V%2FScreenshot%202024-01-24%20at%2023.39.07.png?alt=media&#x26;token=bce08236-b371-4278-9293-7906803f0a25" alt=""><figcaption></figcaption></figure>

   \
   \
   Next, connect the **image** output of your **User-Defined Input Form** node to the **Image** input of your **Rembg** node. <br>

   <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FCW9XdDmztL8hJxQBrn8A%2FScreenshot%202024-01-24%20at%2023.32.23.png?alt=media&#x26;token=930bfb03-6d8f-428b-bf43-9226c4796a70" alt=""><figcaption></figcaption></figure>

   <br>

10. Now, let's add some magic. Right-click on the workspace, choose **Add processor** again and search for the Ad-inpaint processor: type `ad-inpaint` in the search bar. \
    \
    This model uses your image and your text prompt as the input data and generates promo cards.\
    \
    Connect the output of your **Rembg** node with the **Image Path** input of your **Ad-inpaint** node. <br>

    <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FMJsr3NSrtSe2AVZbHxfh%2FScreenshot%202024-01-24%20at%2023.44.09.png?alt=media&#x26;token=a53f3ada-d0c6-448b-8cd8-0c1f31abf521" alt=""><figcaption></figcaption></figure>

    <br>

11. By default there will only be one promo card, but I want three. Let's go to the **Ad-inpaint** settings and increase the **Image Num** field to 3. \
    \
    You can increase it even further, but remember that this will also increase the execution time. Simply close this menu after you're all set.<br>

    <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FCsaBs3ijpfpOqs2ggJeg%2FScreenshot%202024-01-24%20at%2023.48.47.png?alt=media&#x26;token=5c1b3b0c-58ad-4179-a3f5-da74c82c334a" alt=""><figcaption></figcaption></figure>

    <br>

12. Next, we are going to use ChatGPT to generate a creative background description for Ad-inpaint. \
    \
    Add a **ChatGPT Processor** node to your workspace. You again can do it by using the search bar of the left pannel (right-clicking on the workspace and adding a processor works as well). Type `chatgpt`, and scroll a little if you don't see the desired processor right away.\ <br>

    <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FqnAcjKaxWCtKtqy80dPt%2FScreenshot%202024-01-30%20at%2010.48.07.png?alt=media&#x26;token=12fb349e-4655-45ff-a8af-be249501c21f" alt=""><figcaption></figcaption></figure>

    \
    \
    Connect the **prompt** output of your **User-Defined Input Form** node to the input of your **ChatGPT Processor** node. \ <br>

    <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FGTPuhZdPA8QRGzx94z20%2FScreenshot%202024-01-30%20at%2010.53.45.png?alt=media&#x26;token=dc848473-00c1-4323-ad0f-87a717ca106d" alt=""><figcaption></figcaption></figure>

    <br>

13. Handling **ChatGPT Processor** may be slightly more complex due to the syntax of the node. You'll need to refer to the prompt from your **User-Defined Input** node as a variable. \
    \
    First, open the settings of your **User-Defined Input Form** node and copy the **Node ID**.<br>

    <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FR3pfbQz2iKG6B3dFV6eh%2FScreenshot%202024-01-24%20at%2023.52.25.png?alt=media&#x26;token=9bf0ae17-e461-4453-8ed9-c827f95d64f1" alt=""><figcaption></figcaption></figure>

    \
    \
    Second, go to the **ChatGPT Processor** settings, proceed to **Messages**. Click on the pencil and add a new message.<br>

    <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2F0hKb4RoufHPiPM5fSbkB%2FScreenshot%202024-01-24%20at%2023.57.34.png?alt=media&#x26;token=5868ed05-c997-40ca-9d77-83cddb994dbc" alt=""><figcaption></figcaption></figure>

    \
    Use the **Node ID** that you've just copied and write a line like this into the field:\
    \
    `{{context["7yHF-user-input"]["prompt"]}}`\
    \
    In place of `7yHF-user-input` there should be the **ID** of your **User-Defined Input Form**.\
    \
    Don't forget to save the message!<br>

    <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FlWEr5GVDcDhm1qd1Z2Jz%2FScreenshot%202024-01-25%20at%2000.03.34.png?alt=media&#x26;token=b6dc7c89-f774-4f30-8866-4c25b2d2090d" alt=""><figcaption></figcaption></figure>

    \
    \&#xNAN;*Or alternatively, you can use the **Expression editor**. We'll talk about this method later.*\
    \
    By the way, you can also change the ChatGPT version, use the **Model** option in the settings.<br>

    <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FFPxHy9JxRiPHZtlm933Q%2FScreenshot%202024-01-25%20at%2000.14.01.png?alt=media&#x26;token=d96090aa-634b-416b-9b02-14034817cfe7" alt=""><figcaption></figcaption></figure>

    \
    \
    Connect the **Success** output of your **ChatGPT** node to the **Prompt** input of your **Ad-inpaint node**. \ <br>

14. Run your workflow by clicking **Play** in the top toolbar. Choose **Save and execute** when asked.<br>

    <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2F6xz6xYjGF7nilScklBGW%2FScreenshot%202024-01-25%20at%2000.17.54.png?alt=media&#x26;token=89a0ba85-730b-41e2-af88-7df1456121e1" alt=""><figcaption></figcaption></figure>

15. After running the workflow, a generated prompt will appear in the **ChatGPT** node describing the image background to generate a beautiful card. <br>

    <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FYYpDD0kR8mId2zNhVe3l%2FScreenshot%202024-01-25%20at%2000.21.14.png?alt=media&#x26;token=f24c8767-4d9a-4be7-b808-7421cdfd1730" alt=""><figcaption></figcaption></figure>

    \
    \
    Following the execution, the **Ad-inpaint** node will display four pictures: the original image and three photos of the product with generated backgrounds.<br>

    <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FF8dKHHer7m0JnjrJ2GuN%2FScreenshot%202024-01-25%20at%2000.38.38.png?alt=media&#x26;token=c3ec67bc-261b-48a4-94a9-550f76452c43" alt=""><figcaption></figcaption></figure>

    <br>

16. The images already have good resolution, but, say, we want to upscale one of them anyway. Let's add a **Gfpgan** node — this model is widely used for improving image quality and upscaling. \
    \
    Again, you can get **Gfpgan** by using the left panel or by right-clicking on the workspace, type `gfpgan` in the search bar.\
    \
    Connect the output of your **Ad-inpaint** node and the Input of your **Gfpgan** node. <br>

    <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2F1aaxB561OCfZvfqPH48P%2FScreenshot%202024-01-30%20at%2011.44.17.png?alt=media&#x26;token=309ad9d8-dfec-4022-ac7c-632f348e78e1" alt=""><figcaption></figcaption></figure>

    <br>

17. As the **Ad-inpaint** doesn't display four images as separate outputs, you have to use variables again. \
    \
    In the **Gfpgan's** settings, change the **Img** input type to **Expression**. <br>

    <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FsK7X6S7QAb6OnIXkfXZp%2FScreenshot%202024-01-25%20at%2000.45.20.png?alt=media&#x26;token=309860d2-fc30-4657-b70c-a6eb68f76e42" alt=""><figcaption></figcaption></figure>

    \
    \
    Next, click on the hash to open the **Expression editor**. <br>

    <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FTnMjUKEGwSbTHYzk9zkp%2FScreenshot%202024-01-30%20at%2011.48.12.png?alt=media&#x26;token=8ec6448f-d903-4eac-b5f0-a0bd7efb4eb6" alt=""><figcaption></figcaption></figure>

    \
    \
    Here you’ll see a list of nodes on the left. Find and open the **Ad-inpaint** node and click **Success**. This section represents all images that you can see on the **Ad-Inpaint** node: \
    \
    \- 0 is the source image and is located in the top-left of the node;\
    \- 1 is the top-right generated image; \
    \- 2 is the left-bottom one; \
    \- 3 is the right-bottom image.<br>

    <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FSEvciUoDrxe54YtxzoWo%2FScreenshot%202024-01-25%20at%2000.46.45.png?alt=media&#x26;token=f841d2e1-0e7c-4ff8-9b7b-f236a79d3f8d" alt=""><figcaption></figcaption></figure>

    \
    \
    Drag your desired image from the **Success** section into the editor field. <br>

    <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FX5Bqu7U0UDX1QpN9siKe%2FScreenshot%202024-01-30%20at%2011.57.28.png?alt=media&#x26;token=36ca2737-ce54-44eb-a5d4-c957d7be5095" alt=""><figcaption></figcaption></figure>

    \
    \
    \
    Now, run **Gfpgan** by clicking **Execute** on the node.  And there you have it! A high-resolution photo appears in the **Gfpgan** node.<br>

    <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2Fyl7e6no6YRREKQypwvxG%2FScreenshot%202024-01-25%20at%2000.49.15.png?alt=media&#x26;token=d108bcb1-779c-4713-bd3b-e3793dee681b" alt=""><figcaption></figcaption></figure>

    <br>

18. Extra actions are available by hovering over images: preview the image or download it<br>

    <figure><img src="https://2793209830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNCrOWKpBlXYnNB9SFIzb%2Fuploads%2FJkkAn8lLXMkdqLqSgBx7%2FScreenshot%202024-01-30%20at%2013.29.50.png?alt=media&#x26;token=a03636b1-a8ae-4228-8ddb-23e3a40cc0fb" alt=""><figcaption></figcaption></figure>

You can integrate this workflow to your product via API. [Contact us](mailto:support@scade.pro) to get access, documentation and support

\ <br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://scade.gitbook.io/scade-knowledge-base/flow-examples/building-a-flow-create-promo-cards-of-a-product.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
