Hi Erin,
You can do this by nesting block/statement/value/next/field elements inside your block ones. For example, if your go block has a statement input named A, you'd use:
<block type = "go">
<statement name = "A">
... statement block goes here ...
</statement>
</block>
If the foreach block attached to this statement input had a field named dropdown that started with a field value of water, it would look something like this:
<block type = "go">
<statement name = "A">
<block type = "foreach">
<field name = "dropdown">water</field>
</block>
</statement>
</block>
If this foreach block also had a move block connected to its statement input named "DO":
<block type = "go">
<statement name = "A">
<block type = "foreach">
<field name = "dropdown">water</field>
<statement name = "DO">
<block type = "move"></block>
</statement>
</block>
</statement>
</block>
If you know the blocks you want to nest in advance, an easy way to get the XML would be to use the Block factory at:
https://blockly-demo.appspot.com/static/demos/blockfactory/index.html . You can import the blocks that you're using, assemble the starter blocks you want to use and then export the resulting workspace, which would then be the string you'd provide to the Blockly.Xml.textToDom function.
You can also create/connect blocks and set field values programmatically instead of importing from XML:
const workspace = Blockly.getMainWorkspace();
const goBlock = workspace.newBlock("go");
const forEachBlock = workspace.newBlock("foreach");
const moveBlock = workspace.newBlock("move");
goBlock.initSvg();
forEachBlock.initSvg();
moveBlock.initSvg();
goBlock.getInput("A").connection.connect(forEachBlock.previousConnection);
forEachBlock.setFieldValue("water", "dropdown");
forEachBlock.getInput("DO").connection.connect(moveBlock.previousConnection);
workspace.render();
It's also possible to create and attach blocks randomly and randomly set field values by using block.inputList to get all of block's inputs and input.fieldRow to get all of input's fields. So if block referred to a foreach block from the above example, block.inputList[0].fieldRow[1].getOptions() might be used to get the list of options from the dropdown menu from which you could select a random option and block.inputList[1].connection might be the forEachBlock.getInput("DO").connection, which you could then use to connect another block. You could use information like this to set input value blocks/field values appropriately. Safety checks to see that the blocks "fit" together would be required as well.
Hope this helps. I can provide more details about programmatically setting up your workspace if you plan to do this.
Best,
Jason