Skip to content

📡 System Events Guide ​

Complete description of all fields available in events after parsing through EventParser.

Event Types ​

System supports following event types:

Event TypeDescriptionWhen Occurs
messageRegular message from userUser sends text message or media
callbackInline button clickUser clicks button in message
member_joinedMember joined groupUser joins group or supergroup
member_leftMember left groupUser leaves group or supergroup
pre_checkout_queryPayment confirmation requestUser clicks "Pay" in invoice, but before payment processing
payment_successfulSuccessful paymentPayment via invoice successfully processed

Common Fields ​

These fields available in all event types. All these fields come initially when receiving event and contain original data that formed the event.

ℹ️ Important: These attributes — original event information passed from source (e.g., Telegram). They used by system as default values for actions (e.g., chat_id and message_id taken from event if not specified explicitly in action parameters).

⚠️ Limitation for scheduled scenarios: In scenarios launched on schedule (with schedule field), most common fields unavailable, as event not associated with user or chat. Only system fields available (bot_id, tenant_id) and special scheduled scenario fields (see Scheduled Scenario Fields section).

FieldTypeDescriptionExample
event_sourcestringEvent source"telegram"
event_typestringEvent type"message", "callback", "member_joined", "member_left", "pre_checkout_query", "payment_successful"
user_idintegerUser ID who initiated event123456789
chat_idintegerChat ID from which event came-1001234567890
chat_typestringChat type"private", "group", "supergroup", "channel"
is_groupbooleanWhether chat is group or supergrouptrue for group and supergroup, false for private and channel
message_idintegerID of original message that led to event. For message type events — text message ID, for callback — message ID with button that triggered callback1234
event_datestringEvent date (ISO)"2024-01-15T10:30:45+03:00"
usernamestringUser username"john_doe" (can be null)
first_namestringUser first name"John"
last_namestringUser last name"Doe" (can be null)
language_codestringUser language code"ru", "en" (can be null)
is_botbooleanWhether user is botfalse
is_premiumbooleanPremium usertrue
chat_titlestringChat title"My Group" (can be null)
chat_usernamestringChat username"my_group" (can be null)
user_statestringUser state"feedback", "onboarding" (can be null)
user_state_expired_atstringState expiration time (ISO)"3000-01-01T00:00:00+00:00" (can be null)

🔧 Service Fields ​

System automatically adds following service fields for correct action operation:

FieldTypeDescriptionPurpose
bot_idintegerBot IDRequired for sending messages and executing actions
tenant_idintegerTenant IDRequired for loading scenarios and determining context
polling_start_timestringBot polling start time (ISO)Service for filtering events by time
last_errorstringLast action error textService for passing errors between scenario steps
last_resultstringLast executed action resultService for debugging and result checking between scenario steps
scenario_chainarrayScenario chain in execution orderService for debugging and logging, contains array of scenario names in execution order

⚠️ Important: Following fields added automatically:

  • Required fields (bot_id, tenant_id) — required for executing actions (sending messages, working with DB, managing states)
    • ℹ️ In scheduled scenarios: Fields bot_id and tenant_id available automatically and don't require explicit specification in action parameters. They automatically substituted from synthetic event context
  • Service fields (polling_start_time, last_error, last_result, scenario_chain) — used by system for internal logic:
    • polling_start_time — filtering events by time
    • last_error — saving action error text for subsequent scenario steps
    • last_result — saving action execution result (e.g., success, error, timeout, not_found) for debugging and checking in subsequent scenario steps
    • scenario_chain — array of scenario names in call order, automatically updated when launching each scenario and on transitions (jump_to_scenario, execute_scenario). Current scenario available as scenario_chain[-1], previous — as scenario_chain[-2] (if exists). Used for debugging and logging execution flow
  • State fields (user_state, user_state_expired_at) — can be null if state not set or expired

Scheduled Scenario Fields ​

Additional fields for scenarios launched on schedule:

FieldTypeDescriptionExample
scheduled_atstringScheduled scenario launch time (ISO)"2024-01-15T10:30:00+03:00"
scheduled_scenario_idintegerScheduled scenario ID in database123
scheduled_scenario_namestringScheduled scenario name"daily_report"

ℹ️ Important: These fields available only in scheduled scenarios (with schedule field in configuration). In regular event-triggered scenarios, these fields absent.

⚠️ Limitation: In scheduled scenarios most common fields (e.g., user_id, chat_id, event_text, message_id, etc.) unavailable, as event not associated with user or chat. For sending messages use target_chat_id parameter in actions.

Message Fields ​

Additional fields for message type events:

FieldTypeDescriptionExample
event_textstringMessage text"Hello! How are you?"
media_group_idstringMedia group ID"1234567890123456789" (can be null)
event_attachmentarrayAttachments[{"type": "photo", "file_id": "AgACAgIAAxkBAAIB..."}]
inline_keyboardarrayMessage inline keyboard[[{"Button 1": "action_1"}]] (can be null)
is_replybooleanReply to messagetrue
is_forwardbooleanForwarded messagefalse

Reply Message Fields ​

FieldTypeDescriptionExample
reply_message_idintegerReply message ID1233
reply_message_textstringReply message text"How are you?"
reply_user_idintegerReply message author ID123456789
reply_usernamestringReply message author username"jane_doe"
reply_first_namestringReply message author first name"Jane"
reply_last_namestringReply message author last name"Smith"
reply_datestringReply message date (ISO)"2024-01-15T10:25:30+03:00"
reply_attachmentarrayReply message attachments[{"type": "document", "file_id": "BQACAgIAAxkBAAIB..."}]

Forwarded Message Fields ​

FieldTypeDescriptionExample
forward_message_idintegerForwarded message ID5678
forward_from_user_idintegerForwarded message author ID987654321
forward_from_user_usernamestringForwarded message author username"original_author"
forward_from_user_first_namestringForwarded message author first name"Original"
forward_from_user_last_namestringForwarded message author last name"Author"
forward_from_chat_idintegerForwarded message chat ID-1009876543210
forward_from_chat_titlestringForwarded message chat title"Original Group"
forward_from_chat_typestringForwarded message chat type"supergroup"
forward_datestringForwarded message date (ISO)"2024-01-15T09:15:20+03:00"

Callback Fields ​

Additional fields for callback type events:

FieldTypeDescriptionExample
callback_idstringCallback ID"1234567890123456789"
callback_datastringCallback data"menu_main"
callback_message_textstringOriginal message text callback attached to (text or caption)"Choose action:" (can be null)
inline_keyboardarrayInline keyboard of message callback attached to[[{"Button 1": "action_1"}]] (can be null)

Payment Events ​

Events related to payment via Telegram invoices.

pre_checkout_query Fields ​

Event pre_checkout_query occurs when user clicks "Pay" button in invoice, but before payment processing. This is payment confirmation request from Telegram to bot.

ℹ️ Important: Must respond to this event via answer_pre_checkout_query action to confirm or reject payment. If don't respond within 10 seconds, payment will be automatically rejected.

FieldTypeDescriptionExample
pre_checkout_query_idstringPayment confirmation request ID"1234567890123456789"
invoice_payloadstringInvoice ID (payload passed during creation)"123"
currencystringPayment currency"XTR" (Telegram Stars)
total_amountintegerTotal payment amount in minimal currency units100 (100 stars)

Additionally: Event contains common fields (see Common Fields section).

payment_successful Fields ​

Event payment_successful occurs after successful payment processing via invoice.

FieldTypeDescriptionExample
invoice_payloadstringInvoice ID (payload passed during creation)"123"
currencystringPayment currency"XTR" (Telegram Stars)
total_amountintegerTotal payment amount in minimal currency units100 (100 stars)
telegram_payment_charge_idstringPayment ID in Telegram"1234567890"

Additionally: Event contains common fields (see Common Fields section).

Member Events ​

Events of type member_joined and member_left use standard common fields (see Common Fields section).

ℹ️ Important:

  • Event member_joined occurs when user joins group (transition from status left, kicked or first join)
  • Event member_left occurs when user leaves group (transition to status left or kicked)
  • These events available only for groups and supergroups

Attachment Fields ​

Structure of objects in event_attachment and reply_attachment arrays:

Attachment Types ​

TypeDescriptionNote
photoPhotoLargest available resolution
documentDocumentAny file (PDF, DOC, ZIP, etc.)
videoVideoVideo file
audioAudioAudio file
voiceVoice messageVoice message
stickerStickerTelegram sticker
animationAnimationGIF animation
video_noteVideo noteRound video message

Attachment Object Structure ​

FieldTypeDescriptionExample
typestringAttachment type"photo"
file_idstringFile ID"AgACAgIAAxkBAAIB..."

Attachment Structure Example ​

json
{
  "type": "photo",
  "file_id": "AgACAgIAAxkBAAIB..."
}

Usage Examples ​

How to use event fields in scenarios:

Simple Conditions ​

yaml
# Check event type
trigger:
  - event_type: "message"

# Check message text
trigger:
  - event_type: "message"
    event_text: "/start"

# Check callback data
trigger:
  - event_type: "callback"
    callback_data: "menu_main"

# Check user state
trigger:
  - event_type: "message"
    user_state: "feedback"

Complex Conditions ​

yaml
# Check user and chat
trigger:
  - event_type: "message"
    condition: |
      $user_id == 123456789 and
      $chat_type == "private" and
      $event_text ~ "hello"

# Check attachments
trigger:
  - event_type: "message"
    condition: |
      $event_attachment[0].type == "photo"

# Check reply message
trigger:
  - event_type: "message"
    condition: |
      $is_reply == true and
      $reply_user_id == 987654321

Usage in Action Parameters ​

yaml
# Send message to same chat
- action: "send_message"
  params:
    bot_id: "{bot_id}"
    chat_id: "{chat_id}"
    text: "Hello, {first_name}!"

# Reply to message
- action: "send_message"
  params:
    bot_id: "{bot_id}"
    chat_id: "{chat_id}"
    text: "Received your message!"
    message_reply: "{message_id}"

# Manage user state
- action: "set_user_state"
  params:
    state: "feedback"
    expires_in_seconds: 3600

Coreness — Create. Automate. Scale.