{
  "settings": {
    "type":"object",
    "title":"Telegram API Settings",
    "properties":{
      "api_id":{
        "type":"number",
        "title":"api id",
        "minLength":1,
        "required":true,
        "description":"create/find your API key on my.telegram.org"
      },
      "api_hash":{
        "type":"string",
        "title":"api hash",
        "required":true,
        "minLength":1,
        "description":"create/find your API hash on my.telegram.org"
      }
    }
  },
  "collections": {
    "accounts": {
      "type": "object",
      "title": "Account",
      "description": "Control a Telegram account. Send messages from and receive messages to this account.",
      "required":["name","settings"],
      "options":{
        "disable_edit_json":true,
        "disable_properties":true
      },
      "properties": {
        "name":{
          "type":"string",
          "pattern":"^[0-9A-Za-z_-]*$"
        },
        "settings": {
          "type": "object",
          "description": "set the connection properties for this telegram account",
          "additionalProperties":false,
          "required": ["phone_number"],
          "properties": {
            "phone_number": {
              "type": "string",
              "title":"phone number",
              "pattern":"^[+][0-9]{7,20}$",
              "required": true,
              "description": "The telegram accounts phone number in the format +49123456789."
            },
            "password": {
              "type":"string",
              "title":"password",
              "format":"password",
              "description":"enter password if account is password protected"
            },
            "level":{
              "title":"default level",
              "type":"string",
              "description":"Define level, that is used, once this account is contacted and no session registered a routing for the contacting chat.",
              "enum":[]
            },
            "chat_argument":{
              "title":"chat level argument",
              "type":"string",
              "default":"Player"
            },
            "test":{
              "type":"boolean",
              "title":"test",
              "description":"set true if this is supposed to be a test account"
            }
          }
        },
        "telegram":{"$ref":"#/definitions/telegram_peer"},
        "chats": {
          "type": "array",
          "format":"table",
          "options": {
            "collapsed":true,
            "disable_array_add": true,
            "disable_array_delete": true,
            "disable_array_delete_all_rows":true,
            "disable_array_delete_last_row":true,
            "disable_array_reorder":true
          },
          "items":{
            "type":"string",
            "readonly": true
          }
        }
      }
    },
    "bots": {
      "type": "object",
      "title": "Bot",
      "description": "Control a Telegram Bot. Send messages from and receive messages to this bot.",
      "required":["name","settings"],
      "options":{
        "disable_edit_json":true,
        "disable_properties":true
      },
      "properties": {
        "name":{
          "type":"string",
          "pattern":"^[0-9A-Za-z_-]*$"
        },
        "settings": {
          "type": "object",
          "description": "set the connection properties for this telegram account",
          "additionalProperties":false,
          "required": ["token"],
          "properties": {
            "token": {
              "type": "string",
              "title":"bot api token",
              "description": "The telegram bot token you received when creating the bot e.g. via @BotFather."
            },
            "level":{
              "title":"default level",
              "type":"string",
              "description":"Define level, that is used, once this account is contacted and no session registered a routing for the contacting chat.",
              "enum":[]
            },
            "chat_argument":{
              "title":"chat level argument",
              "type":"string",
              "default":"Player"
            }
          }
        },
        "telegram":{"$ref":"#/definitions/telegram_peer"},
        "chats": {
          "type": "array",
          "format":"table",
          "options": {
            "collapsed":true,
            "disable_array_add": true,
            "disable_array_delete": true,
            "disable_array_delete_all_rows":true,
            "disable_array_delete_last_row":true,
            "disable_array_reorder":true
          },
          "items":{
            "type":"string",
            "readonly": true
          }
        }
      }
    }
  },
  "data_variables":{
    "players":{
      "telegram":{
        "type":"object",
        "properties":{
          "first_name":{"type":"string"},
          "last_name":{"type":"string"},
          "id":{"type":"integer"},
          "phone":{"type":"string"},
          "username":{"type":"string"},
          "type":{"type":"string"},
          "bot":{"type":"boolean"}
        }
      }
    },
    "chats":{
      "name":{"type":"string"},
      "title":{"type":"string"},
      "members":{
        "type":"array",
        "items":{
          "type":"integer"
        }
      },
      "member_count":{
        "type":"integer"
      },
      "admin":{"type":"string"},
      "telegram":{
        "type":"object",
        "properties":{
          "date":{"type":"string"},
          "id":{"type":"integer"},
          "participants_count":{"type":"integer"},
          "title":{"type":"string"}
        }
      },
      "polls":{
        "type":"object",
        "additionalProperties":{
          "type":"object"
        }
      }
    }
  },
  "action_variables":{
    "onMessage":{
      "text":{"type":"string"},
      "media":{"type":"string"},
      "match":{"type":"string"},
      "id": {"type":"integer"},
      "date":{"type":"string"},
      "from_id":{"type":"integer"},
      "to_id":{"type":"integer"},
      "peer_type":{"type":"string"},
      "peer":{"type":"integer"},
      "download":{"type":"object"},
      "lat":{"type":"number"},
      "long":{"type":"number"}
    },
    "buttons":{
      "button":{"type":"string"},
      "match":{"type":"string"},
      "id": {"type":"integer"},
      "date":{"type":"string"},
      "from_id":{"type":"integer"},
      "to_id":{"type":"integer"},
      "peer_type":{"type":"string"},
      "peer":{"type":"integer"}
    }
  },
  "definitions":{
    "telegram_agent":{
      "title":"Telegram Account",
      "propertyOrder":1,
      "type":"string",
      "required":true,
      "enum":[],
      "isAdaptorContent":false
    },
    "telegram_peer":{
      "type":"object",
      "additionalProperties":false,
      "options":{
        "disable_edit_json":true,
        "disable_properties":true
      },
      "properties":{
        "first_name":{"type":"string", "readonly": true},
        "last_name":{"type":"string", "readonly": true},
        "id":{"type":"integer", "readonly": true},
        "phone":{"type":"string", "readonly": true},
        "username":{"type":"string", "readonly": true},
        "type":{"type":"string", "readonly": true},
        "bot":{"type":"boolean", "readonly": true}
      }
    },
    "permissions": {
      "type":"object",
      "description":"Assign or limit permissions for non admin group members. Setting a value to false, forbids this option.",
      "properties":{
        "view_messages":{
          "type":"boolean",
          "format":"checkbox",
          "default":true,
          "title":"View messages"
        },
        "send_messages":{
          "type":"boolean",
          "format":"checkbox",
          "default":true,
          "title":"Send messages"
        },
        "send_media":{
          "type":"boolean",
          "format":"checkbox",
          "default":true,
          "title":"Send media"
        },
        "send_stickers":{
          "type":"boolean",
          "format":"checkbox",
          "default":true,
          "title":"Send stickers"
        },
        "send_gifs":{
          "type":"boolean",
          "format":"checkbox",
          "default":true,
          "title":"Send GIFs"
        },
        "send_games":{
          "type":"boolean",
          "format":"checkbox",
          "default":true,
          "title":"Send games"
        },
        "send_inline":{
          "type":"boolean",
          "format":"checkbox",
          "default":true,
          "title":"Use inline bots"
        },
        "send_polls":{
          "type":"boolean",
          "format":"checkbox",
          "default":true,
          "title":"Send polls"
        },
        "change_info":{
          "type":"boolean",
          "format":"checkbox",
          "default":true,
          "title":"Change group info"
        },
        "invite_users":{
          "type":"boolean",
          "format":"checkbox",
          "default":true,
          "title":"Invite users"
        },
        "pin_messages":{
          "type":"boolean",
          "format":"checkbox",
          "default":true,
          "title":"Pin messages"
        }
      }
    },
    "admin":{
      "type":"object",
      "title":"set admin",
      "description":"grant or revoke admin rights for chat members. For small Group chats you can only toggle if member is admin.",
      "required":["members","is_admin"],
      "properties":{
        "members":{
          "type":"array",
          "format":"table",
          "items":{
            "type":"string",
            "isAdaptorContent":false
          }
        },
        "is_admin":{
          "title":"is admin",
          "type":"boolean"
        },
        "change_info":{
          "type":"boolean"
        },
        "post_messages":{
          "type":"boolean"
        },
        "edit_messages":{
          "type":"boolean"
        },
        "delete_message":{
          "type":"boolean"
        },
        "ban_users":{
          "type":"boolean"
        },
        "invite_users":{
          "type":"boolean"
        },
        "pin_messages":{
          "type":"boolean"
        },
        "add_admins":{
          "type":"boolean"
        },
        "title":{
          "type":"string"
        }
      }
    },
    "languages":{
      "type":"string",
      "enum":["da-DK","de-DE","en-AU","en-CA","en-GB","en-IN","en-US","ca-ES","es-ES","es-MX","fi-FI","fr-CA","fr-FR","it-IT","ja-JP","ko-KR","nb-NO","nl-NL","pl-PL","pt-BR","pt-PT","ru-RU","sv-SE","zh-CN","zh-HK","zh-TW"],
      "isAdaptorContent":false
    },
    "respond":{
      "type":"array",
      "format":"table",
      "description":"On match, respond or reply to the incoming message. ",
      "items":{
          "type":"object",
          "title":"response",
          "properties":{
            "mode":{
              "type":"string",
              "enum":["respond","reply"],
              "isAdaptorContent":false
            },
            "text":{
              "type":"string",
              "minLength":1,
              "format":"textarea"
            }
          }
      }
    }
  },
  "actions": {
    "sendMessage":{
      "type":"object",
      "title":"Send Message",
      "description": "Send a text message.",
      "documentation":"https://docs.adaptorex.org/basics/actions/telegram/sendMessage.html",
      "template":"{const regex = new RegExp(`${action.plugin}\\.[a-zA-Z]*\\.`); return { title:`telegram ${action.name}`, subtitle:`from ${payload.agent?.replace(regex, '')} to ${payload.to}`, body:[{ text: payload.text }]} }",
      "resolveAdaptorVariables":false,
      "required":["agent","to","text"],
      "default":{"to":"Player"},
      "additionalProperties":false,
      "properties": {
        "agent":{
          "title":"from",
          "$ref":"#/definitions/telegram_items"
        },
        "to":{"$ref":"#/definitions/chat"},
        "text":{
          "type":"string",
          "format":"textarea"
        },
        "typing":{
          "type":"string",
          "description":"Set a delay in seconds to show the 'typing' indicator before the message is sent. If you do not select this option, a delay will be calculated based on the length of the message you send. Set to 0 to not show he indicator at all."
        },
        "pin":{
          "type":"boolean",
          "format":"checkbox",
          "description":"Pin the message and notify chat user(s)."
        }
      }
    },
    "sendFile":{
      "type":"object",
      "title":"Send File",
      "description":"Send a picture, document, video or voice message.",
      "documentation":"https://docs.adaptorex.org/basics/actions/telegram/sendFile.html",
      "template":"{const regex = new RegExp(`${action.plugin}\\.[a-zA-Z]*\\.`); return { title:`telegram ${action.name}`, subtitle:`from ${payload.agent?.replace(regex, '')} to ${payload.to}`, body:[{ text: payload.file }]} }",
      "resolveAdaptorVariables":false,
      "required":["agent","to","file","format"],
      "default":{"to":"Player"},
      "additionalProperties":false,
      "properties": {
        "agent":{
          "title":"from",
          "$ref":"#/definitions/telegram_items"
        },
        "to":{"$ref":"#/definitions/chat"},
        "file":{"$ref":"#/definitions/files"},
        "caption":{
          "type":"string",
          "format":"textarea"
        },
        "format":{
          "type":"string",
          "enum":["auto","document","voice","video"],
          "isAdaptorContent":false
        },
        "pin":{
          "type":"boolean",
          "format":"checkbox",
          "description":"Pin the media message and notify chat user(s)"
        }
      }
    },
    "sendGeo":{
      "title":"Send Geo Location",
      "description":"Send a small map widget that points to a geo location.",
      "documentation":"https://docs.adaptorex.org/basics/actions/telegram/sendGeo.html",
      "template":"{const regex = new RegExp(`${action.plugin}\\.[a-zA-Z]*\\.`); return { title:`telegram ${action.name}`, subtitle:`from ${payload.agent?.replace(regex, '')} to ${payload.to}`, body:[{ text: `Lat: ${payload.latitude.substr(0, 27)}`},{ text: `Lon: ${payload.longitude.substr(0, 27)}`}]} }",
      "resolveAdaptorVariables":false,
      "default":{"to":"Player"},
      "type":"object",
      "required":["agent","to","longitude", "latitude"],
      "additionalProperties":false,
      "properties": {
        "agent":{
          "title":"from",
          "$ref":"#/definitions/telegram_items"
        },
        "to":{"$ref":"#/definitions/chat"},
        "latitude":{
          "type":"string",
          "description":"Geo Coordinate Latitude value. E.g. 53.5823000"
        },
        "longitude":{
          "type":"string",
          "description":"Geo Coordinate Longitude value. E.g. 9.9693000"
        }
      }
    },
    "sendPoll":{
      "title":"Send Poll",
      "description":"Send a poll for group members to vote.",
      "documentation":"https://docs.adaptorex.org/basics/actions/telegram/sendPoll.html",
      "resolveAdaptorVariables":false,
      "template":"{const regex = new RegExp(`${action.plugin}\\.[a-zA-Z]*\\.`); return { title:`telegram ${action.name} ${payload.name}`, subtitle:`from ${payload.agent?.replace(regex, '')} to ${payload.to}`, body:[{text: payload.question}]} }",
      "default":{"to":"Groupchat","private":true,"multiple_choice":false,"quiz":false},
      "type":"object",
      "required":["agent","to","name","question","answers","private","multiple_choice"],
      "additionalProperties":false,
      "properties": {
        "agent":{
          "title":"from",
          "$ref":"#/definitions/telegram_items"
        },
        "to":{"$ref":"#/definitions/chat"},
        "name":{
          "type":"string",
          "title":"Name",
          "pattern": "^[^\\s]*$"
        },
        "question":{
          "type":"string",
          "title":"Question"
        },
        "answers":{
          "type":"array",
          "title":"Answer Options",
          "format":"table",
          "items":{
            "type":"string",
            "title":"Answer"
          }
        },
        "private":{
          "type":"boolean",
          "title":"Anonymous Vote",
          "format":"checkbox"
        },
        "multiple_choice":{
          "type":"boolean",
          "title":"Multiple Choice",
          "format":"checkbox"
        }
      }
    },
    "sendQuiz":{
      "title":"Send Quiz",
      "description":"Send a poll that has a correct answer.",
      "documentation":"https://docs.adaptorex.org/basics/actions/telegram/sendQuiz.html",
      "resolveAdaptorVariables":false,
      "template":"{const regex = new RegExp(`${action.plugin}\\.[a-zA-Z]*\\.`); return { title:`telegram ${action.name} ${payload.name}`, subtitle:`from ${payload.agent?.replace(regex, '')} to ${payload.to}`, body:[{text: payload.question}]} }",
      "default":{"to":"Groupchat"},
      "type":"object",
      "required":["agent","to","name","question","answers","correct_answer"],
      "additionalProperties":false,
      "properties": {
        "agent":{
          "title":"from",
          "$ref":"#/definitions/telegram_items"
        },
        "to":{"$ref":"#/definitions/chat"},
        "name":{
          "type":"string",
          "title":"Name",
          "pattern": "^[^\\s]*$"
        },
        "question":{
          "type":"string",
          "title":"Question"
        },
        "answers":{
          "type":"array",
          "title":"Answer Options",
          "format":"table",
          "items":{
            "type":"string",
            "title":"Answer"
          }
        },
        "correct_answer": {
          "type": "string",
          "title":"Correct Answer",
          "watch": {
            "answer_options": "answers"
          },
          "enumSource": "answer_options"
        },
        "private":{
          "type":"boolean",
          "title":"Anonymous Quiz",
          "format":"checkbox"
        }
      }
    },
    "castVote":{
      "type":"object",
      "title":"Cast Vote",
      "description": "Vote in a Chat Poll that was created with Send Poll.",
      "documentation":"https://docs.adaptorex.org/basics/actions/telegram/castVote.html",
      "template":"{const regex = new RegExp(`${action.plugin}\\.[a-zA-Z]*\\.`); return { title:`telegram ${action.name}`, subtitle:`${payload.agent?.replace(regex, '')} cast vote(s) in ${payload.to} poll ${payload.poll}`, body:[{ text: `${payload.options}` }]} }",
      "resolveAdaptorVariables":false,
      "required":["agent","to","poll","options"],
      "default":{"to":"Player","options":[]},
      "additionalProperties":false,
      "properties": {
        "agent":{
          "$ref":"#/definitions/telegram_accounts"
        },
        "to":{"$ref":"#/definitions/chat"},
        "poll":{
          "type":"string",
          "description":"Name of poll, as defined in 'Send Poll', to cast vote for."
        },
        "options":{
          "type":"array",
          "format":"table",
          "description":"Index of Poll option (first option is 0) or title of Poll option.",
          "items":{
            "title":"option",
            "type":"string"
          }
        }
      }
    },
    "buttons":{
      "title":"Buttons",
      "description":"Send/show buttons and respond to button clicks. Only for Bots.",
      "documentation":"https://docs.adaptorex.org/basics/actions/telegram/buttons.html",
      "resolveAdaptorVariables":false,
      "mode":"listen",
      "template":"{}",
      "default":{"to":"Player","message":"","buttons":[{}]},
      "type":"object",
      "required":["agent","to","type","message","buttons"],
      "additionalProperties":false,
      "properties": {
        "agent":{
          "title":"Bot",
          "$ref":"#/definitions/telegram_bots"
        },
        "to":{"$ref":"#/definitions/chat"},
        "from":{
          "type":"array",
          "description":"User(s) that can click the buttons in the chat. If chat is not a group chat or channel this will be ignored.",
          "isAdaptorContent":false,
          "default":[""],
          "items":{
            "type":"string",
            "format":"table",
            "title":"member"
          }
        },
        "type": {
          "type":"string",
          "enum":["inline","keyboard"]
        },
        "message":{
          "type":"string"
        },
        "typing":{
          "type":"string",
          "description":"Set a delay in seconds to show the 'typing' indicator before the buttons are sent. If you do not select this option, a delay will be calculated based on the length of the message you send. Set to 0 to not show he indicator at all."
        },
        "buttons":{
          "type":"array",
          "title":"Buttons",
          "items": {
            "type": "array",
            "title": "row",
            "items": {
              "type": "object",
              "title": "button",
              "required":["label"],
              "additionalProperties": false,
              "properties": {
                "label":{
                  "type":"string"
                },
                "respond":{
                  "$ref":"#/definitions/respond"
                },
                "next":{
                  "$ref":"#/definitions/next"
                }
              }
            }
          }
        },
        "keep_listening": {"$ref":"#/definitions/keep_listening"}
      }
    },
    "onMessage":{
      "type":"object",
      "title":"On Incoming Message",
      "description":"React to the content of incoming messages.",
      "documentation":"https://docs.adaptorex.org/basics/actions/telegram/onMessage.html",
      "required":["agent","chat"],
      "mode":"listen",
      "resolveAdaptorVariables":false,
      "additionalProperties": false,
      "properties": {
        "agent":{
          "title":"Account or Bot",
          "$ref":"#/definitions/telegram_items"
        },
        "chat":{"$ref":"#/definitions/chat"},
        "from":{
          "type":"array",
          "description":"User (Player, Account or Bot) the message in the chat originates from. If chat is not a group chat or channel this will be ignored.",
          "isAdaptorContent":false,
          "default":[""],
          "items":{
            "type":"string",
            "format":"table",
            "title":"member"
          }
        },
        "priority":{
          "type":"number",
          "default":1,
          "description":"Ignore this if there is an incoming message action with the same members of higher priority in a different path, prefer this otherwise. If priority is the same, latest 'On Incoming Message' is preferred.",
          "enum":[0, 1, 2],
          "options": {
            "enum_titles": [
              "low",
              "normal",
              "high"
            ]
          }
        },
        "if":{
          "type":"array",
          "title":"if",
          "items":{
            "title":"condition",
            "oneOf":[
              {
                "title":"Equals",
                "description":"If message equals the or any of the following values",
                "type":"object",
                "additionalProperties": false,
                "required":["equals"],
                "properties":{
                  "equals":{"$ref":"#/definitions/equals"},
                  "case_sensitive":{"type":"boolean","format":"checkbox","title":"case sensitive"},
                  "respond":{"$ref":"#/definitions/respond"},
                  "next":{"$ref":"#/definitions/next"}
                }
              },
              {
                "title":"Contains",
                "description":"If message contains the or any of the following values",
                "type":"object",
                "additionalProperties": false,
                "required":["contains"],
                "properties":{
                  "contains":{"$ref":"#/definitions/contains"},
                  "case_sensitive":{"type":"boolean","format":"checkbox","title":"case sensitive"},
                  "respond":{"$ref":"#/definitions/respond"},
                  "next":{"$ref":"#/definitions/next"}
                }
              },
              {
                "title":"Contains Media",
                "description":"If message contains some type of media",
                "type":"object",
                "required":["media"],
                "additionalProperties": false,
                "properties":{
                  "media":{
                    "propertyOrder": 2,
                    "oneOf":[
                      {
                        "title":"contains",
                        "type":"string",
                        "enum":["photo","image","document","audio","voice","video","sticker","geo","geolive","contact","poll","webpage","venue","game","dice","invoice","downloadable","any","unsupported","empty","unknown"],
                        "required":true,
                        "isAdaptorContent":false
                      },
                      {
                        "title":"contains any of",
                        "type":"array",
                        "format":"table",
                        "default":["",""],
                        "items":{"type":"string","title":"media type","enum":["photo","image","document","audio","voice","video","sticker","geo","geolive","contact","poll","webpage","venue","game","dice","invoice","unsupported","empty","unknown"],"isAdaptorContent":false}
                      }
                    ]
                  },
                  "download":{
                    "type":"object",
                    "required":["dir"],
                    "description":"Download media from incoming message if it is photo, image, document, audio, voice, video or sticker",
                    "properties":{
                      "dir":{
                        "type":"string",
                        "title": "directory",
                        "default":"telegram/",
                        "description":"Set a directory where to store the downloaded media file."
                      },
                      "file":{
                        "type":"string",
                        "title":"filename",
                        "default":"",
                        "description":"Set an optional filename under which to store the downloaded media. Do not provide a file extension hence it will be appended automatically."
                      },
                      "variable":{
                        "type":"string",
                        "title":"variable",
                        "default":"",
                        "description":"Store the download path to a local variable."
                      }
                    }
                  },
                  "respond":{"$ref":"#/definitions/respond"},
                  "next":{"$ref":"#/definitions/next"}
                }
              },
              {
                "title":"Less Than",
                "description":"If message is value that is less than",
                "type":"object",
                "default":{"lessThan":""},
                "additionalProperties": false,
                "properties":{
                  "lessThan":{"$ref":"#/definitions/lessThan"},
                  "respond":{"$ref":"#/definitions/respond"},
                  "next":{"$ref":"#/definitions/next"}
                }
              },
              {
                "title":"Greater Than",
                "description":"If message is value that is greater than",
                "type":"object",
                "default":{"greaterThan":""},
                "additionalProperties": false,
                "properties":{
                  "greaterThan":{"$ref":"#/definitions/greaterThan"},
                  "respond":{"$ref":"#/definitions/respond"},
                  "next":{"$ref":"#/definitions/next"}
                }
              },
              {
                "title":"Regular Expression",
                "description":"If regular expression returns anything when used on incoming message",
                "type":"object",
                "default":{"regex":""},
                "additionalProperties": false,
                "properties":{
                  "regex":{"$ref":"#/definitions/regex"},
                  "respond":{"$ref":"#/definitions/respond"},
                  "case_sensitive":{"type":"boolean","format":"checkbox","title":"case sensitive"},
                  "next":{"$ref":"#/definitions/next"}
                }
              },
              {
                "title":"Javascript Function",
                "description":"If javascript function returns true. Use value as function argument.",
                "type":"object",
                "default":{"javascript":""},
                "additionalProperties": false,
                "properties":{
                  "javascript":{"$ref":"#/definitions/javascript"},
                  "respond":{"$ref":"#/definitions/respond"},
                  "next":{"$ref":"#/definitions/next"}
                }
              },
              {
                "title":"Database Query",
                "description":"If database find query returns a valid document. You can use 'On Incoming Message' 'text' action var in query: [[statename.actionname.text]]",
                "type":"object",
                "default":{"find":""},
                "additionalProperties": false,
                "properties":{
                  "find":{"$ref":"#/definitions/find"},
                  "respond":{"$ref":"#/definitions/respond"},
                  "next":{"$ref":"#/definitions/next"}
                }
              }
            ]
          }
        },
        "else":{
          "type":"object",
          "title":"else",
          "additionalProperties":false,
          "properties":{
            "next":{"$ref":"#/definitions/next"},
            "respond":{"$ref":"#/definitions/respond"}
          }
        },
        "while_idle": {"$ref":"#/definitions/while_idle"},
        "finally": {"$ref":"#/definitions/finally"},
        "keep_listening": {"$ref":"#/definitions/keep_listening"}
      }
    },
    "createChat":{
      "type":"object",
      "title":"Create Chat",
      "description":"Create a new telegram chat",
      "documentation":"https://docs.adaptorex.org/basics/actions/telegram/createChat.html",
      "template":"{return { title:`telegram ${action.name}`, subtitle:`new chat '${payload.name}' ${payload.reference || ''}`, body:[{ text: `Members: ${payload.agent?.replace('telegram.accounts.', '')}, ${payload.members.join(', ')}`}]} }",
      "resolveAdaptorVariables":false,
      "required":["name","agent","members","type"],
      "additionalProperties":false,
      "properties":{
        "type":{
          "type":"string",
          "enum":["chat"],
          "isAdaptorContent":false
        },
        "name":{
          "type":"string"
        },
        "agent":{
          "$ref":"#/definitions/telegram_accounts"
        },
        "members":{
          "type":"array",
          "format":"table",
          "description":"reference or query to agent or player",
          "items":{
            "type":"string",
            "title":"member",
            "isAdaptorContent":false
          }
        },
        "title":{
          "type":"string",
          "description":"Set a group chat title that is different from the chat name"
        },
        "photo":{"$ref":"#/definitions/files"},
        "about":{
          "type":"string",
          "format":"textarea",
          "description":"group description text"
        },
        "create_link":{
          "type":"boolean",
          "title":"create invite link",
          "format":"checkbox",
          "default":true,
          "description":"create an invite link. The link URL will be stored in the chat item under 'link'. The link will never expire, requires no confirmation and can be used infinite times."
        },
        "permissions":{"$ref":"#/definitions/permissions"},
        "reference":{
          "type":"string",
          "description":"Name to reference the group chat or channel from inside this level.",
          "isAdaptorContent":false
        }
      }
    },
    "editChat":{
      "type":"object",
      "title":"Edit Chat",
      "description":"Change group chat settings and add or remove members. The executing Agent has to be group admin",
      "documentation":"https://docs.adaptorex.org/basics/actions/telegram/editChat.html",
      "resolveAdaptorVariables":false,
      "required":["chat","agent"],
      "additionalProperties":false,
      "properties":{
        "agent":{
          "title":"Account or Bot",
          "$ref":"#/definitions/telegram_items"
        },
        "chat":{"$ref":"#/definitions/chat"},
        "title":{
          "type":"string",
          "description":"change group chat title"
        },
        "add_members":{
          "type":"array",
          "title":"add members",
          "format":"table",
          "description":"add members by reference or query to agent or player",
          "items":{
            "type":"string",
            "title":"member",
            "isAdaptorContent":false
          }
        },
        "remove_members":{
          "type":"array",
          "title":"remove members",
          "format":"table",
          "description":"remove members by reference or query to agent or player",
          "items":{
            "type":"string",
            "title":"member",
            "isAdaptorContent":false
          }
        },
        "photo":{"$ref":"#/definitions/files"},
        "about":{
          "type":"string",
          "description":"group description text"
        },
        "create_link":{
          "type":"boolean",
          "default":true,
          "title":"create invite link",
          "description":"create an invite link. The link URL will be stored in the chat item under 'link'. The link will never expire, requires no confirmation and can be used infinite times."
        },
        "permissions":{"$ref":"#/definitions/permissions"}
      }
    }
  }
}