-
Notifications
You must be signed in to change notification settings - Fork 4
Dev Hook
Dev Hook is an innovative feature designed for development purposes, facilitating a seamless testing and interaction experience with your Telegram bot without the need for deploying your code after each change. By leveraging the Dev Hook, developers can simply save their code and interact with their bot, streamlining the development process.
Dev Hook operates by using webhooks internally, in conjunction with a standard Google Apps Script project. Telesun integrates with middleware servers hosted on platforms such as Vercel
, Render
, and Google Apps Script
to make this possible. Here's a step-by-step breakdown of how it functions:
- Set the webhook to one of the supported servers.
- The Telegram Bot API server sends a POST request containing updates to the configured server.
- The server then calls the
doPost
function using the Google Apps Script API execution.
To utilize Dev Hook, follow these steps:
- Deploy your project as an "API Executable" within Google Apps Script settings.
- Create a standard Google Apps Script project and connect the project ID to your Apps Script project.
function doPost( e ){
const telesun = new Telesun.connectBot("YOUR_BOT_TOKEN")
.devHook(e, { server: "VERCEL" }); // Options: "GAS", "RENDER"
}
Replace "YOUR_BOT_TOKEN"
with your actual bot token. The server
option specifies which middleware server to use for handling the webhook.
Below is a simplified architecture diagram of the Dev Hook process:
[Telegram Bot API] --(POST request)--> [Middleware Server (e.g., VERCEL)] --(doPost)--> [Google Apps Script]
This diagram represents the flow from setting up the webhook, through the Telegram Bot API sending POST requests, to the middleware server executing the doPost
function in your Google Apps Script project.
- Telesun
- Getting Started - Apps script
- Getting Started with the Telesun Ready Template
- Import Telesun
- Telesun-Handlers
- Context Object
- Next Middleware
- Stages
- Manager Classes:
- Mail:
- Google Spreadsheet:
- Best Practice:
- Getting Updates:
- Example Types:
- Example Bots: