How to create a TelegramBot using ZettaBlock GraphQL API

soham

Soham

Posted on January 4, 2023

How to create a TelegramBot using ZettaBlock GraphQL API

To create a bot using the ZettaBlock GraphQL API, you'll need to follow a few steps. First, make sure you have an API key and access to the ZettaBlock GraphQL endpoint where you will get API ID and API Key which you need to input in the .env file. Then, you'll need to create a bot on Telegram and then choose a programming language and a framework to build your bot with. Some popular options for building bots include Node.js, Python.

Follow the steps shown below to make an awesome Telegram Bot:

  1. Make a Data Query

Image description

  1. Create an SQL Query to fetch Solana tokens on the Mainnet-Beta(Here we are building a Solana Token Tracker Bot)
SELECT
  "name",
  "symbol",
  "decimals",
  "token_authority",
  "supply",
  "type",
  "address"
FROM
  solana_mainnet.token_metadata
LIMIT
  20 
Enter fullscreen mode Exit fullscreen mode
  1. Create API to Query the data. Indexed the data by selecting the name, symbol and supply field

Image description

  1. Get your API Key, API ID, Bot token and Hop on to Github

Github - TelegramBot

Run following command

npm i

Add API ID, API Key and Bot Token in .env.example and rename the file to .env

Now, run the following command and you're good to test your bot on Telegram

node index.js

💖 💪 🙅 🚩
soham
Soham

Posted on January 4, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related