How to create an automated flow for a Telegram chatbot

The flow builder is the main tool to set up your bot to welcome new subscribers, assist users, sell products, and notify a manager about users’ questions in the chatbot. Also, a chatbot can gather information and send it to your system for future use.
All you need is to create keywords, design the bot’s structure, and drag-and-drop elements in the SendPulse flow builder.

Below you can find a detailed table of contents. Use it as a map for comfortable navigation to find all of the possible triggers and elements to get started adding them to your bot’s flow.

Choosing a trigger for your flow

By default, there are Welcome message, Standard reply, and Unsubscribe from bot flows. And you can create your own new triggers to get more functionality.

Choose your bot. Go to the Bot Structure tab and choose a trigger.

Welcome message flows

The flow starts after a user subscribes to your chatbot - i.e after clicking the “Start” button.

Users can subscribe by following a link to your bot https://t.me/username, finding the bot on the Telegram app by its @username or using a website widget.

This flow introduces your bot to users. Here you can write about your bot and its features - how the bot can be useful, what information bot can provide, and how often bot will send messages and the content of those messages.

Standard reply

The flow will launch in response to any user question that is outside your bot’s scenario, or by sending an image to a bot. Here you can add a message with information, that a manager will contact during them during business hours and reply to the user.

You can set up a cool down interval for launching a flow that is between 1 minute and 24 hours - so your bot won’t launch a second time within the specified interval.

Unsubscription from bot

This a flow with one message element that will launch after a user unsubscribes using the /stop or /unsubscribe command.

Trigger flow

You can add keywords - triggers, that your bot will react to and launch your flow.

Click Create a new triggerSelect a trigger type. For Keyword type write your command using one or several words. For example, you can use the words Order, Tickets, Price, or Delivery.

If the user enters part of a keyword linked to your command, your bot will suggest prompts such as a button with the name of your trigger. When the user clicks the button, the flow will launch.

To disable this feature, go to your chatbot settings and select the Disable bot suggestions when entered messages do not match a keyword option.

Building your flow

It’s important to think about the architecture and logic structure of your bot carefully. A well-designed bot will let users easily get a reply to their questions or place an order successfully by providing the necessary information.

Formulate the bot’s tasks, divide its functions into sections, think of how you will connect the elements, and start creating your bot’s flow using our drag-and-drop builder.

All the elements available in the builder are optional, you can even stop building after the first message element.

We recommend checking out the different varieties of chatbots and strategies for building your bot on our blog.

Start

You can choose the first element that launches your flow: Message, Filter, Randomizer, and API Request.

For example, using the Filter and API Request elements, you can check the subscriber's data and personalize your communication by starting your flow only for those users who have or do not have the requested data or branch your flow and send different messages. Using the Random choice element, you can diversify your chatbot's auto-replies or create an A/B test.

To make an element a start element, connect the desired element to the Start.

To see which trigger starts your flow, click on the Start.

A Message element

Using the Message element, you can create a message of any type and add various blocks to it: text, video, gallery, buttons, user data request, and so on.

You can add the Message element to any part of your flow. For example, in the last block of your flow, you can thank your users, confirm their order, and send information from your gathered variables, asking if the information is correct.

Text

Within the Message element select the text element type and add the text of your message. Also, you can add emoji and variables to personalize your messages.

To add a variable click {} in the right corner of the text block and choose the variable you want to add from the drop-down menu. If you have a value for this variable in the user’s contact information, they will receive a message with the value filled in.

You can add the following types of variables.

Custom variables for contacts You can transfer variables when a user subscribes to your chatbot. Set and update variables manually in the Audience section. Set and update variables automatically in a flow using the Action — set variable, User input, and API request elements.
System variables You can insert the text of the last message from your subscriber using the last_message variable. You can also add a subscriber ID using contact_id and a subscriber Telegram ID using telegram_id.
Global variables You can create your own variables in your bot settings and use messages with predefined values that will be shared with all of your subscribers. By default, $bot_name, $bot_id, and $current_date are available.

You can also format text to better visualize and highlight information.

Buttons

You need to add a button or user input element to the message element if you want to connect it with other elements in your flow. This is one of the most important elements for communicating with your users - buttons engage users and let them chose a direction for your bot to take them to the next part of your flow.

To add a button, click + Add Button. Select the type of button: Continue flow, URL or Payment

Name your button in the first field. You can add up to 20 characters and emoji to the button’s text.

The text on the button should be easily understandable - it’s important for users to understand what will happen when they click on the button and know what specifically they need to choose. Make sure that the next element in your flow corresponds to what the button says it will do to maintain the logic of your bot.

For a button with the URL type, you can also attach a link to a third-party resource. Your link can contain up to 512 characters.

To allow the user to continue the conversation by clicking on the link button, you need to activate the Link Tracking option in the chatbot settings under the General tab.

Also, for the URL button type, you can add a web application link, for example, a one-page online store.

Only the https:// protocol is supported. If you insert a link in the http:// format, your Telegram bot will not send your message.

Select the Open in web app pop-up checkbox to open a pop-up window with the specified link to the application.

You can create an online store with products, a shopping cart, and a data collection form and add links to Telegram buttons. Users can click them and complete their purchases in a separate window.

You can install Telegram JS code on your page — it works with data transferred from the messaging platform, including subscriber information.

You can add up to 13 buttons and for the Continue flow type and choose the layout that suits you best — from 1 to 4 in a row.

For the user, the buttons will look like this (below you will see "1 in a row" and "2 in a row"):

We recommend adding “Back” and “Back to main” buttons after all the information you add, so users can change their choice and choose another path through your flow. This prevents the logic of your bot from being trapped or broken with one message.

Quick Replies (Keyboard Reply)

You can also add another type of buttons — Quick Replies, (preset replies for chatbot users) which do not save user data (as it saves in User input function), but you can use it to expand the number of buttons and link each button to the next branch of your scenario.

If you turn on the “Wait for the subscriber’s response” toggle, the quick reply buttons not linked to user input will be disabled. You can use quick reply buttons only once — as quick replies for user input or as keyboard reply buttons.

Likewise, you can use buttons as an additional menu and improve navigation for your chatbot.

To add quick reply buttons, click Quick replies in the editing panel of the Message element and enter a name for the button: emoji or text up to 20 characters. To substitute dynamic values, insert the name of a variable stored in the audience as {{your_variable}}. Press Enter to save the button.

Quick reply buttons are displayed to the user immediately below the text input field. Users can hide the buttons and reveal them by clicking in the text input field on the corresponding icon located on the right.

For the user, the buttons will display like this:

You can combine Quick reply buttons and regular buttons, but users will receive an additional emoji message in this case.

After sending the next message, quick replies disappear. To quickly get a message with these buttons, we recommend creating a trigger and a flow on this trigger. Then, place the flow in the menu, which is always shown to the user and expands when the "/" icon is pressed

Images

Diversify your messages by using visual content that relates to your text.

Click the Select file button to upload an image from your computer or device, or drag and drop a file into the upload field.

There are no limitations to the size of the image, but note, that the image resolution for Telegram will be 500px in width and 200px in height.

To upload an image from a link, select Upload image by URL in the drop-down menu and specify the link to the image in the field.

You can also specify a dynamic path to the image. For example, using the "API request" element or from the a360 event, launching the flow via API, you can send a product picture and use this variable in the following message, displaying order data to the client.

To do this, select a variable or specify a JSON path in the field and pass the path to the image in the variable's value. Thus, each client will receive an image according to their order.

You can also add a caption and send the information to the user in one message-card. Your caption cannot be longer than 1024 characters. You can also break it into several lines and add emoji, links, and variables.

Available with the Pro plan and above, as well as during the 7-day free trial

The carousel format allows you to showcase up to 10 cards. In one card you can add an image, title – with up to 40 characters, description – with up to 80 characters and 3 buttons with link to an external source or with a phone number to call. 

You can add an image, up to 3 buttons, a card title (up to 32 characters), and a short description (up to 80 characters) to each card.

To add a new card to the carousel, click the + icon. You can add up to 10 cards to one message.

Telegram does not have the standard carousel functionality. Your carousel will be displayed as a single message with the right and left buttons that users need to click to see all your cards.

File

You can add files in any format except executable files of up to 20 MB. Attach tickets, maps, checklists, instructions, or other additional materials.

Click Choose File to upload a file from your computer or device, or drag and drop a file into the upload field.

To upload a file via a link, choose Upload file via URL from the drop-down menu and specify the file’s link in the field.

You can also specify a dynamic path to the file. For example, if you use the API Request element, or launch a flow from an A360 event or via the API request, you can send a file and use this variable in the next message when displaying order data to the customer.

To do this, select a variable or specify the JSON path in the field and pass the file path in the variable value. Thus, each customer will receive a file linked to their order.

Multimedia files

You can also add audio and video messages that will be played in messaging apps to your chatbot flow. For example, you can send video lectures and voice consultations directly in your chatbot without redirecting a subscriber to external sources.

Audio

Use this option to send audio recordings. You can add a file that’s up to 20 MB in size in the MP4 format.

You can also select the checkbox to display your audio file as a voice message.

Video

Use this option to send videos as attached files. You can add a file that’s up to 20 MB in size in the MP3, MP4, and OGG formats.

Video Note

Use this option to send short video messages. These videos are often recorded using the front camera to quickly address one’s audience. Your uploaded video will be cut down to 1 minute and displayed as a circle. You can add a file that’s up to 20 MB in size in the MP4 format.

Delay

Divide long texts into passages up to 4 lines with the Delay element. This element will imitate typing by showing the typing animation and gives your user a rest before the next message.

Click the Add button and choose the Delay element. Enter a value in seconds - from 1 to 5.

User Input

You can gather information from users and save it to a variable for future use. Users can enter any value, and you only need to set up the type of validation for this value, e.g., string (for text values), number, date, phone number, email address, URL, regular expression, geolocation, or image or document.

Activate Wait for the subscriber's response. Choose the validation type, add a warning message for users who enter the wrong value, and choose the variable where you want to store information.

Geolocation only works in Telegram’s mobile app.

The received email address, phone number, and other user data are saved in the automatically generated mailing list from our Email service.

You can also choose the period to wait for a response from the user. If the user does not respond within the selected time, the wait for a response from the user will expire and the chatbot will no longer check the entered data for validity to record user's response.

Also, under the message, you can add quick replies buttons - so users can choose from predefined responses instead of typing their own.

To do this click on the Quick replies button in the User input element window and enter values for the buttons. Quick replies disappear when a user or a bot sends the next message.

Note the difference between standard buttons and quick reply buttons: quick reply buttons are the bot’s element that saves information of the chosen button into a variable

And click on a standard button redirects the user to another element of your flow according to your scenario or to an external source.

Moving elements

By default, each element you add is placed at the end of the message element you are working on. Hover on the element that you want to move up or down and click on the corresponding button.

Continuing the flow

You can connect the next element after the Message element using the button or the Input option. You can also continue your flow without waiting for the user's response. We recommend using it with the "Pause" element to check if the subscriber interacted with the flow and send a message after a particular time.

When planning a flow scenario, keep in mind that you cannot both continue your flow using the Continue connector and use quick replies.

Connecting elements

Drag a line from the blue drop of one element to another element to connect them.

Click on the line twice and you will see a button to remove a connection.

The disconnected elements will be highlighted in yellow, remember that you need to link it to another element.

Elements with empty fields will be highlighted in red, reminding that you need to fill in fields. For example - if you added a button, but did not enter text for it or used a link element, but did not enter a URL. You cannot save your flow until you fill in these fields.

You can link an unlimited number of elements to elements that wait for user response and link up to 100 elements to the Continue button.

An Action element

The Action element is visible only to you. Select the element in the panel on the left and drag it after the block you're tracking.

Then select what action you want to create:

Open the chat Open a chat with a subscriber in the "Conversations" section
Unsubscribe from the bot Unsubscribe a user from bulk and automated messages
Add or Remove tags Assign a tag to a subscriber, remove a tag assigned to a user
Add variable Set the variable value to be assigned to the subscriber or updated. You can also create a new variable
Send webhook Send a POST request with user data to your URL
Create deal Create a deal in your CRM when a specific action is performed, for example, clicking the "Buy" button
Block or unblock in a group or channel Block or unblock a subscriber in a selected group or channel
Notify me Send a message on behalf of your chatbot to the system chatbot or Telegram group

A Flow element

You can simplify your bot’s structure and move your user to another flow.

To do this, add an element, then choose the Flow element and select the flow you want to link from the drop-down list.

The Flow element will be the last element in this branch of your existing flow. You cannot link it to another element to continue the original flow.

A Filter element

Segment customers based on their personal data and previous messages received. Select the element in the left sidebar, and drag it after the element that will start your script branching.

Then select the condition itself. Combine conditions by adding the operators any or all, or add independent additional conditions.

Read also: How to use the Filter element in the chatbot flow builder.

After adding conditions, add the additional flow elements to each of the Filter element options if the condition is met (green dot) or not met (red dot).

A Pause element

This is the period during which no automatic messages are sent to the subscriber. The pause can be set in minutes, hours, or days.

You can choose to pause in between using the Time period option or until a specific time using the Till date or Till Time option.

Select the Time period option and set a pause between sending flow elements from 1 minute to 24 hours. Use it in a flow, for example, to warm up a client. After the specified time, the next message will be sent.

If you select a pause of more than 1 day between elements, you can set the time at which the message will be sent. The system considers the next day any time after 00:00 according to the time zone set in the settings of your personal account.

Also, you can select Till date or Till time and set a delay until a particular time. For example, you can use this option to indicate business hours or promotion hours.

Also, using the Pause element, you can set the condition for executing the next element of the flow: always or when the subscriber is inactive.

An API Request element

Available with the Pro plan and above, as well as during the 7-day free trial

Send requests to a third party server to create objects or retrieve data. Get data and use it in your chatbot messages.

You can save the received data to a variable or add it to a message as JSONPath.

Drag the API Request element to the workspace, connect it to the element, after which you want to retrieve data. Select the type of request and enter the URL to send the request to.

Selecting a flow

After testing the request and receiving a successful response, configure the mapping settings. If you need to save the value from the response to a variable, select the key from the received request and the variable to save to. If you want to use the received value once without saving it to a variable, copy {{$ ['somekey'] ['nestedkey']}} and use it in the next message element.

Read more: How to send and receive data from external sources

Selecting a flow

A Random Choice element

Send elements from your chatbot script at random for A/B testing, creating quizzes, and more. You can customize the size of the recipient group for each option, send random information, and test different chatbot scenarios.

Drag the item Random choice element to the working area, connect it to the element you start branching the script from.

Learn more: How to use the Randomizer element.

Save and launch your flow

When you finished creating your flow and have looked over all of the elements, save your flow before exiting. Click Save and send it to yourself to test the flow and check if everything is working correctly.

You can also save an updated version of the flow while leaving the current version unchanged. To do this, click Save as a new flow. The new flow will be saved in the Flows section.

Note: your flow must have at least one Message or Action element.

After that, you can exit your flow by clicking Save and exit.

Managing your flows

You can enable and disable flows at any time by choosing a flow and switching it on or off from your chatbot dashboard.

Disabled flows will have a grey switch.

Analyzing your results

Sendpulse allows you to track general statistics on a chatbot in the Statistics tab.

You can see the number of messages sent and read, redirections from the flow, both in total and separately for each message in the Bot structure tab.

It’s also possible to track statistics on button clicks in flow messages and statistics for users for whom the Action and Pause elements were triggered. Click the number on a button to see who clicked the button.

    Rate this article about "How to create an automated flow for a Telegram chatbot"

    User Rating: 5 / 5

    Previous

    How to create a chatbot in Telegram

    Next

    How to set up a Telegram chatbot description

    Popular in Our Blog

    Try creating a chatbot for Facebook Messenger for free