TradingView Chart Telegram Bot (Part1)

5 min readMar 31


In this tutorial, I will help you set up, configure and run the TradingView Chart Telegram Bot based on CHART-IMG API using Docker, Local Server with NodeJS NPM, and Serverless Cloudflare Workers. By the end of this tutorial, you should be able to run your Telegram Bot with customized preset indicators.

Before we continue, I recommend reviewing the project on GitHub and
the CHART-IMG API documentation.

The upcoming update to the CHART-IMG website will allow users to run a fully managed Telegram Bot Server with customized configuration.

Live Telegram Bot



To set up the server, you will need the following requirements:

  • Telegram Bot API Token
  • CHART-IMG API Access Key
  • NGROK Auth Token if you want to run your server
  • Cloudflare Account if you want to use Serverless

Telegram Bot API Token

The first step in building a Telegram bot is to chat with the Telegram Bot Father. To create a new bot, use the /newbot command and choose a name and username. The Bot Father will provide a token for the authentication.


To obtain your access key, log in to using your Google account and generate it. Please note that without the subscription, the chart will have a watermark and a maximum resolution of 800x600, which should be enough for this project.

NGROK Auth Token (Deploy option #1)

To run your server, you need a secure proxy tunnel to forward the Telegram webhook payload to your local server. I recommend using NGROK. You can create an account at and get a free Auth Token. The free version has restricted bandwidth and usage. Please refer to their price plan for more detail.

Cloudflare Account (Deploy option #2)

Cloudflare Workers is a Serverless platform that enables instant code deployment globally, ensuring exceptional performance, reliability, and scalability. You don’t have to manage your server, and it’s free for up to 100,000 requests per day, which is more than enough. Create an account at

Clone the project repository

Let’s download the project source code to your computer. If you have git installed, run the following command:

git clone

If you do not have git installed, you can download the ZIP file from the GitHub repository.

After the git clone command or unzipping the file, go to the root directory of the project by entering the following command:

cd chart-img-telegram-bot



This file is a vital component of the project, as it allows for customization of the preset inputs and messages for the Telegram Bot.

"version": 1,
"/chart": {
"intervals": ["5m", "15m", "1h", "4h", "1D", "1W"],
"default": {
"symbol": "CAPITALCOM:US100",
"interval": "1D",
"theme": "dark"
"commands": [
"command": "/start",
"description": "Introduction"
"command": "/chart",
"description": "TradingView <exchange:symbol> <interval>"
"command": "/example",
"description": "Command Examples"
"messages": [
"name": "/start",
"text": "Hello, Welcome message..."
"name": "/example",
"text": "List of examples..."
"private": {
"enabled": true,
"allowFromIds": [12345678, 12345679]
"group": {
"enabled": false

To better understand the differences between API versions, I suggest reviewing the API documentation for both version 1 and version 2 of the TradingView Advanced Chart.

Additionally, look at the config1.json and config2.json files in the examples folder. These files contain the same indicator inputs but are for each API version. The project documentation outlines specific configuration requirements that you have to follow.


This file is an important part of the project as it stores the credentials necessary to access the required APIs.

Replace the variables with the previous requirements mentioned earlier.

name = "chart-img-telegram-bot"

main = "src/index.js"
compatibility_date = "2022-11-30"

TELEGRAM_SECRET_TOKEN = "somethingRandomHere"

TELEGRAM_SECRET_TOKEN is to make sure the webhook payload is from the Telegram Server. Replace the variable with a random string that only you know. NGROK_TOKEN is only necessary if you intend to run your local server without your own proxy to forward the webhook payload.


Make sure to have two files wrangler.toml and config.json ready with the necessary credentials and configurations.

Deploy with Docker Image

If you have Docker installed, this would be the simplest way to run the server with just two files.

Replace <PATH> with the absolute file path for each wrangler.toml and config.json.

docker run --restart=always --name telegram-bot -v <PATH>/wrangler.toml:/chart-img-telegram-bot/wrangler.toml -v <PATH>/config.json:chart-img-telegram-bot/config.json -d hawooni/chart-img-telegram-bot:latest

Example if you use Linux:

docker run --restart=always --name telegram-bot \
-v $(pwd)/wrangler.toml:/chart-img-telegram-bot/wrangler.toml \
-v $(pwd)/config.json:/chart-img-telegram-bot/config.json \
-d hawooni/chart-img-telegram-bot:latest

Deploy with NodeJS & NPM

Ensure you have the latest NPM and NodeJS, preferably using a Node version manager like Volta or NVM to avoid permission issues and easily change NodeJS versions. You can download the latest NodeJS at

Let’s install the necessary packages before we can run the server.

npm install

Run the server locally with port 8080.

npm run server-local -- --ip --port 8080
> chart-img-telegram-bot@1.0.3 server-local
> npx wrangler dev --ip --port 8080

⛅️ wrangler 3.3.0
wrangler dev now uses local mode by default, powered by 🔥 Miniflare and 👷 workerd.
To run an edge preview session for your Worker, use wrangler dev --remote
Your worker has access to the following bindings:
- Vars:
⎔ Starting a local server...
[mf:inf] Ready on
│ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit │

Although you have started the server on your machine, it cannot receive the webhook sent by Telegram. You need NGROK or a secured proxy to forward the payload to your local server.

npm run ngrok -- --port 8080 -t
> chart-img-telegram-bot@1.0.3 ngrok
> node --no-warnings src/setup/ngrok --port 8080 -t

ngrok: connected
------------------------------------------------------ =>

This will run the NGROK proxy tunnel to forward the payload after updating the Telegram Webhook URL.

Your local server should be able to receive incoming messages and respond to your command with customized input indicators. If you encounter any issues or have questions, please don’t hesitate to share them in the comments section below.

In Part 2, I will guide you through deploying serverless using Cloudflare Workers.



Recommended from Medium


See more recommendations