Random gifts in your bot to engage users

Views:354

In this guide, Svetlana Gizatulina explains how to set up random gifts in a bot and limit the number of attempts, so you can get the most out of this mechanic for your business!

Step 1 — Connect your bot to puzzlebot

You can find out how in the Knowledge Base: https://help.puzzlebot.top/article?r=3&a=18

Step 2 — Set up sending a random gift from a list

Setup overview (part 1)

Create the commands for giving out a random gift:

1. In the Constructor section, create a regular command.
2. Choose the List block and add the gifts to it. Save the changes.
3. In the List block settings, check Send items in random order. This makes sure users get gifts at random.
4. Copy the variable that was created for the gift list.
5. Add a Text block and paste the message that will be sent to users along with the gift.
6. Save the changes to the command.

Set up how the gift command is called:

1. Open the /start command.
2. Add a message with a button that runs the random gift command.
3. Save the changes to the command.

Upload the changes to the bot and test how the gifts are sent. To keep the list from running out of gifts, check Loop sending rows from the list.

Step 3 — Set up attempt limits for getting a gift

Setup overview (part 2)

To keep gifts from being handed out endlessly, set a limit on the number of attempts. First, create a variable to track attempts:

1. Create a personal variable in the Variables section.
2. Set the variable format to Number.
3. Set Default value to 0.

Then create a command that sends a message when the attempts run out:

1. In the Constructor section, create a regular command with a Text block.
2. Paste a message saying there are no more attempts left to get a gift.

After that, create a command to check the number of attempts:

1. In the Constructor section, create a Condition command that decides which command to send when the Get a gift button is tapped.
2. To set up Rule #1, choose Variable value as the Check type, specify the variable you created and set the value to Equals 0.
3. For Action type, choose Send command or condition and select the gift command.
4. To set up the exclusion rule, choose Send command or condition as the Action type and select the command with the out-of-attempts message.

Finally, set up the order in which the commands are sent. In the /start command, make the Get a gift button send the condition command that checks the number of attempts.

Test the bot from any account. The setup is complete.

Want to ask an expert a question? Leave it in the comments under the latest post in our channel — the most interesting ones will get a detailed breakdown.

Was this page helpful?