Skip to content

Conversational Workflow Builder - #4

Merged
quickerup merged 3 commits into
mainfrom
telegram-native-workflow-builder-11959562328041938038
Jul 14, 2026
Merged

Conversational Workflow Builder#4
quickerup merged 3 commits into
mainfrom
telegram-native-workflow-builder-11959562328041938038

Conversation

@quickerup

@quickerup quickerup commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Introduced a conversational state machine within the Cloudflare Worker allowing users to visually build, chain, and stage graph-based workflows directly inside Telegram.

Key changes:

  • Created state machine supporting multiple builder turns (AWAITING_NAME, AWAITING_NODE_TYPE, sequential config turns, and next-action decisions).
  • Added support for inline keyboards using reply_markup inside the sendMessage helper.
  • Process callback queries via callback_query updates and acknowledged them instantly.
  • Implemented auto-linking and coordinate positioning of sequential nodes.
  • Integrated staging and token-based confirmation on finalization.
  • Added comprehensive E2E test suite simulating all builder turns.

PR created automatically by Jules for task 11959562328041938038 started by @aethelred-agent-factory

Summary by CodeRabbit

  • New Features
    • Added an interactive in-bot workflow builder started with /newworkflow.
    • Added inline-button navigation for selecting and configuring workflow steps.
  • Bug Fixes
    • Improved handling of Telegram inline-button callbacks to ensure correct routing.
    • Enhanced /cancel to fully clear any in-progress build state and pending confirmation.
  • Tests
    • Expanded end-to-end coverage to exercise the complete builder flow (staging, confirmation) and verify the final persisted workflow structure.

Co-authored-by: aethelred-agent-factory <238771426+aethelred-agent-factory@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c02bec38-f068-4865-a061-cdcc9a47517b

📥 Commits

Reviewing files that changed from the base of the PR and between 811e396 and 4995b8a.

📒 Files selected for processing (1)
  • worker/src/index.js

📝 Walkthrough

Walkthrough

Adds Telegram workflow-builder routing with callback handling, per-chat cancellation, staged-workflow inspection, and Telegram API support. Extends the end-to-end runner to start Wrangler, execute the builder flow, verify staged and persisted workflows, and clean up.

Changes

Workflow builder

Layer / File(s) Summary
Telegram routing and API support
worker/src/index.js
Routes callback queries and builder text, supports inline reply markup and callback acknowledgements, clears builder state on cancellation, and exposes pending workflow data.
Builder flow execution
scripts/test-builder-e2e.js
Starts Wrangler, waits for readiness, configures HTTP requests, and submits the sequential builder interaction.
Staged and persisted workflow verification
scripts/test-builder-e2e.js
Validates staged workflow structure, confirms dispatch, verifies D1 persistence, and cleans up the dev process on success or failure.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Telegram
  participant WebhookHandler
  participant WORKFLOW_STATE
  participant TelegramAPI
  participant D1API
  Telegram->>WebhookHandler: Send builder message or callback query
  WebhookHandler->>TelegramAPI: Acknowledge callback or send prompt
  WebhookHandler->>WORKFLOW_STATE: Store or read builder workflow
  Telegram->>WebhookHandler: Send confirmation command
  WebhookHandler->>D1API: Persist confirmed workflow
Loading

Suggested reviewers: google-labs-jules[bot]

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: a conversational workflow builder in the Cloudflare Worker.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch telegram-native-workflow-builder-11959562328041938038

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/test-builder-e2e.js`:
- Around line 81-84: Replace the repeated status-only assertions in the test
flow with assertions on the builder’s observable side effects: capture mocked
Telegram calls, inspect WORKFLOW_STATE, verify generated edges and token
delivery, and validate the /confirm transition. Since worker/src/index.js
converts handler failures into HTTP 200, ensure each transition’s handler result
and resulting state are explicitly checked rather than treating res.statusCode
as success.
- Around line 8-26: Update the request function to apply a finite HTTP timeout
to each http.request call, including the readiness probe’s request path, and
ensure timed-out requests are aborted and rejected so the test fails promptly
instead of hanging.

In `@worker/src/index.js`:
- Line 507: Update the active builder-session flow around handleBuilderState to
guard against updates without text before passing message.text into state
handling; non-text updates such as stickers and photos must be ignored or
handled safely, preventing downstream branches from calling .trim() on undefined
while preserving normal text processing.
- Around line 897-905: Guard the builder callback handling around
`builder:add_node` and `builder:finish` so these actions are rejected while
`state.currentNode` is still being configured. Only transition to
`AWAITING_NODE_TYPE` or call `finalizeAndStageWorkflow` when the current node
has been completed or cleared; otherwise preserve the active node state and
return without abandoning or finalizing it.
- Around line 489-491: Update the callback handling around answerCallbackQuery
and the confirmation sendMessage paths to treat Telegram delivery as best-effort
by checking each response’s res.ok status and preventing delivery failures from
aborting the builder flow. Ensure builder state is cleared only after the
confirmation message is accepted, while preserving the existing deduplication
and successful-delivery behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1b7441ff-ad39-45b8-8760-a46fd8f55824

📥 Commits

Reviewing files that changed from the base of the PR and between 2091836 and 2ba234a.

📒 Files selected for processing (2)
  • scripts/test-builder-e2e.js
  • worker/src/index.js

Comment thread scripts/test-builder-e2e.js Outdated
Comment thread scripts/test-builder-e2e.js
Comment thread worker/src/index.js
Comment thread worker/src/index.js
Comment thread worker/src/index.js Outdated
…dation

Co-authored-by: aethelred-agent-factory <238771426+aethelred-agent-factory@users.noreply.github.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
scripts/test-builder-e2e.js (1)

47-66: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

Readiness probe leaves the response unconsumed.

The success path (Line 57-61) resolves without draining res. Per Node's http docs, once a response handler is attached you must consume the data (.resume()/data) or 'end' never fires and buffered data accumulates in memory. Consider calling res.resume() before resolve(), or better, reuse the request() helper from Line 9 (which already drains and times out) instead of duplicating this logic.

♻️ Suggested fix
         const req = http.get('http://localhost:8790/', (res) => {
           clearTimeout(timer);
+          res.resume();
           ready = true;
           resolve();
         });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/test-builder-e2e.js` around lines 47 - 66, Update the readiness probe
loop in the test builder so the successful http.get response is consumed before
resolving, preferably by reusing the existing request helper from the top of the
file if it provides the required timeout behavior; otherwise call res.resume()
in the response handler before resolve().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@scripts/test-builder-e2e.js`:
- Around line 47-66: Update the readiness probe loop in the test builder so the
successful http.get response is consumed before resolving, preferably by reusing
the existing request helper from the top of the file if it provides the required
timeout behavior; otherwise call res.resume() in the response handler before
resolve().

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f1f3df30-2512-4744-9210-3a7b205940ea

📥 Commits

Reviewing files that changed from the base of the PR and between 2ba234a and 811e396.

📒 Files selected for processing (2)
  • scripts/test-builder-e2e.js
  • worker/src/index.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • worker/src/index.js

@quickerup
quickerup merged commit 706b8dc into main Jul 14, 2026
1 of 2 checks passed
@quickerup
quickerup deleted the telegram-native-workflow-builder-11959562328041938038 branch July 14, 2026 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant