Chat with us
Up to 60% OFF with Recurring Discounts on Premium Upgrades & Whitelabel FlexUp to 60% OFF on Premium Upgrade & Whitelabel03:00:00:00Claim
Knowledgebase/Automation/Article

How to Set Up BotSailor Telegram Outbound Webhook with Google Sheets: Complete Step-by-Step Guide

  • 11 Nov 2026
  • 12 min read
  • 0 views
TL;DR:

 Learn how to set up a BotSailor Telegram outbound webhook with Google Sheets using Google Apps Script to automatically collect and organize customer leads.


In this tutorial, you will connect a Telegram bot in BotSailor to Google Sheets using a Google Apps Script Web App webhook. This setup collects subscriber details through a User Input Flow and stores the submitted information in an organized spreadsheet.

Prerequisites

Before starting the integration, make sure you have access to the following tools and accounts.

  1. 1BotSailor Account: An active BotSailor account with access to Chatbot Manager and Outbound Actions.
  2. 2Telegram Bot: A connected Telegram bot that you can use to collect customer information.
  3. 3Google Account: An active Google account to create and manage Google Sheets and Google Apps Script projects.
  4. 4Google Spreadsheet: A new spreadsheet where customer information will be stored.
  5. 5User Input Flow: A BotSailor User Input Flow configured to collect customer details.
  6. 6Webhook URL: A deployed Google Apps Script Web App URL that will receive data from BotSailor.


Step-by-Step Instructions

Step 1: Create a Google Spreadsheet

First, create a new Google Spreadsheet to store the customer information collected from your Telegram bot.

  1. 1 OpenGoogle Sheets .
  2. 2 Create a new blank spreadsheet.
  3. 3 Give your spreadsheet a recognizable name, such as BotSailor Telegram Leads .
  4. 4 Rename the worksheet to Sheet1 .
  5. 5 Add the following column headers in Row 1:

Column

Header

A

First Name

B

Email

C

Phone Number

D

Input Flow Data

These columns will organize the customer information received from BotSailor.

Important: Keep the column names and their order consistent with the Apps Script configuration.


Blank Google Sheets spreadsheet created to collect BotSailor Telegram user leads through webhook integration.
Create a new Google Sheets spreadsheet to store Telegram leads collected through BotSailor.



Step 2: Open Google Apps Script

Next, create a Google Apps Script project to process incoming webhook requests.

  1. 1 Open your Google Spreadsheet.
  2. 2 Navigate to Extensions in the top menu.
  3. 3 Select Apps Script .
  4. 4 A new Apps Script project will open.
  5. 5 Rename the project to BotSailor Webhook .
  6. 6 Open the default Code.gs file.

Google Apps Script will act as the intermediary between BotSailor and Google Sheets.


Google Sheets Extensions menu highlighted for opening Google Apps Script to configure a BotSailor webhook.
Open the Extensions menu in Google Sheets and select Apps Script.


Step 3: Configure the Google Apps Script

Now configure the Apps Script project to receive customer information, extract the answers, and save them into the correct spreadsheet columns.


First, identify your Google Spreadsheet ID.

You can find the Spreadsheet ID in its URL:

https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit

Copy the ID between /d/ and /edit .

Next, replace the existing code in Code.gs with the following script.

Code placeholder

[PASTE THE ORIGINAL GOOGLE APPS SCRIPT CODE HERE — the supplied source article refers to this script, but the code itself is not included in the uploaded content.]



Google Apps Script editor displaying BotSailor webhook integration code for connecting Telegram leads to Google Sheets.
Add the Google Apps Script code to connect BotSailor with your Google Sheets spreadsheet.


Important configuration notes:

  • ● Replace YOUR_SPREADSHEET_ID with your actual Google Spreadsheet ID.
  • ● Keep SHEET_NAME set to Sheet1 , unless you have used a different worksheet name.
  • ● Do not remove the doGet() or doPost() functions.
  • ● The doGet() function provides a simple webhook health-check response.
  • ● The doPost() function processes incoming customer information.
  • ● The extractAnswers() function identifies the answers associated with the User Input Flow questions.
  • ● The script stores the extracted answers in separate columns and preserves the complete input flow data in JSON format.

Step 4: Deploy the Google Apps Script as a Web App

After adding the code, deploy the project to make it accessible through a Web App URL.

  1. 1 Click the Save icon in the Apps Script editor.
  2. 2 Click the Deploy button in the upper-right corner.
  3. 3 Select New deployment .
  4. 4 Click the deployment type selector (gear icon).
  5. 5 Choose Web app .
  6. 6 Add a suitable description, such as BotSailor Telegram Webhook .
  7. 7 Set Execute as to Me .
  8. 8 Set Who has access to Anyone .
  9. 9 Click Deploy .

If Google requests authorization, follow the on-screen instructions to authorize the script to access your Google Spreadsheet.

Once deployment is complete, Google Apps Script will generate a Web App URL.




Google Apps Script deployment menu showing the New deployment option for publishing the BotSailor webhook.
Click Deploy and select New deployment to publish your webhook as a web app.


Step 5: Copy the Web App URL

After successfully deploying the project:

  1. 1 Open the deployment confirmation window.
  2. 2 Locate the Web app section.
  3. 3 Find the URL displayed under the Web App section.
  4. 4 Click Copy to copy the URL.
  5. 5 Keep this URL available because you will need it in BotSailor.

Important: Copy the Web App URL, not the Deployment ID or Library URL.

The Web App URL is the endpoint that BotSailor will use to send customer information to Google Apps Script.




Successful Google Apps Script web app deployment confirmation displaying the webhook URL for BotSailor integration.
Copy the deployed web app URL to connect your Google Apps Script webhook with BotSailor.


Step 6: Create a User Input Flow in BotSailor

Before configuring the outbound webhook, create the input flow that collects information from Telegram subscribers.

  1. 1 Log in to your BotSailor account.
  2. 2 Navigate to Chatbot Manager .
  3. 3 Select your connected Telegram bot.
  4. 4 Open the Data Collection tab.
  5. 5 Select User Input Flows .
  6. 6 Click Create .
  7. 7 Give your flow a recognizable name, such as Real-Life Example: User Input Flow in BotSailor .

Now configure the flow using the following blocks:

  • ●Start Bot Flow: Define the entry keyword, such as hi .
  • ●Text Block: Send an introductory message asking users to provide their details.
  • ●User Input Flow Block: Connect the data collection process.
  • ●New Question 1: Ask, "What is your first name?" Select the Text reply type and use First Name as the saved field.
  • ●New Question 2: Ask, "What is your email address?" Select the Email reply type and use Email as the saved field.
  • ●New Question 3: Ask, "What is your phone number?" Select the Number reply type and use Phone as the saved field.
  • ●Final Text Block: Send a confirmation message, such as "Your information has been received successfully. Our team will contact you soon."

Connect the blocks in the correct sequence so that each question leads to the next one.

Click Save when the flow is complete.

BotSailor chatbot manager Data Collection section showing Telegram bot selection and User Input Flow creation.
BotSailor chatbot manager Data Collection section showing Telegram bot selection and User Input Flow creation.

Navigate to your Telegram bot's Data Collection section and create a new User Input Flow.



BotSailor User Input Flow builder showing connected message, name, email, and phone number collection blocks.
Build a Telegram lead collection flow with questions for first name, email address, and phone number.

Step 7: Configure the BotSailor Outbound Webhook

Now connect your Google Apps Script Web App to BotSailor using the Outbound Actions feature.

  1. 1 Return to Chatbot Manager .
  2. 2 Select your Telegram bot.
  3. 3 Open the Automation tab.
  4. 4 Select Outbound Actions .
  5. 5 Click Create .

A configuration panel will appear.

Complete the following settings:

Webhook Name:

Enter a recognizable name, such as Telegram Customer Leads .

Outbound Webhook URL:

Paste the Google Apps Script Web App URL copied in Step 5.

Select Actions That Will Trigger the Webhook:

Enable:

  • ● User Input Flow

Then select the User Input Flow you created in Step 6.

Select Data Fields That Will Be Sent:

Enable the following fields:

  • ● First Name
  • ● Email
  • ● Phone Number
  • ● Input Flow Data

Keep other fields disabled unless you specifically need them.

Finally, click Save to complete the BotSailor webhook configuration.

This configuration tells BotSailor when to send the collected customer information and which data fields to include in the request.

Screenshot placement: BotSailor Outbound Actions configuration panel showing the webhook URL, selected User Input Flow, and enabled data fields.


BotSailor Automation Outbound Actions dashboard showing the option to create a new Telegram webhook.
Open Automation, select Outbound Actions, and click Create to configure your webhook.
BotSailor outbound webhook configuration panel showing webhook URL, User Input Flow trigger, and selected lead data fields.
Configure the webhook URL, select your User Input Flow trigger, and choose the customer information to send.

Step 8: Test the Telegram Bot

After configuring the outbound webhook, test the complete integration using your Telegram bot.

  1. 1 Open Telegram.
  2. 2 Search for your connected bot.
  3. 3 Start a new conversation or restart the existing test conversation.
  4. 4 Send /start or the configured entry keyword.
  5. 5 Send hi to trigger the User Input Flow.
  6. 6 Answer the first-name question.
  7. 7 Enter a valid email address.
  8. 8 Enter a phone number.
  9. 9 Wait for the final confirmation message.

For example, use the following test information:

Question

Example Answer

First Name

Mahafuz

Email

Mahafuz@gmail.com

Phone Number

01780860566

After submitting all three answers, the bot should display:

"Your information has been received successfully. Our team will contact you soon."

This confirms that the Telegram conversation has reached the final stage of the input flow. The next step is to verify the webhook execution and spreadsheet output.



Telegram mobile bot conversation showing successful collection of a user's name, email address, and phone number through BotSailor.
Test the complete Telegram lead collection workflow on a mobile device.


Telegram desktop bot displaying successful user input flow completion and automated customer contact information collection.
Confirm that the Telegram bot successfully collects user details and displays the submission confirmation message.


Google Apps Script execution history showing completed doPost and doGet webhook requests for BotSailor Telegram lead integration.
Check Google Apps Script execution logs to verify successful webhook requests and data processing.


Step 9: Verify the Google Apps Script Execution

Now verify whether BotSailor successfully triggered the deployed Google Apps Script Web App.

  1. 1 Open your Google Apps Script project.
  2. 2 Click Executions in the left sidebar.
  3. 3 Review the recent execution records.
  4. 4 Find the latest doPost execution.
  5. 5 Check the Status column.

A successful request should display:

  • ● Function: doPost
  • ● Type: Web App
  • ● Deployment: Latest deployed version
  • ● Status: Completed

You can also check the doGet execution if you have performed a health check.

Important: A Completed status confirms that the Apps Script execution finished without an uncaught error. You should also inspect the Google Sheet to verify that the expected values were actually written.


Google Sheets showing automatically collected Telegram lead information, including first names, email addresses, phone numbers, and User Input Flow responses.
View the collected Telegram customer leads and submitted form responses directly in Google Sheets.

Step 10: Verify the Final Google Sheets Output

Finally, open your BotSailor Telegram Leads spreadsheet and inspect the latest submitted customer record.

The Apps Script should organize the information into four separate columns.

First Name

Email

Phone Number

Input Flow Data

Mahafuz

Mahafuz@gmail.com

01780860566

Complete JSON data

The first three columns contain the individual answers submitted by the Telegram subscriber.

The fourth column stores the complete User Input Flow data in JSON format, including the original questions and their corresponding answers.

For example, the JSON data can contain:

                                                                                                                                      
[ { "question": "What is your first name?", "answer": "Mahafuz" }, { "question": "What is your email address?", "answer": "Mahafuz@gmail.com" }, { "question": "What is your phone number?", "answer": "01780860566" } ]

Each completed submission should create a new row in the spreadsheet without overwriting previously collected leads.

Final Result: Your BotSailor Telegram outbound webhook is now connected to Google Sheets. Customer information is automatically collected, processed, and stored in an organized format.


Success Verification

Use this checklist to confirm that the integration is working correctly.

  • ● Google Spreadsheet created with the correct four headers.
  • ● Google Apps Script configured with the correct Spreadsheet ID.
  • ●doGet() and doPost() functions added successfully.
  • ● Google Apps Script deployed as a Web App.
  • ● Web App URL copied correctly.
  • ● BotSailor User Input Flow created and saved.
  • ● Outbound Actions configured with the correct webhook URL.
  • ● User Input Flow trigger enabled.
  • ● First Name, Email, Phone Number, and Input Flow Data enabled.
  • ● Telegram test conversation completed successfully.
  • ● Apps Script doPost execution status shows Completed.
  • ● Customer details appear in their respective Google Sheets columns.
  • ● Complete input flow data is stored in the fourth column.

When all these checks pass, your integration is working as expected.



Google Sheets showing automatically collected Telegram lead information, including first names, email addresses, phone numbers, and User Input Flow responses.
View the collected Telegram customer leads and submitted form responses directly in Google Sheets.




Troubleshooting

1. Google Sheets Receives the Entire JSON Data in One Column

Possible cause: The Apps Script is saving the complete webhook payload without extracting the individual answers.

Solution:

  • ● Check that the extractAnswers() function is included.
  • ● Confirm that the script reads user_input_data .
  • ● Make sure the question text matches the extraction conditions.
  • ● Verify that the setValues() method writes four separate values into columns A, B, C, and D.
  • ● Save and deploy a new version of the Web App.

2. First Name, Email, or Phone Number Appears Blank

Possible cause: The webhook payload contains empty profile fields, while the actual answers are nested inside the User Input Flow data.

Solution:

  • ● Inspect the incoming payload structure.
  • ● Confirm that the answers are available under user_input_data .
  • ● Verify the question labels used in the User Input Flow.
  • ● Check the field extraction logic in Apps Script.

3. Apps Script Execution Shows an Error

Possible cause: The spreadsheet ID, worksheet name, authorization, or script configuration may be incorrect.

Solution:

  • ● Verify the Google Spreadsheet ID.
  • ● Confirm that the worksheet name matches Sheet1 .
  • ● Check Google Apps Script permissions.
  • ● Open the failed execution to inspect its error details.
  • ● Correct the issue and deploy a new version if the code changes.

4. BotSailor Is Not Sending Data to Google Sheets

Possible cause: The outbound webhook may not be configured correctly.

Solution:

  • ● Verify the Web App URL.
  • ● Make sure the User Input Flow trigger is enabled.
  • ● Confirm that the correct flow is selected.
  • ● Enable the required data fields.
  • ● Save the Outbound Actions configuration.
  • ● Test the Telegram conversation again.

5. Google Sheets Does Not Show New Records

Possible cause: The webhook may not be reaching the correct spreadsheet or worksheet.

Solution:

  • ● Check the Spreadsheet ID in Apps Script.
  • ● Verify the worksheet name.
  • ● Review recent doPost executions.
  • ● Check the last populated row.
  • ● Confirm that the deployment uses the latest code version.

6. Phone Numbers Lose Their Leading Zero

Possible cause: Google Sheets may automatically interpret phone numbers as numeric values.

Solution:

The provided Apps Script formats the destination row as text before inserting the values using setNumberFormat("@") . This helps preserve leading zeros in phone numbers.


Next Steps

Once your Telegram-to-Google-Sheets integration is working, you can extend the workflow to support more advanced lead management.

Consider the following improvements:

  1. 1Lead Management: Add customer status, lead source, submission date, and follow-up status columns.
  2. 2Email Notifications: Notify your sales team when a new customer submits the User Input Flow.
  3. 3CRM Integration: Connect Google Sheets with your preferred CRM to manage leads centrally.
  4. 4Automated Follow-ups: Create follow-up sequences in BotSailor to engage subscribers after submitting their information.
  5. 5Lead Reporting: Use Google Sheets dashboards to monitor submissions and customer acquisition activity.
  6. 6Additional Data Collection: Extend your User Input Flow to collect location, service preferences, or other relevant information.

These improvements can help turn a basic Telegram data collection process into a more organized lead management system.



For more information, visit the official BotSailor guide about the related integration: [ADD OFFICIAL GUIDE URL]

Sanoary Rahaman Istiaque

Sanoary Rahaman Istiaque

FAQ

Frequently Asked Questions

Find answers to common questions about this topic

A BotSailor outbound webhook is an integration feature that sends selected bot event data to an external URL when a configured action occurs. It allows BotSailor to share customer information with platforms such as Google Sheets through a Web App endpoint.

Yes. You can connect BotSailor to Google Sheets using Google Apps Script. Deploy an Apps Script project as a Web App, copy its URL, and configure it in BotSailor's Outbound Actions.

For the method described in this guide, yes. Google Apps Script receives the webhook request, processes the submitted customer information, and writes the results into Google Sheets.

An inbound webhook generally allows an external system to send information or trigger an action in a platform. An outbound webhook sends information from BotSailor to an external endpoint when a configured event occurs.

The available fields depend on the BotSailor configuration. In this tutorial, the selected fields are First Name, Email, Phone Number, and Input Flow Data.

The Input Flow Data field contains the complete submitted question-and-answer structure. If your script writes the entire payload into a single cell, you need to parse the nested data and map each answer to its corresponding spreadsheet column.

Yes. The provided script uses the next available row to store each new submission. This allows multiple customer records to be collected in the same spreadsheet.

You can review the Executions section in Google Apps Script. Look for recent doPost records with a Completed status. Then open Google Sheets and verify that the customer information has been saved correctly.

Yes. When you modify the deployed Web App code, create a new deployment version through Manage deployments. The existing Web App URL can generally remain unchanged when you update the existing deployment.

Yes. You can extend the User Input Flow and update the Apps Script extraction and spreadsheet mapping logic to support additional fields, such as location, service preferences, or customer requirements.

Related Articles

Knowledgebase

How to Collect Customer Email Addresses on Telegram Using BotSailor

Sanoary Rahaman Istiaque
Sanoary Rahaman Istiaque
  • 15 Oct 2026
Knowledgebase

How to Create a Location Reply Button for a Telegram Bot in BotSailor

Sanoary Rahaman Istiaque
Sanoary Rahaman Istiaque
  • 15 Oct 2026
Knowledgebase

How to Create a Birthday Reply Button for a Telegram Bot in BotSailor

Sanoary Rahaman Istiaque
Sanoary Rahaman Istiaque
  • 15 Oct 2026
Knowledgebase

How to Create a Keyword Based Telegram Chatbot : Step-by-Step Guide

Sanoary Rahaman Istiaque
Sanoary Rahaman Istiaque
  • 8 Nov 2026
Knowledgebase

How to Send Sequence Messages on Telegram Using BotSailor

Sanoary Rahaman Istiaque
Sanoary Rahaman Istiaque
  • 9 Nov 2026
Knowledgebase

How to Set Up a Get Started Message in Telegram: Step-by-Step Guide

Sanoary Rahaman Istiaque
Sanoary Rahaman Istiaque
  • 9 Nov 2026