Automated Bitrix24 Chatbot Handler with Webhook Integration - n8n Workflow

Use this comprehensive n8n workflow template to deploy a custom Bitrix24 chatbot application. Learn how the n8n trigger handles events like new messages and bot installation, ensuring seamless integration.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Bitrix24 Administrators: Seeking to integrate custom, internal chatbots without maintaining external complex server infrastructure.
Automation Engineers: Looking for advanced n8n workflow examples utilizing webhooks, logic gates, and HTTP requests.
Developers: Needing an example of a full application lifecycle handler (install, message, delete) built entirely within an n8n node structure.
Users Exploring n8n Templates: Individuals who want to adapt a versatile n8n workflow for custom CRM tasks or messaging automation.

Overview

Developing conversational agents requires reliable event handling and routing. This specific n8n workflow solves the complexity of integrating a custom chatbot with Bitrix24 by providing a single, centralized handler for all relevant application events (message received, bot installation, chat join, deletion).

By leveraging the Bitrix24 API and an n8n trigger (the Webhook), this n8n template efficiently processes incoming requests, validates security tokens, and dynamically routes the execution path using powerful flow control nodes. The value provided is the ability to instantly deploy and customize advanced conversational logic using low-code n8n nodes, saving significant development time compared to traditional scripting methods. This n8n workflow is a perfect example of scalable CRM automation.

How it Works

The entire process is initiated by an external event hitting the primary n8n trigger.


  1. Trigger Reception: The Bitrix24 Handler n8n node (a Webhook) acts as the primary n8n trigger, capturing POST data sent by Bitrix24 whenever an application event occurs (e.g., a user sends a message).

  2. Data Extraction: The flow proceeds to the Credentials n8n node, which uses the Set function to extract critical authentication information (access token, domain) from the webhook payload.

  3. Security Validation: The Validate Token If n8n node performs a critical security check, ensuring the application token matches a known ID. If invalid, it sends an Error Response.

  4. Event Routing: If validation succeeds, the Route Event Switch n8n node inspects the event type (e.g., ONIMBOTMESSAGEADD, ONAPPINSTALL). This branching mechanism directs the n8n workflow to the appropriate processing track.

  5. Event Processing: Depending on the event:

Message Add: The Process Message Function n8n node implements the chatbot logic (echos messages or responds to 'what's hot'). The response is sent back via the Send Message HTTP Request n8n node.
App Install: The Process Install Function n8n node formats registration data, including the handler's webhook URL, and registers the bot with Bitrix24 using the Register Bot HTTP Request n8n node.
* Join Chat: The Process Join Function n8n node prepares a welcome message, sent via the Send Join Message HTTP Request n8n node.

  1. Acknowledge Success: Regardless of the successful path taken (message sent, bot registered, etc.), the n8n workflow concludes by sending a Success Response back to Bitrix24 via the Respond to Webhook n8n node.

Installation Guide

To utilize this complex n8n workflow, follow these steps:


  1. Import the n8n Template: Copy the provided JSON data and import it into your n8n instance via the 'Workflows' section using the 'New' button and selecting 'Import from JSON'.

  2. Configure the n8n Trigger: Once imported, navigate to the Bitrix24 Handler n8n node. Activate the workflow and copy the generated Webhook URL. This URL must be configured within your Bitrix24 application settings as the callback handler.

  3. Update Credentials: Open the Credentials n8n node. This node contains hardcoded placeholder values for CLIENTID and CLIENTSECRET. Crucially, you must replace these placeholders with the actual Client ID and Secret obtained from your Bitrix24 Marketplace application registration. This ensures the token validation step works correctly.

  4. Activate and Test: Save the n8n workflow and activate it. Test the installation process by installing the application in Bitrix24. The ONAPPINSTALL route should trigger, and the bot should register successfully.

Node Details

This n8n workflow leverages several core n8n node types for flow control and external communication:

Bitrix24 Handler (Webhook):
Function: Serves as the primary n8n trigger, listening for POST requests from Bitrix
24.
Key Configuration: Path set to bitrix24/handler.php; Method set to POST; Response mode set to Response Node.
Credentials (Set):
Function: Extracts and standardizes API credentials (tokens, domain) received in the webhook body, making them easily accessible as JSON fields for subsequent n8n nodes.
Key Configuration: Sets static CLIENTID and CLIENTSECRET (must be updated by the user) and dynamically extracts applicationtoken, domain, and accesstoken using expressions.
Validate Token (If):
Function: Implements a security gate. Only traffic with a valid application token is allowed to proceed to the main logic.
Key Configuration: Compares the dynamic applicationtoken (extracted) against the static CLIENTID.
Route Event (Switch):
Function: A crucial flow control n8n node that routes execution based on the Bitrix24 event type (ONIMBOTMESSAGEADD, ONAPPINSTALL, etc.).
Key Configuration: Routes based on the value of {{ $json.body.event }}.
Process Message/Join/Install (Function):
Function: Custom scripting n8n nodes that prepare the payload for API calls (e.g., composing reply messages, generating bot registration parameters).
Key Configuration: Contains Javascript logic to parse input data (DIALOGID, MESSAGE) and format the output structure needed for Bitrix24 API requests.
Send Message/Register Bot (HTTP Request):
Function: Communicates with the external Bitrix24 API endpoint to perform actions like sending a message or finalizing bot registration.
Key Configuration: Uses dynamic URL construction (=https://{{$json.DOMAIN}}/rest/...) and passes necessary body parameters (DIALOG
ID, MESSAGE).

Related n8n Workflows

Free

Nodes: 8 Nodes
Updated: December 26 2025
View all
Created by

With 30+ years in IT and 20+ years in leadership, I specialize in no-code automation with n8n, optimizing workflows and integrating systems efficiently. As an Agile Coach and Project Manager, I’ve led teams, managed R&D, and driven IT transformations. Skilled in n8n, Java, Node.js, and cloud solutions, I help businesses streamline operations. Let’s connect if you need an n8n expert for automation!

Featured*