Skip to content
Proud to collaborate with Microsoft for Startups

data.telegram.chat.upsert ​

Idempotently insert or restore a TelegramChat row, keyed on (bot_uuid, chat_ref)

Idempotently insert or restore a TelegramChat row.

Accepts bot_uuid and resolves it to the internal integer FK before any DB operation, following the platform UUID-only surface rule. organization_id is derived from the resolved bot row — no input required.

Keyed on (telegram_bot_id, chat_id). Three cases:

  • not found → INSERT, persisted=True restored=False
  • found, active → no-op row, refresh chat_type/title/username, persisted=False restored=False
  • found, deleted → restore + refresh, persisted=False restored=True

Overview ​

PropertyValue
Workflow typeAtomic
LibraryApp-telegram
Version1.0

Input Schema ​

FieldTypeRequiredDefaultDescription
bot_uuiduuidYes—UUID of the owning TelegramBot (not the integer bot_id)
chat_refintegerYes—Telegram integer chat reference (e.g. -100123456 for a channel, 12345 for private)
chat_typestringYes—One of: private, group, supergroup, channel
titlestringNo—Display title of the chat (optional; absent for private chats)
usernamestringNo—Chat @username without leading @ (optional; channels/supergroups only)
workflow_run_idstringNo—Engine-stamped parent run id (DAG step target)

Output Schema ​

FieldTypeRequiredDefaultDescription
chat_uuidstringYes—UUID of the persisted TelegramChat row
persistedbooleanYes—True when a brand-new row was inserted
restoredbooleanYes—True when a soft-deleted row was undeleted
workflow_run_idstringNo—Engine-stamped parent run id (carried forward from input)
bot_uuiduuidNo—bot_uuid echoed from input
chat_refintegerNo—chat_ref echoed from input
failure_reasonstringNo—Human-readable failure reason
failure_typestringNo—Failure category (e.g. not_found)
failed_actionstringNo—Name of the action method that raised
errorstringNo—Engine-stamped exception message (set on unhandled exceptions)
error_typestringNo—Engine-stamped exception type name
failed_at_statestringNo—Engine-stamped state name where the failure occurred
failed_layerstringNo—Engine-stamped DAG layer name (None for non-DAG workflows)
failed_stepstringNo—Engine-stamped DAG step name (None for non-DAG workflows)

States ​

StateInitialTerminalSuccessAuto-advanceDescription
pendingYesNo—completeUpsert TelegramChat row
completedNoYesYes—Chat row upserted
failedNoYesNo—Upsert failed

State Diagram ​

Transitions ​

FromActionToDescription
pendingcompletecompleted—
pendingfailfailed—

API Usage ​

bash
POST /api/workflows/start
Content-Type: application/json

{
  "workflow_type": "data.telegram.chat.upsert",
  "initial_data": {
    "bot_uuid": "value",
    "chat_ref": 123,
    "chat_type": "value"
  }
}