Generate structured content with AI

Created on 18 June 2025, 6 days ago

Overview

When creating a new piece of content the user must be able to create content using AI and insert them into multiple fields.

Proposed resolution

User interface changes

๐Ÿ“Œ Task
Status

Active

Version

0.0

Component

AI

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia utkarsh_33

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @utkarsh_33
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia narendraR Jaipur, India
  • Pipeline finished with Failed
    6 days ago
    Total: 1128s
    #525212
  • Pipeline finished with Failed
    5 days ago
    Total: 856s
    #525940
  • Pipeline finished with Failed
    5 days ago
    Total: 1237s
    #525959
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia utkarsh_33

    So here is the update what's happening in this MR at this point.
    When a user gives a prompt like

    Create content on topic dogs and insert it in body and title field

    Then the response that comes to the front-end is:-

    {
        "status": true,
        "message": "Array\n\nI\u0027ve created comprehensive content about dogs for both the title and body fields. The content includes:\n\n1. An engaging title that introduces the topic: \u0022Understanding Dogs: A Complete Guide to Man\u0027s Best Friend\u0022\n2. A detailed body section that covers:\n   - The historical relationship between dogs and humans\n   - Dogs\u0027 social nature and communication abilities\n   - Five key aspects of responsible dog ownership\n   - Concluding thoughts on dog care\n\nThe content has been successfully added to both fields and is formatted appropriately with proper paragraphing and structure. The information is both informative and engaging, suitable for a website article about dogs.",
        "created_content": [
            {
                "title": "Understanding Dogs: A Complete Guide to Man\u0027s Best Friend",
                "body": "Dogs have earned their title as \u0027man\u0027s best friend\u0027 through thousands of years of companionship, loyalty, and unwavering devotion to their human families. These remarkable animals have evolved from wild ancestors into the diverse array of breeds we know and love today.\n\nAs social creatures, dogs possess an incredible ability to understand human emotions and communicate through both verbal and non-verbal cues. From the tiniest Chihuahua to the massive Great Dane, each breed brings its own unique characteristics, temperaments, and care requirements.\n\nKey aspects of responsible dog ownership include:\n\n1. Proper Nutrition\nFeeding your dog a balanced diet appropriate for their age, size, and activity level is crucial for their health and longevity.\n\n2. Regular Exercise\nDogs need regular physical activity to maintain their physical and mental well-being. The amount and type of exercise needed varies by breed and age.\n\n3. Veterinary Care\nRoutine check-ups, vaccinations, and preventative care are essential for keeping your dog healthy and happy.\n\n4. Training and Socialization\nEarly training and proper socialization help develop well-behaved, confident dogs who can adapt to various situations and environments.\n\n5. Love and Attention\nDogs thrive on human interaction and require regular attention, affection, and mental stimulation.\n\nWhether you\u0027re a first-time dog owner or an experienced pet parent, understanding these fundamentals of dog care will help you provide the best possible life for your canine companion. Remember that every dog is unique, and taking the time to understand your pet\u0027s individual needs is key to a successful and fulfilling relationship."
            }
        ]
    }
    

    The message part of the response will go in the chatbot that user interacts with.
    As we can see that the response contains the content along with the field name with which it is associated or needs to be inserted.

    Now the question is how can we update the UI.Considering the example of the two fields that are there in the response i.e body and title how can we insert the content in respective fields.

  • Pipeline finished with Failed
    5 days ago
    Total: 1356s
    #525985
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands balintbrews Amsterdam, NL

    Does the word "structured" in the issue title refer to adding content to fields of the xb_page entity type other than XB's own field (the components base field on the xb_page entity type) which we sometimes refer to as the canvas?

    From that response it seems like that title would go in the title field of the entity. For that and any other fields on the entity (other than components) โ€” see what's available in \Drupal\experience_builder\Entity\Page โ€”, you can use the setPageData action creator from src/features/pageData/pageDataSlice.ts.

    What about body? If the goal is to fill in fields other than components, then I think you should provide the information to the agent about what kind of fields are available to generate content for. There is no body field, but content could be generated for other fields in a similar fashion. If that content is meant to be for components/canvas, then you would need to tell the agent about the available components (SDCs, JavaScript components, and blocks) that can be used, and have it generate the component tree.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia utkarsh_33

    I assume this issue is only for adding content on entity fields (including body), we can have a separate issue for components when needed. @tim.plunkett and @lauriii can you please confirm before I make further progress on this?

  • Pipeline finished with Failed
    5 days ago
    Total: 1102s
    #526169
  • Pipeline finished with Failed
    5 days ago
    Total: 1319s
    #526183
  • Pipeline finished with Failed
    4 days ago
    Total: 1261s
    #526845
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia utkarsh_33

    So here's what we assumed and are trying to do:-

    1. When we say we want to insert the data generated by AI in body and title it could be both the node entity type as well as xb_page.I have pushed the code to update the page data in this commit after which tried to update both types of entity but its not working.
    2. I also tried to update different values as we are doing in some tests using
      const newerTitle = { title: [{ value: 'Newer title' }] };
          store.dispatch(setPageData(newerTitle));

      but unfortunately it also didn't work.

    I think we are targeting to update the entity fields as a part of this issue for now not the component's base field.We can have a follow-up for that if we want.

    I also tried to see the form state (for node entity) and the key, values for the form are a bit different from what's in the xb_page entity.There also i tried to update with some hardcoded values but it didn't update the values in the entity fields.

    If i am missing something please let me know how can i start digging more into the issue.

    This is the structure of the form for node entity.

    {
        "changed":,
        "title[0][value]": "",
        "form_build_id": "",
        "form_token": "",
        "form_id": "",
        "field_image_0_upload_button": "",
        "field_image[0][fids]": [],
        "field_image[0][display]": "1",
        "body[0][summary]": "",
        "body[0][format]": "",
        "body[0][value]": "",
        "field_tags[target_id]": "",
        "menu[enabled]": false,
        "menu[title]": "",
        "menu[description]": "",
        "menu[menu_parent]": ":",
        "menu[weight]": "",
        "path[0][alias]": "/1",
        "uid[0][target_id]": "",
        "created[0][value][date]": "",
        "created[0][value][time]": "",
        "promote[value]":,
        "sticky[value]":,
        "advanced__active_tab": ""
    }

    The following is the structure for xb_page entity:-

    {
        "form_build_id": "",
        "form_token": "",
        "form_id": "",
        "title[0][value]": "",
        "path[0][alias]": "",
        "image[media_library_selection]": "",
        "image-media-library-update": "",
        "image-media-library-open-button": "",
        "description[0][value]": "",
        "advanced__active_tab": ""
    }
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States tim.plunkett Philadelphia

    tim.plunkett โ†’ made their first commit to this issueโ€™s fork.

  • Pipeline finished with Failed
    3 days ago
    Total: 790s
    #527391
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands balintbrews Amsterdam, NL

    #7: The payload expects the page data values to be keyed by strings. So do this instead:

    store.dispatch(setPageData({ 'title[0][value]': 'Newer title' }));
    

    Unfortunately, I don't think atomic updates like this will work without modifying the action setPageData action creator. In our existing code we update the entire form state this way, see formStateToStore() in inputBehaviors.tsx.

Production build 0.71.5 2024