Telegram Bot for Sports Participant Registration

Job ID: 39157226

Budget: $10 – $30 USD

Technical Specification: Development of a Telegram Bot for Registration of Phygital Sports Participants on Make.com
1. General Requirements
Objective: To develop a Telegram bot on the Make.com platform that replicates the functionality of an existing bot (as provided in the JSON scenario), designed to process messages from Telegram users, manage the registration process for phygital sports participants, and store data in Google Sheets.

Platform: Make.com (formerly Integromat).
Type: Automation scenario consisting of multiple modules (triggers, actions, and routers).
External APIs:
Telegram Bot API for receiving and sending messages (via "Telegram - Watch Updates" and "Telegram - Send a Text Message or a Reply" modules).
Google Sheets API for data storage (via "Google Sheets - Add a Row" module).
Data Storage: Make.com Data Store for temporary storage of registration states (replacing any external database).
Context: The bot must fully replicate the logic of the existing Telegram bot implemented in Make.com, preserving message handling routes and step-by-step registration as per the provided JSON.
2. Functional Requirements
The scenario must:

Operate as a Telegram Bot:
Use the "Telegram - Watch Updates" module to receive messages via Webhook or polling.
Handle commands /start, Registration, Finish, and responses to registration steps.
Send a Welcome Message:
Upon receiving the /start command, send:
text
Перенос
Копировать
Hello! ?\n\nI am the dispatcher bot of the Phygital Sports Federation.\nSend 'Registration' to start the event registration process.\n\nData will be saved to the table: [Link to table](https://docs.google.com/spreadsheets/d/1whGZ1RefscCSiVNnVUGaXWiISnXa59EhXqxwmTXG3Vo/edit?usp=sharing)
Module: "Telegram - Send a Text Message or a Reply" with a filter for {{1.message.text}} = "/start".
Manage the Registration Process:
After the Registration command, initiate a step-by-step data collection process (8 steps).
Store intermediate data in a Make.com Data Store using {{1.message.chat.id}} as the unique key.
After collecting all data, save it to Google Sheets.
Registration Steps:
Sequence of questions (mirroring the existing JSON):
"Specify the discipline name"
"Specify the team name (or 'Individual')"
"Specify full name (FIO)"
"Specify contact phone number"
"Specify date of birth (DD.MM.YYYY)"
"Specify city of residence"
"Specify organization/educational institution"
"Specify comment (or 'No comments')"
Use "OpenAI - Create a Completion" module to generate questions based on the current step (step stored in Data Store).
After each response, update the Data Store with the user’s input and increment step.
After the 8th step, save the data to Google Sheets.
Complete Registration:
Upon receiving the Finish command:
Send: "Registration completed. Would you like to add a red line to the table? Reply 'Yes'."
If "Yes" is received, add an empty row with a red background in Google Sheets using "Google Sheets - Add a Row" and "HTTP - Make a Request" modules.
Reset the state in the Data Store (step = 0).
Error Handling:
If an error occurs while writing to the Data Store or Google Sheets, send a message: "An error occurred while saving data. Please try again in a minute."
Use error handlers (e.g., "Break" or "Ignore") for critical modules with a fallback "Telegram - Send a Text Message or a Reply" module.
3. Architecture on Make.com
3.1. Main Modules
Trigger: Telegram - Watch Updates (ID 1):
Receives incoming messages from Telegram.
Output: 1.message.text (message content), 1.message.chat.id (chat ID).
Router: Basic Router (ID 2):
Routes messages to different flows based on content:
Route 1: /start.
Route 2: Registration.
Route 3: Registration steps.
Route 4: Finish.
Flow 1: Welcome Message:
Module: "Telegram - Send a Text Message or a Reply" (ID 3).
Filter: {{1.message.text}} = "/start".
Action: Send the welcome message.
Flow 2: Start Registration:
Module: "OpenAI - Create a Completion" (ID 24).
Filter: {{lower(trim(1.message.text))}} = "registration" AND {{1.message.text}} exists.
Action: Generate the first question ("Specify the discipline name").
Module: "Telegram - Send a Text Message or a Reply" (ID 5).
Action: Send the generated question.
Module: "Data Store - Add/Replace a Record" (ID 25).
Key: {{1.message.chat.id}}.
Data: { "step": 1, "discipline": "", "team": "", "fio": "", "phone": "", "birthdate": "", "city": "", "organization": "", "comment": "" }.
Overwrite: True.
Flow 3: Registration Steps:
Module: "Data Store - Get a Record" (ID 23).
Filter: {{1.message.text}} ≠ "/start" AND ≠ "Registration" AND ≠ "Finish".
Key: {{1.message.chat.id}}.
Module: "OpenAI - Create a Completion" (ID 27).
Filter: {{parseNumber(if(23.step = emptystring or 23.step = null; 0; 23.step))}} ≥ 0 AND ≤ 8.
Action: Generate the next question based on 23.step and 1.message.text.
Module: "Data Store - Add/Replace a Record" (ID 26).
Filter: Same as ID 27.
Key: {{1.message.chat.id}}.
Data: Update fields based on step (e.g., discipline for step 1, team for step 2) and increment step.
Overwrite: True.
Module: "Telegram - Send a Text Message or a Reply" (ID 21).
Filter: Same as ID 27.
Action: Send the generated question.
Module: "Google Sheets - Add a Row" (ID 15).
Filter: {{parseNumber(if(23.step = emptystring or 23.step = null; 0; 23.step))}} = 9.
Action: Save all data to Google Sheets.
Flow 4: Finish Registration:
Module: "Telegram - Send a Text Message or a Reply" (ID 9).
Filter: {{1.message.text}} = "Finish".
Action: Send "Registration completed. Would you like to add a red line to the table? Reply 'Yes'."
Module: "Data Store - Add/Replace a Record" (ID 31).
Key: {{1.message.chat.id}}.
Data: Reset to { "step": 0, ... }.
Module: "Google Sheets - Add a Row" (ID 14).
Filter: {{1.message.text}} = "Yes".
Action: Add an empty row.
Module: "Set Multiple Variables" (ID 28).
Action: Calculate row indices for the red line.
Module: "HTTP - Make a Request" (ID 16).
Action: Apply red background to the empty row.
Module: "Telegram - Send a Text Message or a Reply" (ID 13).
Action: Send "Registration completed, data saved, red line added."
3.2. Google Sheets Architecture
Spreadsheet ID: 1whGZ1RefscCSiVNnVUGaXWiISnXa59EhXqxwmTXG3Vo (from the original JSON).
Sheet Name: registration (from module ID 15).
Table Structure:
Columns (mirroring module ID 15):
Date and time of entry (DD.MM.YYYY HH:mm).
Discipline name.
Team name.
Full name (FIO).
Phone number.
Date of birth and age (DD.MM.YYYY (X years)).
City.
Organization.
Comment.
Data Addition Format:
Data appended to the end of the table (INSERT_ROWS).
Upon "Yes" response to Finish, an empty row with a red background (RGB: 1.0, 0.0, 0.0) is added via HTTP request.
3.3. Data Store Structure
Data Store Name: RegistrationState (or custom ID, e.g., 56381).
Fields:
chat_id (Text, key).
step (Number).
discipline, team, fio, phone, birthdate, city, organization, comment (Text).
4. Technical Requirements
Modules:
"Telegram - Watch Updates" and "Telegram - Send a Text Message or a Reply" for Telegram integration.
"OpenAI - Create a Completion" for generating questions.
"Data Store - Add/Replace a Record" and "Data Store - Get a Record" for state management.
"Google Sheets - Add a Row" and "HTTP - Make a Request" for Google Sheets integration.
Configuration:
Telegram connection (e.g., __IMTCONN__: 6087310).
OpenAI connection (e.g., __IMTCONN__: 6087333).
Google Sheets connection (e.g., __IMTCONN__: 6087358).
Error Handling:
Use "Break" error handlers requiring "Store incomplete executions" to be enabled in scenario settings.
5. Development Stages
Scenario Setup (1 day):
Configure Telegram, OpenAI, and Google Sheets connections.
Set up the Data Store.
Welcome Flow (ID 3) (1 day):
Implement /start handling.
Registration Start Flow (ID 24, 5, 25) (2 days):
Build the initial registration route.
Registration Steps Flow (ID 23, 27, 26, 21, 15) (3 days):
Implement step logic and Google Sheets integration.
Finish Flow (ID 9, 31, 14, 28, 16, 13) (2 days):
Handle completion and red line addition.
Error Handling and Testing (2 days):
Add error handlers and test all flows.
Total time: ~11 working days (with one developer).

6. Acceptance Criteria
Acceptance Criteria:
Bot responds to /start with the welcome message.
After Registration, it requests data step-by-step (1–8).
Data is correctly saved to Google Sheets in the specified structure.
Upon Finish and "Yes", a red row is added.
Errors are handled with user notifications.
7. Notes
Developers must base the implementation on the provided Make.com JSON scenario.
Ensure Google Sheets API is configured with write permissions for spreadsheet 1whGZ1RefscCSiVNnVUGaXWiISnXa59EhXqxwmTXG3Vo.
Enable "Store incomplete executions" in Make.com scenario settings for error handling.
Related categories: C Programming Make.com