Based on the provided code snippets and instructions, here's a step-by-step guide to creating a Telegram bot that fetches DEX swap quotes using the swapapi.dev API:
Step 1: Set Up Your Environment
First, ensure you have Node.js installed. You'll also need to install some packages for your project.
bash1npm init -y 2npm install node-fetch axios dotenv
Create a .env file in your project root and add the necessary environment variables:
plaintext1TELEGRAM_BOT_TOKEN=your_bot_token_here 2CHAT_ID=your_chat_id_here
Step 2: Create Telegram Bot
You can create a bot using BotFather on Telegram. Once you have the token, store it in .env.
Step 3: Initialize Your Project Files
Create index.js and set up your project structure.
javascript1require('dotenv').config(); 2const fetch = require('node-fetch'); 3const { AbortController } = require('abort-controller'); 4 5// Load environment variables 6const TELEGRAM_BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN; 7const CHAT_ID = process.env.CHAT_ID; 8 9// Telegram bot API endpoint 10const BASE 11 12[Read the full article at DEV Community](https://dev.to/moonsoon69/how-to-add-token-swaps-to-a-telegram-bot-40o4) 13 14--- 15 16**Want to create content about this topic?** [Use Nemati AI tools](https://nemati.ai) to generate articles, social posts, and more.

![[AINews] The Unreasonable Effectiveness of Closing the Loop](/_next/image?url=https%3A%2F%2Fmedia.nemati.ai%2Fmedia%2Fblog%2Fimages%2Farticles%2F600e22851bc7453b.webp&w=3840&q=75)



