I am trying to create a bot, that lists the last 10 messages from Telegram group (Successful), and then select a random message among them. I thought maybe I could do it using random function. The random function gives me a random number between 1 to 10 that will help me in randomly selecting a message. But I am not able to understand how do I pull the message based on that number? I understand I need to somehow create an array containing all the bundle numbers and messages, then use this random function to return a bundle number, message corresponding to that bundle number will be returned. But I am not able to create such array. Please help me on how to pull the chat from the randomly selected bundle number.
Welcome to the Make community!
When you have multiple bundles and want just one item, you can use an Array Aggregator first to combine them into an array, then use the shuffle-first functions.
If you already have an array, then just use the shuffle-first functions directly. You can put this in a Set Variable module if you need a module to put these functions in.
{{ first(shuffle(array)) }}
Hope this helps! Let me know if there are any further questions or issues.
β @samliew
Thank you for your support. It works now
Couple of points if you can help please:
- Is it possible to reply to a certain text on Telegram? I mean tagging the user and then sending the text? Currently, I am able to send the random text in the grp, but it sends it as standalone, not tagging the user/replying to the text. I tried using update id as input to the original message id, but it gave error saying message not found.
- I am using ChatGPT to send responses in a grp. Is it possible to get ChatGPT to somehow not repeat the the same output it gave earlier?
- Is it possible to somehow feed array into chatgpt? I want to send it recent 10 messages that I am fetching through Tg bot, and then generate a reply to one of them using all 10 as reference. I tried to give array as input to it but the input to chatgpt only picks up the first element of the array.
No problem, glad I could help!
Iβd appreciate it if you can create a separate thread per question. This is because I may not be able to answer all the questions, and I also may not be available to answer follow-up questions quickly. It also helps keep this forum organised and easy to search for answers to individual questions.
1. If anyone has a new question in the future, please start a new thread. This makes it easier for others with the same problem to search for the answers to specific questions, and you are more likely to receive help since newer questions are monitored closely.
2. The Make Community guidelines encourages users to try to mark helpful replies as solutions to help keep the Community organized.
This marks the topic as solved, so that:
- others can save time when catching up with the latest activity here, and
- allows others to quickly jump to the solution if they come across the same problem
To do this, simply click the checkbox at the bottom of the post that answers your question:
3. Donβt forget to like and bookmark this topic so you can get back to it easily in future!
Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too β
Getting Started
- Help Centre | Tutorials β Make βManualβ
- Make Academy β Basics 101: Learn Make and get certified
Help Centre Basics
- Mapping β What is mapping? What can I map?
- Mapping with arrays β How to map items in an array
- Aggregate an array for mapping complex fields
- Tokens for
parseDate
| Tokens forformatDate
- HTTP modules β Make a request, Get (download) a file
- Webhooks β Error Handling, Responding to webhooks
Articles & Videos
- Router Magic Formula - YouTube
- Error Handlers in Make - YouTube playlist
- Getting started with OpenAI - How to setup and use OpenAI (ChatGPT) in Make
- How to use Regex in Make - How to use pattern matching to extract the text you want
Partner & Custom Apps
Hope this helps! Let me know if there are any further questions or issues.
β @samliew
Thank you. I have created separate threads for all the questions.