AutomationFlowsSlack & Telegram › Build a Telegram Mental Health Support Bot with Gpt-4o

Build a Telegram Mental Health Support Bot with Gpt-4o

ByAI/ML API | D1m7asis @d1m7asis on n8n.io

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

Event trigger★★★★☆ complexity15 nodesTelegram TriggerN8N Nodes AimlapiTelegram
Slack & Telegram Trigger: Event Nodes: 15 Complexity: ★★★★☆ Added:

This workflow corresponds to n8n.io template #6556 — we link there as the canonical source.

This workflow follows the Telegram → Telegram Trigger recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "0111b076-35d5-4bd1-b608-ec1bf479592b",
      "name": "Start: Receive Message on Telegram",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        1008,
        752
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "c7f4bbc1-d12b-4f41-b430-aff228a795c9",
      "name": "Route by Input Type",
      "type": "n8n-nodes-base.switch",
      "position": [
        1456,
        720
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Vent",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "71a70192-b1c2-44fc-9e0b-cad9cc5eaac4",
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    },
                    "leftValue": "={{ $('Start: Receive Message on Telegram').item.json.message.text }}",
                    "rightValue": "#vent"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Insight",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "1b5b1c7e-99e9-4e6d-a050-2d3c1c22c236",
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    },
                    "leftValue": "={{ $('Start: Receive Message on Telegram').item.json.message.text }}",
                    "rightValue": "#insight"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Cope",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "a9ad78e2-623b-4d1b-b0b8-bdaebf8bd71c",
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    },
                    "leftValue": "={{ $('Start: Receive Message on Telegram').item.json.message.text }}",
                    "rightValue": "#cope"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Any other",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "6f3a36ca-2348-4573-bbd7-4aa8088ec296",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Start: Receive Message on Telegram').item.json.message.text }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "notesInFlow": false,
      "typeVersion": 3.2
    },
    {
      "id": "329aeb7a-9473-4893-b288-0a9db699d090",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        976,
        -144
      ],
      "parameters": {
        "width": 540,
        "height": 468,
        "content": "## \ud83d\ude80 Quick Start Guide\n\n1. \ud83d\udd10 **Connect Your Credentials**  \n   - **Telegram**: Link your bot token in the **Telegram Trigger** and **Telegram** nodes (use BotFather).  \n   - **AI/ML API**: Add your API key under the **AI/ML account** credential.  \n\n2. \u2705 **Activate the Workflow**  \n   - Toggle **Active** in the canvas header.  \n\n3. \ud83d\udcac **Send a Message in Telegram**  \n   - Prefix with **#vent**, **#insight**, or **#cope** for specific support modes.  \n   - Or send any text without a tag for a general empathic response.  \n\n4. \u23f3 **Observe \u201cTyping\u2026\u201d Indicator**  \n   - The **Show Typing Indicator** node signals the bot is processing.  \n\n5. \ud83e\udd16 **Receive Your AI-Powered Reply**  \n   - A custom response is generated by the **Generate personalised answer** node and sent back to you.  \n"
      },
      "typeVersion": 1
    },
    {
      "id": "3afdea7a-997f-4593-b5f3-f0ae4592dae4",
      "name": "Vent prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        1856,
        464
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"prompt\": \"You are a compassionate therapist. The user is sharing their thoughts or feelings. Respond with empathetic validation, reflective listening, and gentle curiosity. Don\u2019t offer solutions unless explicitly asked.\"\n}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "bdf9d3e9-6430-4a13-b7fc-2fe570720c1f",
      "name": "Insight prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        1856,
        656
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"prompt\": \"Act as an insightful psychologist. Analyze the user\u2019s message and offer possible psychological insights or inner patterns behind their thoughts or behavior. Speak in clear, calm, and respectful language.\"\n}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "dd67ab30-9837-4e25-bee4-7011c49485ea",
      "name": "Cope prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        1856,
        848
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"prompt\": \"The user is facing a tough emotional moment. Suggest 1\u20132 simple coping strategies (e.g. grounding, reframing, breathwork) based on their situation. Keep the tone warm, supportive, and practical.\"\n}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "da096c11-0b37-40e7-ba94-4ab65f3cb890",
      "name": "Main prompt for all other messages",
      "type": "n8n-nodes-base.set",
      "position": [
        1856,
        1040
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"prompt\": \"You're a compassionate AI mental health assistant trained in supportive conversation. The user wrote a message without a clear tag. Gently interpret what they might be asking or needing \u2014 whether it's support, insight, tools, or just someone to listen. Respond with warmth, emotional intelligence, and clarity. Avoid sounding like a robot or giving generic answers. Make it feel real and human.\"\n}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "98cf523a-aaf9-4e73-968c-15fe3fa4d0ef",
      "name": "Generate personalised answer",
      "type": "n8n-nodes-aimlapi.aimlApi",
      "position": [
        2304,
        752
      ],
      "parameters": {
        "model": "openai/gpt-4o",
        "prompt": "={{ $json.prompt }}\n\nMessage:\n{{ $('Start: Receive Message on Telegram').item.json.message.text }}",
        "options": {},
        "requestOptions": {}
      },
      "credentials": {
        "aimlApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "292e839f-2843-486f-9a83-3624f0e8fdc0",
      "name": "Send message to Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2528,
        752
      ],
      "parameters": {
        "text": "={{ $json.content }}",
        "chatId": "={{ $('Start: Receive Message on Telegram').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "21b81566-ae81-483b-8430-71766e380426",
      "name": "Show Typing Indicator",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1232,
        752
      ],
      "parameters": {
        "chatId": "={{ $('Start: Receive Message on Telegram').item.json.message.chat.id }}",
        "operation": "sendChatAction"
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4d5093cf-bd4b-4435-b1bb-87d3befd4cf7",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1392,
        640
      ],
      "parameters": {
        "height": 288,
        "content": "### Checks message.text for #vent, #insight, #cope, or falls back"
      },
      "typeVersion": 1
    },
    {
      "id": "9f5bc824-0d97-4009-83fe-781cfc4892a6",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1552,
        -80
      ],
      "parameters": {
        "width": 368,
        "height": 320,
        "content": "## \ud83d\udd0d Node Overview\n\n- **Telegram Trigger**: Listens for incoming messages.  \n- **Show Typing Indicator**: Immediately shows \u201ctyping\u2026\u201d in chat.  \n- **Route by Input Type (Switch)**: Detects your tag and routes to the right prompt.  \n- **Vent/Insight/Cope/Main Prompt**: Builds the JSON payload for the AI/ML API.  \n- **Generate personalised answer**: Calls the AI/ML API (model: `openai/gpt-4o`).  \n- **Send message to Telegram**: Delivers the AI\u2019s reply back into your chat.  "
      },
      "typeVersion": 1
    },
    {
      "id": "42a676f1-815f-4fc7-b537-4550f4ca8852",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1792,
        320
      ],
      "parameters": {
        "width": 224,
        "height": 896,
        "content": "## Chooses from given prompts"
      },
      "typeVersion": 1
    },
    {
      "id": "09df03c2-96dc-4872-bb52-213506ac8a72",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2272,
        656
      ],
      "parameters": {
        "width": 384,
        "height": 272,
        "content": "## Generates and sends answer to Telegram"
      },
      "typeVersion": 1
    },
    {
      "id": "e0c4e11c-ce6b-4c39-ad13-9108bfcaeda1",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1952,
        -80
      ],
      "parameters": {
        "width": 368,
        "height": 320,
        "content": "## **Example:**\n\n## ```#vent I\u2019m feeling anxious about my presentation```\n\n## \u2192 ```\u201cI hear that you\u2019re worried\u2026 can you tell me more about what\u2019s on your mind?\u201d```\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Cope prompt": {
      "main": [
        [
          {
            "node": "Generate personalised answer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Vent prompt": {
      "main": [
        [
          {
            "node": "Generate personalised answer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insight prompt": {
      "main": [
        [
          {
            "node": "Generate personalised answer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Input Type": {
      "main": [
        [
          {
            "node": "Vent prompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Insight prompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Cope prompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Main prompt for all other messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Show Typing Indicator": {
      "main": [
        [
          {
            "node": "Route by Input Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate personalised answer": {
      "main": [
        [
          {
            "node": "Send message to Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Main prompt for all other messages": {
      "main": [
        [
          {
            "node": "Generate personalised answer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start: Receive Message on Telegram": {
      "main": [
        [
          {
            "node": "Show Typing Indicator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

Source: https://n8n.io/workflows/6556/ — original creator credit. Request a take-down →

More Slack & Telegram workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Slack & Telegram

This n8n workflow enables Telegram users to interact with multiple AI models dynamically using #model_id commands. It also supports a /models command to list all available models. Each user has a dail

Telegram Trigger, Google Sheets, Telegram +2
Slack & Telegram

This workflow transforms your Telegram bot into a smart AI-powered travel assistant that instantly creates 3-day trip plans for any city in the world. Users can personalize trips by sending hashtags s

N8N Nodes Aimlapi, Telegram, Telegram Trigger
Slack & Telegram

This n8n workflow turns Telegram into a personal language tutor. Users can choose between different learning modes — vocabulary, grammar, quiz, or mixed lessons — simply by adding a hashtag to their m

Telegram Trigger, N8N Nodes Aimlapi, Telegram
Slack & Telegram

This n8n workflow lets users chat with GPT-5 directly in Telegram. It simulates typing for a natural UX, sends messages to GPT-5 via AI/ML API, and replies back in the same chat. Optionally, each inte

Telegram Trigger, Google Sheets, N8N Nodes Aimlapi +1
Slack & Telegram

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

Telegram Trigger, n8n, Telegram +4