Skip to main content

Code Block

A code block UI type is used to display a code block in AI chat. In your AI Agent builder you should response in output key with this format:

tip

Title and description are optional. If you need to display only code block data you can omit them.
Language should be in data.language field. Code should be in data.code field.
Generally, code should be a JSON stringified string, and in most cases AI Agent Node will return it in a right format.
So you can use it directly in data.code field, as {{ $json.code }}

output:

[
.... can be other ui types ...
{
"ui_type": "code_editor",
"title": "Example: Laravel Controller snippet",
"description": "Returning UI blocks from backend",
"data": {
"language": "php",
"code": "<?php\n\nreturn response()->json([\n 'blocks' => $uiBlocks,\n]);\n"
}
},
... can be other ui types ...
]

Result:

Code Block UI Type