Skip to main content

Tree Examples – Various

Work in Progress - Relation Value

Widget

Used model: V-gemma-4-26B-A4B-it-UD-Q4_K_M

Make sure to use a model that can follow instructions and produce valid structured JSON responses. Otherwise, the behavior may fail silently.

Widget

Code for Widget -> Advanced -> Import Widget:

{"Name":"Exported Widget","Description":"","Export":{"UserWidget":{"BaseWidgetId":"1ab444f4-aa05-4ba2-bc5c-2728b6e02bc0","BaseWidgetType":5,"IsLocked":false,"IsHidden":false,"IsNotInteractable":false,"IsForeground":false,"IsMaximized":false,"PositionData":{"Top":0.0,"Left":0.0},"SizeData":{"Height":500.0,"Width":750.0},"IsTransparent":true,"FileUri":null,"StoreType":1,"GameType":0,"IsNotConfigurable":false,"TtsOptionsFlag":0,"UserWidgetConfig":{"FileUri":null,"RenderFps":30,"BehaviorFps":30,"EnergyMode":0,"LoadModelMode":0,"MilliSecondsToPause":14000,"IsSoundAmbientEnabled":false,"IsUiHideOnPauseEnabled":false,"IsPixelArt":false,"UseSyntaxHighlighting":false,"IsMarkdownDisabled":false,"BackgroundType":1,"EffectsFlag":0,"TextOptionsFlag":1332,"BackgroundColor":"#FF000000","BackgroundId":null,"BackgroundFileEnding":null,"PanelTextSize":1.0,"PanelFontName":"Verdana","PanelPrimaryColor":"#E69C3230","PanelHighlightColor":"#E6FED33F","PanelTextColor":"#E6FFFFFF","PanelBackgroundColor":"#C8000000","AmbientColor":"#FFFFFFFF","LastConversationId":null,"AgentConfig":[{"AgentId":"82bdca18-942c-4b65-b68a-9d9272397f1f","Properties":{"Scale":1.0,"FlipX":false,"XF":0.5,"YF":0.5,"Transparency":0.0}}],"UiPanelConfig":[{"Id":"521f972e-7107-498a-a2d2-a9995e3641e2","Properties":{"Width":600,"Height":400,"XF":0.5,"YF":0.25,"IsNotVisible":false,"AvatarSize":0},"UiPanel":{"PanelType":3,"Name":"Simple Chat History Panel","Filter":[]}},{"Id":"c93e2fdc-7c27-4bfd-94ac-46f3b556f173","Properties":{"Width":500,"Height":100,"XF":0.5,"YF":0.8,"IsNotVisible":false,"HasVisibleButtons":false,"IsEventOnly":true},"UiPanel":{"PanelType":2,"PromptType":1,"Name":"Simple Text Input Panel","Filter":[]}},{"Id":"3797f997-c917-4f1b-9181-fa6590608802","Properties":{"Width":120,"Height":50,"XF":0.1,"YF":0.2,"IsNotVisible":false,"Scale":1,"Text":"State: {{currentState}}{{NEWLINE}}Value: {{currentValue}}","Value":"","UpdateRateMs":1000},"UiPanel":{"PanelType":5,"Name":"General Text Panel","Filter":[]}}],"AdditionalData":"","LoadedSidePanelHistoryEntries":5,"HideConversationStarters":false},"Id":"df0db081-e2de-422d-b1d8-3c9c9d231977","NewerVersionId":null,"DependencyId":null,"Name":"Lightweight Widget","Description":"","Author":"","Version":1,"Url":"","Tags":null,"CreatedDate":"2026-06-12T20:00:07.6112701+02:00","LastUpdatedDate":null},"Agents":[{"FileUri":null,"StoreType":1,"PromptId":"c7b8de90-f6f4-4606-9838-af66392852bc","TextModelId":"d565ea01-3549-4eb7-8193-00e298afb526","TextModelIdOverride":"00000000-0000-0000-0000-000000000000","PresetId":"189d9d10-c738-4c56-89c9-3740c2e85306","FaceType":1,"FaceId":"4fcd75a9-19a4-4883-8f66-3d5fbbc6d0fb","IsHidden":false,"DefaultAnimationId":null,"DefaultExpressionId":null,"DefaultExpressionStrength":0.25,"DefaultHiddenObjects":null,"IncludedAnimations":null,"BehaviorTreesConfig":"[{\"id\":\"1baedd88-e3db-4ed3-8d57-542c0d24b7d1\",\"name\":\"\",\"type\":\"RunAllComposite\",\"children\":[{\"id\":\"57dc3535-3c9f-4ad4-ad18-390d06a7d645\",\"name\":\"\",\"type\":\"RepeatDecorator\",\"children\":[{\"id\":\"0f5c47d0-ee9c-466f-8946-bf5dc28448fd\",\"name\":\"\",\"type\":\"SequenceComposite\",\"children\":[{\"id\":\"cd6bde23-fa67-4e52-98c1-99cf419208d1\",\"name\":\"\",\"type\":\"SetDynamicTokenAction\",\"children\":[],\"properties\":{\"tokenId\":\"currentState\",\"text\":\"neutral\",\"setGlobal\":false},\"isDisabled\":false},{\"id\":\"9b1fc463-d52f-4b61-9ea8-f325ea0e1c1e\",\"name\":\"\",\"type\":\"SetDynamicTokenAction\",\"children\":[],\"properties\":{\"tokenId\":\"currentValue\",\"text\":\"0\",\"setGlobal\":false},\"isDisabled\":false},{\"id\":\"0bd9bd4a-7663-496c-9e52-546a5ce46a0f\",\"name\":\"\",\"type\":\"SetDynamicTokenAction\",\"children\":[],\"properties\":{\"tokenId\":\"userInput\",\"text\":\"\",\"setGlobal\":false},\"isDisabled\":true}],\"properties\":{},\"isDisabled\":false}],\"properties\":{\"times\":1,\"autoReset\":false},\"isDisabled\":false},{\"id\":\"79bcf3ba-7cab-421c-9d75-799343898ecd\",\"name\":\"\",\"type\":\"SequenceComposite\",\"children\":[{\"id\":\"4dc28c71-ecc9-46ee-9ae8-95f57e0aa7c0\",\"name\":\"\",\"type\":\"GetLastEventDataAction\",\"children\":[],\"properties\":{\"eventId\":32,\"palIdFilter\":\"\",\"messageIdFilter\":\"\"},\"isDisabled\":false},{\"id\":\"52108f38-40ca-433e-b05c-1b7a64c6fbeb\",\"name\":\"\",\"type\":\"SetDynamicTokenAction\",\"children\":[],\"properties\":{\"tokenId\":\"userInput\",\"text\":\"\",\"setGlobal\":false},\"isDisabled\":false},{\"id\":\"ec301766-3e7a-4449-8e66-afb3ea13fff2\",\"name\":\"\",\"type\":\"SetTextAction\",\"children\":[],\"properties\":{\"replacementText\":\"You are a relationship state tracker for an NPC.  The NPC has a single numeric relationship value with the player, ranging from -9 (extremely hostile) to +9 (extremely friendly). The current value BEFORE the player's message is provided as a number.  Mapping: - -9 to -4 → hostile - -3 to +3 → neutral - +4 to +9 → friendly  Analyze the player's message and decide how much the relationship value should change. - Keep changes small and believable (usually 1 to 3 points, maximum 4 points for very extreme messages). - A positive message (compliments, kindness, help) increases the value. - A negative message (insults, threats, cruelty) decreases the value. - Make sure the updated value never goes below -9 or above +9.  Current state and Example format: {\\\"currentValue\\\":{{currentValue}},\\\"currentState\\\":\\\"{{currentState}}\\\"} The player says: {{userInput}}  IMPORTANT: Output **only** a valid JSON object with these two keys: - \\\"currentValue\\\" (integer) — the new relationship value after the change. - \\\"currentState\\\" (string) — \\\"hostile\\\", \\\"neutral\\\", or \\\"friendly\\\", based on the new value.  No markdown, no extra text, no explanation.\",\"appendText\":\"\",\"prependText\":\"\"},\"isDisabled\":false},{\"id\":\"bbb65884-1428-4fdf-b744-8be23513e943\",\"name\":\"\",\"type\":\"ConsoleLogAction\",\"children\":[],\"properties\":{\"message\":\"\",\"printFlow\":true},\"isDisabled\":false},{\"id\":\"2bbe4b38-bc7b-432e-a013-d4a139b4f0e6\",\"name\":\"\",\"type\":\"InstructAction\",\"children\":[],\"properties\":{\"userMessage\":\"\",\"charId\":\"320cbe6f-2d71-488d-b666-e6bc96cb9b81\",\"messageId\":\"320cbe6f-2d71-488d-b666-e6bc96cb9b81\",\"fakePalId\":\"\"},\"isDisabled\":false}],\"properties\":{},\"isDisabled\":false}],\"properties\":{},\"isDisabled\":false},{\"id\":\"aea2edfe-b830-456c-a62f-0be1e879e568\",\"name\":\"\",\"type\":\"SequenceComposite\",\"children\":[{\"id\":\"d6661b60-4202-4643-905b-c30bdf415059\",\"name\":\"\",\"type\":\"GetLastEventDataAction\",\"children\":[],\"properties\":{\"eventId\":28,\"palIdFilter\":\"\",\"messageIdFilter\":\"320cbe6f-2d71-488d-b666-e6bc96cb9b81\"},\"isDisabled\":false},{\"id\":\"95243cb6-dd7e-4ce8-8adc-3dc9199dc86b\",\"name\":\"\",\"type\":\"SetDynamicTokenAction\",\"children\":[],\"properties\":{\"tokenId\":\"lastInstructResult\",\"text\":\"\",\"setGlobal\":false},\"isDisabled\":false},{\"id\":\"9b479f85-d346-4a37-9dc1-c9946ffa4036\",\"name\":\"\",\"type\":\"SequenceComposite\",\"children\":[{\"id\":\"bcb77c6e-6772-4359-bded-6e374bac08b0\",\"name\":\"\",\"type\":\"GetDynamicTokenAction\",\"children\":[],\"properties\":{\"tokenId\":\"lastInstructResult\"},\"isDisabled\":false},{\"id\":\"f6e75cd1-c630-457d-8d30-7ecd687a3948\",\"name\":\"\",\"type\":\"ConsoleLogAction\",\"children\":[],\"properties\":{\"message\":\"\",\"printFlow\":true},\"isDisabled\":false},{\"id\":\"6d00b59e-5d78-4492-8358-857e01620813\",\"name\":\"\",\"type\":\"JsonExtractAction\",\"children\":[],\"properties\":{\"jsonPath\":\"currentValue\"},\"isDisabled\":false},{\"id\":\"d31d2721-321b-4a70-9b90-ef02318b3db9\",\"name\":\"\",\"type\":\"SetDynamicTokenAction\",\"children\":[],\"properties\":{\"tokenId\":\"currentValue\",\"text\":\"\",\"setGlobal\":false},\"isDisabled\":false},{\"id\":\"d787a3bb-e894-4a24-8218-7df2edfde77e\",\"name\":\"\",\"type\":\"GetDynamicTokenAction\",\"children\":[],\"properties\":{\"tokenId\":\"lastInstructResult\"},\"isDisabled\":false},{\"id\":\"ee91a2d8-1149-444f-8330-95177b1d7f67\",\"name\":\"\",\"type\":\"JsonExtractAction\",\"children\":[],\"properties\":{\"jsonPath\":\"currentState\"},\"isDisabled\":false},{\"id\":\"7554bd3a-7e14-4452-baa1-b9bf6d4ea7dc\",\"name\":\"\",\"type\":\"SetDynamicTokenAction\",\"children\":[],\"properties\":{\"tokenId\":\"currentState\",\"text\":\"\",\"setGlobal\":false},\"isDisabled\":false},{\"id\":\"08a3668e-5104-4875-a0ef-1c589ce9e8f7\",\"name\":\"\",\"type\":\"ConsoleLogAction\",\"children\":[],\"properties\":{\"message\":\"\",\"printFlow\":true},\"isDisabled\":false}],\"properties\":{},\"isDisabled\":false},{\"id\":\"385045e9-5cd1-4d18-9c61-35e0861d6978\",\"name\":\"\",\"type\":\"SequenceComposite\",\"children\":[{\"id\":\"8d7d5d7d-15ca-44c0-a183-4984e7b97090\",\"name\":\"\",\"type\":\"SequenceComposite\",\"children\":[{\"id\":\"48a7787b-a3b6-4753-84e5-508265dc5721\",\"name\":\"\",\"type\":\"SetTextAction\",\"children\":[],\"properties\":{\"replacementText\":\"\",\"appendText\":\"!) \",\"prependText\":\"(RESPONSE INSTRUCTION: Talk like being \"},\"isDisabled\":false},{\"id\":\"ff0b3995-5ac3-440f-9af7-3aa99f8f9efd\",\"name\":\"\",\"type\":\"SetPalResponseInstructionAction\",\"children\":[],\"properties\":{\"instructionText\":\"\"},\"isDisabled\":false}],\"properties\":{},\"isDisabled\":false},{\"id\":\"9afba873-1bd0-4bd8-8dc3-24a966068b2a\",\"name\":\"\",\"type\":\"GetDynamicTokenAction\",\"children\":[],\"properties\":{\"tokenId\":\"userInput\"},\"isDisabled\":false},{\"id\":\"716b3d1a-84dd-4427-9792-c4ef15a42ebf\",\"name\":\"\",\"type\":\"DelayDecorator\",\"children\":[{\"id\":\"c375b4ee-6d33-400e-8142-1b8cdb24045f\",\"name\":\"\",\"type\":\"ChatAction\",\"children\":[],\"properties\":{\"userMessage\":\"\"},\"isDisabled\":false}],\"properties\":{\"durationInMs\":550},\"isDisabled\":false}],\"properties\":{},\"isDisabled\":false}],\"properties\":{},\"isDisabled\":false}]","AddDefaultBehavior":true,"Id":"82bdca18-942c-4b65-b68a-9d9272397f1f","NewerVersionId":null,"DependencyId":null,"Name":"82bdca18-942c-4b65-b68a-9d9272397f1f","Description":"","Author":"","Version":1,"Url":"","Tags":null,"CreatedDate":"2026-06-12T18:00:07.6112855Z","LastUpdatedDate":null}],"CustomCss":null,"AdditionalUserAssets":[],"UseAgentPrompt":false},"StdBaseWidget":null}

Step 1 – Intercept the User Message (Tree 1)

The simple User Text Input Field is configured as event-only (Panel Config). This ensures that the default behavior of starting a chat is disabled, allowing us to intercept the message and trigger our own logic.

Step 1

Step 2 – Use InstructAction for Classification (Tree 1)

In this example, we store the user's input (StateAction) and build an instruction text (SetTextAction) to classify the message (InstructAction). The model returns a structured result containing the current relationship state and the updated relationship value.

Mapping:
- -9 to -4 → Hostile
- -3 to +3 → Neutral
- +4 to +9 → Friendly

Step 3 – Process the Result

We retrieve the result using GetLastEventDataAction and extract the values from the structured response. These values are then stored as dynamic tokens.

Note: This example assumes that the model produces only valid JSON and does not return malformed output.

Step 4 – Resume the Chat

We retrieve the current state from the text flow and combine it with the instruction to feed it to SetPalResponseInstructionAction:

(RESPONSE INSTRUCTION: Talk as if you are " + currentState + ")!"

We then resume the chat using ChatAction. The user message is loaded from the state and the response action ensures that it is combined with our custom instruction. This can be verified using Chat Debug.

tip

Use Settings → Chat → Debug: Context to see exactly what's sent to the AI. It reveals the full context sent, including custom instructions.