Rule-based chatflows
Add a recording request and completion check to a HubSpot rule-based chatbot, with copyable Node.js code.
Use this setup when your HubSpot chatbot follows a sequence of questions and branches. A server-side code action requests a recording, waits while the customer records, and checks the same request when they return.
What you need
A connected Screendesk workspace and its dedicated chatbot token.
HubSpot Data Hub Professional or Enterprise for the Run a code snippet action.
Permission to edit the chatflow.
A known HubSpot contact before the recording step. Collect the customer's email first if the visitor is not already identified.
A test endpoint supplied for the preview, or the production endpoint after release.
This example attaches the recording to the contact timeline. It does not automatically discover the ticket or conversation thread that the visitor is viewing.
1. Choose where to offer a recording
Open Service → Chatflows and edit your rule-based chatbot. A useful place is after the customer describes the problem and provides their email, but before a troubleshooting or human-handoff step.
For example:
Ask what the customer needs help with.
Collect their email if it is not already known.
Offer to record the problem.
Run the Screendesk code action when they accept.
Continue to your existing troubleshooting or handoff after completion or skipping.
HubSpot limits the actions available directly after the welcome message. If Run a code snippet is missing at the very beginning, add an initial question or prompt, then add the code action after it.
2. Add the code action
Click the + between the relevant actions and choose Run a code snippet. Use a descriptive internal name, such as Request a Screendesk recording, and select Node 24.x.

The screenshot shows a small formatting-only test. Use the complete integration example below to create real recording requests.
3. Configure the complete example
Set these two values before saving:
BASE_URL
https://app.screendesk.io. Confirm that the chatbot preview is enabled for your workspace before testing.
BOT_TOKEN
Your dedicated workspace chatbot token, configured server-side. Do not use a general API token.
The code first tries the SCREENDESK_HUBSPOT_BOT_TOKEN environment variable. If your editor does not provide environment secrets, replace REPLACE_WITH_HUBSPOT_CHATBOT_TOKEN only in HubSpot's restricted server-side editor. Keep the credential out of customer messages and public website code.
4. Save and connect the next step
Save the action and keep its default next step connected to your existing troubleshooting or human handoff. The code uses responseExpected: true while waiting for the recording, so the next visitor reply returns to the same snippet.
When the recording is received, skipped, expired, or the API cannot be reached, the example uses responseExpected: false and follows the configured next step. Make that next step useful even when a customer does not provide a recording.
The example stores screendeskRequestId in customState. Keep this state intact if you adapt the flow. Otherwise, a later reply can create a new request instead of checking the one already shown to the customer.
5. Understand the customer messages
First request
Offers Record your screen, I've sent my recording, and Continue without a recording
Customer returns before submission
Checks the original request, shows the same link, and keeps waiting
Recording has been submitted
Confirms that the recording was received, then continues the flow
Customer skips
Continues support without requiring a recording
Request expired
Asks the customer to request a new link from support, then continues
API or configuration failure
Continues the support request without claiming a recording was received
The confirmation means the upload was saved. It does not claim that the bot watched the video, that transcription is complete, or that a HubSpot note has already been delivered.
6. Keep the link clickable and readable
The example sends an HTML anchor with the visible label Record your screen. Its href contains the exact recording URL returned by Screendesk, with HTML escaping to preserve query parameters safely.

Browser-verified formatting with a placeholder destination. In the actual integration, the destination is the signed link returned by the request API.
HTML anchors rendered correctly in the tested HubSpot chatbot. Markdown syntax such as [Record your screen](URL) appeared literally, so do not substitute Markdown in botMessage. The link opens in a new tab; the customer returns to the original chat after submission.
7. Preview before publishing
Use a HubSpot test contact and an unpublished flow. HubSpot's preview can perform real actions, so use test records throughout.
Complete the initial question and email step.
Reach the recording action and confirm the labeled link appears.
Select I've sent my recording before uploading. The bot should remain pending.
Open the recording link, make a short test recording, and submit it.
Return to chat and select I've sent my recording again.
Confirm the receipt message and the next flow step.
Open the test contact in HubSpot and check its timeline for the Screendesk recording note.
Run a separate preview with Continue without a recording and confirm that support continues.
The complete rule-based conversation with a real uploaded recording remains a rollout check. The API/upload/contact-note path and the chatbot's HTML link rendering were verified separately. See Testing and troubleshooting for the full validation matrix.
Adapting the destination
If your server-side integration already knows the correct ticket or conversation ID, it can supply ticket_id or thread_id when creating the request. Do not ask the customer for these internal IDs or choose the contact's latest ticket automatically.
HubSpot's documented snippet event provides a contact ID but does not guarantee a conversation thread ID. A thread-specific implementation needs a trusted source for that context and the additional conversation permissions described in the overview.
Official reference: HubSpot code snippet actions.
Was this helpful?