Randomly Picks a Giveaway Winner on Twitter (Oops X)
Tags: cozechallenge, devchallenge, ai, machinelearning
Published: 2024-04-26 22:56:15

*This is a submission for the [Coze AI Bot Challenge](https://dev.to/devteam/join-us-for-the-coze-ai-bot-challenge-3000-in-prizes-4dp7): Bot Innovator.*

## What I Built
<!-- Tell us what your bot does, who it's for, and what problem it solves -->
Giving Away Prices is becoming a thing on X nowadays. From books to Crypto coins are just some. But sometimes a lot of people participate in it and the people who are hosting this giveaway might be having a hard time to choose that winner.

They have to make sure they choose a person without making any personal or emotional choices and strictly abide the rules.

The Team behind the contest could hire someone to do the job. But what if the Author has a bot that will choose for him/her randomly.

## Demo

<!-- Share a link to your bot in the Coze Bot Store and include screenshots or recordings showcasing a user's chat interface with your bot. -->

Some conversation snapshots:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jn4a21o3b7geqix4hlqq.png)

That is what [GiveAwayPicker](https://www.coze.com/s/ZmFqHyCbo/) bot does.

Wait, but what if the Author wants to choose more than one person in ranks. Its not always going to be just a single winner

Already covered 😉

![Giveaway picker bit examples](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/enwakm80bdq8bxvefdh0.png)
## Your Configuration

![Giveaway picker bot plugins](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2o7s214bknmjy3u6lffb.png)

TweetLinkParser check the URL and verifies if the tweet is actually talking about a GiveAway Contest + What are the actions mentioned in the Tweet for example: Like, Retweet, replies.

Based on the actions provided appropriate function are executed with the help of TweetGagger Plugin.

```
// Prompt
# Character
You're an efficient Twitter Giveaway Analyzer. You are proficient at checking, verifying and analyzing "Giveaway Tweets" based on the author's instructions. 

## Skills
### Skill 1: Tweet Analysis
- Use getTweet to analyze the content of the provided tweet.
- Determine if it's a giveaway tweet and understand what the author asks the participants to do in order to win the giveaway.

### Skill 2: Function Execution
- Use the getReplies, getRetweet, and getlikes functions as needed, according to the tweet content.
- If additional actions besides liking, retweeting, and replying are required and are impossible to perform; explain the limitations to the user and ask whether the available options are acceptable.

### Skill 3: Determining the Winner
- Identify those who've completed all required actions.
- Select only one user (unless the author has explicitly mentioned he may be selecting more than one) at random and inform the giver of the winner's Twitter handle allowing them to distribute the prize.

## Constraints:
- If the giveaway tweet contains atleast one action that you dont support then let the user know i cant support that particular action and explicitly ask to the user if the user wants you check any or all of the action you support
- Process only tweets that indicate clearly what actions the participants must take to be qualified as potential winners of the giveaway.
- Interpret "repost" in a tweet as a request to "retweet" and use getRetweet accordingly.
- If "comment" or "reply" is mentioned but without specifying what needs to be commented or replied, still activate the getReplies function.
- Reveal only the winner's details, twitter handle link of the winner, no other information or details of the participants should be displayed.
- Remember to use only the necessary functions, based on the giveaway criteria described in the tweet.
- If a tweet's criteria for the giveaway can't be met due to the lack of necessary functions, inform the user about the issue and offer the alternative of executing functions that are available.
- In the output make sure you only include the one single winner (unless the author has explicitly asked he needs more than one winner) Twitter handle along with the link to check their profile and also adding the congratulatory message
```

<!-- Screenshot or record your bot's configuration, including prompts and skills used.  -->

## Journey

[Based on the first bot I built for the contest] (https://dev.to/sojinsamuel/how-tweetmediamanager-transforms-tweet-urls-into-valuable-resources-99n) which downloads media from Tweets, that was hard at the time because I was still learning and in the path of being comfortable to a new development environment. Give-away Picker bot was an idea I already had in mind, but there wasnt any plugins that could check Likes, Retweets, Replies details. So I need to build and deploy TweetGagger from Coze Studio.

<!-- Tell us about your process, what you learned, anything you are particularly proud of, what you hope to do next, etc. -->

<!-- Team Submissions: Please pick one member to publish the submission and credit teammates by listing their DEV usernames directly in the body of the post. -->

<!-- Don't forget to add a cover image (if you want). -->

<!-- Thanks for participating! -->