Перейти до змісту

AI Agent Integration & Schema Guidelines

This document provides technical instructions for AI Agents (like Cursor, Claude, ChatGPT) to generate valid MyCode.Bot scenario JSONs. Users can copy and paste the generated JSON directly into the visual scenario builder.

When a user asks you to build a bot logic, flow, or scenario for MyCode.Bot, you MUST generate the JSON exactly according to this schema. Do not deviate from the namespace structures ($type), node naming conventions, or required fields.

Root JSON Structure

{
  "botJson": {
    "Version": "1.0",
    "MappedNodes": {
      // Key-value pairs of node mapping.
      // Keys MUST exactly match the "Action" property of the node.
      // - Events: "OnMemberFollow", "OnError"
      // - Screens: "go_to_screen:{Id}"
      // - Logic nodes: "node:{Id}"
    }
  },
  "placements": [
    // Array specifying the visual coordinates for each node on the canvas.
    // Every node in MappedNodes MUST have a corresponding placement entry.
  ]
}

Node Types and MappedNodes

Each entry in MappedNodes represents a node. Every node requires: 1. Id: A unique integer. 2. Action: A string identifier matching the object key (e.g., go_to_screen:9, node:10). 3. $type: The exact C# class and assembly mapping. 4. NodeType: Enum value specifying the type of node. 5. NextAction (or routing alternatives): The Action string of the node to proceed to. null if it's the end of the flow.

1. Event Node (Trigger)

Events start the scenario. - User Followed: Action "OnMemberFollow", EventType: 0 - Error Occurred: Action "OnError", EventType: 2

"OnMemberFollow": {
  "$type": "WM.MessengersForms.Elements.Nodes.Core.EventNode, WM.MessengersForms",
  "Id": 1,
  "Title": "Event 1",
  "Action": "OnMemberFollow",
  "NextAction": "go_to_screen:2", 
  "NodeType": 5,
  "EventType": 0 
}

2. Screen Node

Displays messages and buttons to the user. - Action naming: go_to_screen:{Id} - NodeType: 0 - ElementType: 4

"go_to_screen:2": {
  "$type": "WM.MessengersForms.Elements.Nodes.Core.Screen, WM.MessengersForms",
  "Id": 2,
  "Title": null,
  "Name": "Welcome Screen",
  "NextAction": null,
  "TargetKey": "userInput",
  "Order": 0,
  "IsOrderingEnabled": false,
  "IsKeyboardScreen": false,
  "OneTimeKeyboard": false,
  "HideKeyboard": false,
  "LastElementId": 0,
  "ElementType": 4,
  "Elements": [
    // Messages and Buttons go here. Order determines sequence.
  ],
  "ScreenButtonsGrid": null,
  "Action": "go_to_screen:2",
  "NodeType": 0
}

Screen Elements (Messages and Buttons)

Inside the Elements array of a Screen Node, you can add Message and Button elements. Each element needs a unique Id (scoped to the screen or globally unique) and an Order integer.

Message Element: - ElementType: 1

{
  "$type": "WM.MessengersForms.Elements.Message, WM.MessengersForms",
  "ElementType": 1,
  "Id": 1,
  "Order": 0,
  "Title": "Message Title",
  "Text": "<p>Message content (HTML supported)</p>",
  "PhotoUrl": null,
  "Options": { "Color": null, "Style": null }
}

Button Element: Buttons route the user to another node upon click. - ElementType: 0

{
  "$type": "WM.MessengersForms.Elements.Button, WM.MessengersForms",
  "ElementType": 0,
  "Options": { "Color": null, "Image": null, "Icon": null },
  "Action": "node:3", // Target node action (must match an existing node's Action)
  "Id": 2,
  "Order": 1,
  "Text": "Click Me",
  "SubText": null
}

3. Logic Nodes

Logic nodes perform backend operations and route without user interaction. - Action naming: node:{Id}

Set User Tag Node: Assigns or clears a tag for the user. To clear, set "TagTemplate": "". - NodeType: 7

"node:3": {
  "$type": "WM.MessengersForms.Elements.Nodes.Core.SetUserTagNode, WM.MessengersForms",
  "Id": 3,
  "Title": "SetUserTagNode 3",
  "Action": "node:3",
  "NextAction": "go_to_screen:4",
  "NodeType": 7,
  "UserIdTemplate": "#mcb_user_id", 
  "TagTemplate": "vip_user" 
}

Get User Tag Node: Retrieves a tag to use in conditions. It outputs a variable with the name defined in OutputKey. - NodeType: 9

"node:4": {
  "$type": "WM.MessengersForms.Elements.Nodes.Core.GetUserTagNode, WM.MessengersForms",
  "Id": 4,
  "Title": "GetUserTagNode 4",
  "Action": "node:4",
  "NextAction": "node:5",
  "NodeType": 9,
  "OutputKey": "user_tag" 
}

Condition Node: Evaluates a JavaScript expression and branches routing. You can reference variables obtained from previous nodes, e.g., #node.4.user_tag. - NodeType: 4

"node:5": {
  "$type": "WM.MessengersForms.Elements.Nodes.Core.ConditionNode, WM.MessengersForms",
  "Id": 5,
  "Title": "Condition 5",
  "Action": "node:5",
  "NextAction": null,
  "NodeType": 4,
  "Expression": "String(#node.4.user_tag).trim().toLowerCase() === 'vip_user'",
  "TrueAction": "go_to_screen:6",
  "FalseAction": "go_to_screen:7"
}

Placements Array

You must generate visual placement coordinates for each node so they render correctly in the visual builder. Every nodeId must map to the Id of a node in MappedNodes. - type: Always 0. - Calculate positionX by advancing approximately 250 for every step forward in the logic chain. - Space vertically (positionY) by 150 for branching logic.

{
  "nodeId": 1, 
  "positionX": 100,
  "positionY": 100,
  "type": 0
}

AI Generation Checklist

When returning the JSON: 1. Wrap the entire output in a single Markdown json code block. 2. Verify all Action strings perfectly match the keys in MappedNodes. 3. Verify all Id values are unique integers across MappedNodes. 4. Verify all Action references inside Buttons (Action), Nodes (NextAction, TrueAction, FalseAction) point to valid existing nodes. 5. Provide a valid placements array with coordinates for every single node.