# Building a flow: a virtual AI editorial office

Nowadays it is possible to employ AI for writing blog posts, email letters and what not. But straightforward approach may give the result that is far from ideal. To fix this and boost the quality we're going to gather an AI team that will help us write captivating texts. The team will consist of two authors, a proofreader, and a leader, who will choose the final result.\
\
As an example, we'll take the case of writing a text about a consumer product. The text should be fit for the product website, marketing materials, and so on and so forth.

{% hint style="info" %}
[Video version](https://www.youtube.com/watch?v=01rg9fbKNKQ?utm_source=scade_gitbook\&amp;utm_medium=organic\&amp;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="/files/1FctURbD0ref8c9fqO24" alt=""><figcaption></figcaption></figure>

   <br>
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="/files/iB4mamWNjUc36FvF1YZN" alt=""><figcaption></figcaption></figure>

   <br>
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="/files/ZN8Gvgo95MzgkdcY4PAO" alt=""><figcaption></figcaption></figure>

   <br>
4. Add a field and name it `product`. We will put basic info about our product here. Don't forget to click the **Save** button<br>

   <figure><img src="/files/Pf9cbZvXDKLkahRJpJru" alt=""><figcaption></figcaption></figure>

   <br>
5. Return to the **User-Defined Input Form** node. Let's say, our product is a makeup kit for teenagers. Type the text "makeup kit for teens" into the **Product** input of the node<br>

   <figure><img src="/files/WQ4XDRT6Lzrsj4jvODNi" alt=""><figcaption></figcaption></figure>

   <br>
6. Hit the **Execute** button and then click **Save and execute** to run this node and generate the custom output.  We need it to move further.<br>

   <figure><img src="/files/X8ldTIiHl73tf2MVvyFH" alt=""><figcaption></figcaption></figure>

   <figure><img src="/files/vyYYw0ElEOuHOJfvO04S" alt=""><figcaption></figcaption></figure>

   <br>
7. Now let's start gathering our team. To hire the first author start typing `chatgpt processor` in the left panel and drag a **ChatGPT Processor** node to your workspace.<br>

   <figure><img src="/files/ls06XlE11kHc1RUYHyjq" alt=""><figcaption></figcaption></figure>

   <br>
8. Go to settings of the **ChatGPT Processor** node. \
   \
   You can choose ChatGPT versions with the **Model** dropdown. Let's choose gpt-4 for its advanced writing capabilities.<br>

   <figure><img src="/files/8GX28lh2lFHy4bLbJPZL" alt=""><figcaption></figcaption></figure>

   <br>
9. Now it's time to prepare ChatGPT for receiving instructions. In the settings, go to **Messages** section, click on a pencil and a new message<br>

   <figure><img src="/files/Ho3LaBPO4640ipWmt2O5" alt=""><figcaption></figcaption></figure>

   <figure><img src="/files/cnHkDvnlAYHauzaro7Do" alt=""><figcaption></figcaption></figure>

   \
   \
   Change the type of the message to `System` as recommended by OpenAI to emphasize that it's a high-level instruction and to guide the model's behaviour<br>

   <figure><img src="/files/BZkXzngYfxDtzkyE6s5D" alt=""><figcaption></figcaption></figure>

   <br>
10. Paste the text of your instruction to the **Message** field. \
    \
    Here's mine, you can modify it freely or come up with your own:\
    \
    `You are an experienced author of marketing texts who likes the most specific and meaningful pieces. You have presented hundreds of successful products.`

    `A client comes to you with a request. He needs to create a description of their product for a marketplace. The description should be brief, but able to catch customer's attention. Focus on the advantages of the product and the advantages of its use.`

    `2 scenarios are possible:`

    1. `if the client sends only the name of their product, then the description must be written fully from the very beginning;`
    2. `if the client sends a ready-made description, then it is only needed to correct it if necessary; all specific factual data about the product must be left unchanged.`

    `You should give only a description of the product as a result, without any introductory words.`<br>

    <figure><img src="/files/qz2SD28S33qcSo8rfkc4" alt=""><figcaption></figcaption></figure>

    <br>
11. We're not done here yet! We need to get data from the **User-Defined Input Form**. \
    \
    Add another message (there's no need to change the message type this time)<br>

    <figure><img src="/files/eUo5HHZxVELFR9hAE5TX" alt=""><figcaption></figcaption></figure>

    <br>
12. Here things will become a little bit tricky. Due to the syntax of the **ChatGPT Processor** node we will need to use **Expression editor**. \
    \
    Click on the **#** symbol in the lower **Message** field<br>

    <figure><img src="/files/iG74FG4cWlURFICvaqfQ" alt=""><figcaption></figcaption></figure>

    \
    \
    You'll get the **Expression editor**. There is a list of the nodes on the left. Click on the **User-Defined Input Form** to see its output<br>

    <figure><img src="/files/zf7vgMWUvmMDWgV1Kdp6" alt=""><figcaption></figcaption></figure>

    \
    \
    Drag the **product** output to the expression field<br>

    <figure><img src="/files/X7etkxVXu24ufCdB70y7" alt=""><figcaption></figcaption></figure>

    \
    \
    The result should look like this<br>

    <figure><img src="/files/BWvrM7egDYOzw3BrHtP4" alt=""><figcaption></figcaption></figure>

    \
    \
    Click the **Save** button in the **Expression editor** and don't forget to click top-right **Save** as well before leaving the settings<br>
13. Connect the output of your **User-Defined Input Form** and the input of the **ChatGPT Processor**.<br>

    <figure><img src="/files/SFZL47yka5jmkcpbgjql" alt=""><figcaption></figcaption></figure>

    \ <br>
14. We can add notes that help us to navigate through the flow and can store any additional info like comments. There will be two virtual writers, so in order to not mess things up let's add a note.\
    \
    Right-click on your workspace somewhere near to the **ChatGPT Processor** node and choose **Add note**<br>

    <figure><img src="/files/VsXLmksoDN5lOlJgxWnM" alt=""><figcaption></figcaption></figure>

    \
    \
    \
    As our instruction states, ChatGPT should assume a role of the author who values specific and meaningful texts the most. So let's write on the sticker something akin `Author #1: precise and specific` <br>

    <figure><img src="/files/toA8wYPis0iya94uh6yy" alt=""><figcaption></figcaption></figure>

    <br>
15. To add another author we should repeat basically the same actions:\
    \
    a. drag another **ChatGPT Processor** node to the workspace;\
    \
    b. connect the **product** output of the **User-Defined Input Form** with the input of this **ChatGPT Processor** node;\
    \
    c. go to the **Settings** of the node and change the model version (preferably);\
    \
    d. without leaving the **Settings**, add a message and change its type to `System`;\
    \
    e. paste the instruction for the second virtual author — obviously, it should be somehow different from the instruction given to the first author; for example, here's mine:\
    \
    `You are a brilliant marketing professional who makes short but vivid descriptions for any product. You have presented hundreds of successful products.`

    `A client comes to you with a request. He needs to create a description of their product for a marketplace. The description should be brief, but able to catch customer's attention. Focus on the advantages of the product and the advantages of its use.`

    `2 scenarios are possible:`

    1. `if the client sends only the name of their product, then the description must be written fully from the very beginning;`
    2. `if the client sends a ready-made description, then it is only needed to correct it if necessary; all specific factual data about the product must be left unchanged.`

    `You should give only a description of the product as a result, without any introductory words.`\
    \
    f. add another message and using the **Expression editor** refer to the data from the **User-Defined Input Form**;\
    \
    g. (optional) add a note about the second author.\
    \
    If you're a little lost, be sure to scroll this guide a little bit back. There are detailed instructions for all these actions starting from the guide item #7\
    \
    Your workspace should look like that at this point:<br>

    <figure><img src="/files/1wQkzkziXb9PsMxth7Xf" alt=""><figcaption></figcaption></figure>

    \
    \
    And the insides of the second **ChatGPT Processor** node — like that:<br>

    <figure><img src="/files/QzrG5AqQWPmnGHadH9v3" alt=""><figcaption></figcaption></figure>

    <figure><img src="/files/ZweC9dFxAoYciGI7K6tm" alt=""><figcaption></figcaption></figure>

    <br>
16. We need to run our workflow before moving any further. Hit the **Start** button on the top panel and choose **Save and execute** when prompted<br>

    <figure><img src="/files/wUly18xzmCTQ3EYkBg4f" alt=""><figcaption></figcaption></figure>

    <br>
17. Let's add a proofreader to check the generated texts and correct them if necessary. \
    \
    Yet again, it's more or less the same routine — refer to items 7-10 of this guide for the detailed description of the actions:\
    \
    a. add the third **ChatGPT Processor** to your workspace;\
    \
    b. connect the **Success** outputs of both "authors" to the input of this node;<br>

    <figure><img src="/files/SXI3LmAm5jFbOCIMJFQ4" alt=""><figcaption></figcaption></figure>

    \
    \
    c. change the model version in the settings to gpt-4;\
    \
    d. add a `System` message like that:<br>

    `You are a highly skilled proofreader. Your tasks are:`

    * `carefully read 2 product descriptions;`
    * `remove all spelling, punctuation or stylistic errors or inaccuracies from the text;`
    * `remove all dubious or incomprehensible comparisons;`
    * `remove excessive marketing cliches, make the text easy, understandable and pleasant;`
    * `be very strict in the selection of material, it is better to remove more than to leave bad material.`&#x20;

    \
    e. add another message and open the **Expression editor**; \
    \
    f. drag **success** outputs of both "author's" nodes to the expression field <br>

    <figure><img src="/files/PGaQWwW98e1cre8UdkGJ" alt=""><figcaption></figcaption></figure>

    \
    \
    g. place the expressions that you get on different lines and enumerate them<br>

    <figure><img src="/files/cehavuhcu4tCndoR1RH4" alt=""><figcaption></figcaption></figure>

    \
    Don't forget to save everything!<br>
18. Run the "proofreader" node by clicking the **Execute** button on it<br>

    <figure><img src="/files/9ZNAgod8WqrGchzBlvB8" alt=""><figcaption></figcaption></figure>

    <br>
19. And finally, let's bring in the product owner. It's their responsibility to choose the best text.\
    \
    It's **ChatGPT Processor** again, so please refer the guide starting from item #7 if needed\
    \
    a. add the fourth **ChatGPT Processor** to your workspace;\
    \
    b. connect the **Success** output of the "proofreader" node with the input of this node;\
    \
    c. change the model version in the settings to gpt-4;\
    \
    d. add a `System` message like that:\
    \
    `You are a successful seller of goods on the marketplace, the editor will now send you a description of the audience and 2 text options.`

    `Your task is to choose the best text that will increase your sales. The text should catch the audience as much as possible. Write out only the text itself. If suddenly there are errors or strange words in the final text, correct them.`\
    \
    e. add another message and using the **Expression editor** drag the **success** output of the third **ChatGPT Processor** to the expression field;<br>

    <figure><img src="/files/M4Snd1w78tr9rkJrAUQS" alt=""><figcaption></figcaption></figure>

    \
    \
    Make sure you've clicked the **Save** buttons!<br>
20. Hooray, let's see the choice. Hit the **Execute** button on the "product owner" node<br>

    <figure><img src="/files/lOgyFMB17TlrSFAOA5Ob" alt=""><figcaption></figcaption></figure>

    <br>
21. Nice! Now we can copy this final text and use it on our website, or as a product description on a marketplace<br>

    <figure><img src="/files/C9tPHlwvJuDGgyK6S5Dy" alt=""><figcaption></figcaption></figure>

    <br>

Once you have the workflow built, there's no need to run nodes one by one anymore. Simply change the **product** text in the **User-Defined Input Form** and use the **Start** button on the top bar

<figure><img src="/files/z5FDXjmL2V6tkUnz9YEi" alt=""><figcaption></figcaption></figure>


---

# 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-a-virtual-ai-editorial-office.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.
