Home

Awesome

<p> <a href="https://twitter.com/AskDexa"><img alt="@AskDexa on Twitter" src="https://img.shields.io/badge/twitter-@AskDexa-blue" /></a> <a href="https://github.com/dexaai/xbot/actions/workflows/test.yml"><img alt="Build Status" src="https://github.com/dexaai/xbot/actions/workflows/main.yml/badge.svg" /></a> <a href="https://github.com/dexaai/xbot/blob/main/license"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-blue" /></a> <a href="https://prettier.io"><img alt="Prettier Code Formatting" src="https://img.shields.io/badge/code_style-prettier-brightgreen.svg" /></a> </p>

X Bot <!-- omit from toc -->

Twitter / X bot for responding to user mentions with AI-generated answers.

Features

Configuring the bot

You'll need a paid Twitter developer account and a Twitter v2 app with OAuth 2.0 enabled. You'll need to subscribe to at least the basic Twitter API plan in order to run this bot; the free tier is not supported since it doesn't support fetching tweets which is required for this bot to work.

Set up a .env file by copying .env.example and initializing all required environment variables.

Dependencies to call out:

Setting TWITTER_API_PLAN to the correct plan is important, because this is used to determine the bot's internal twitter API throttling in order to avoid rate limits and maximize quota usage.

Running the bot

tsx bin/xbot.ts
Usage:
  xbot [flags...]

Flags:
  -a, --answer-engine <string>                      Answer engine to use (openai, dexa, or perplexity) (default: "openai")
      --debug                                       Enables debug logging
  -t, --debug-tweet-ids <string>                    Specifies a tweet to process instead of responding to mentions with
                                                    the default behavior. Multiple tweets ids can be specified (-t id1
                                                    -t id2 -t id3). Exits after processing the specified tweets.
  -d, --dry-run                                     Enables dry run mode, which will not tweet or make any POST requests
                                                    to twitter
  -e, --early-exit                                  Exits the program after resolving the first batch of mentions, but
                                                    without actually processing them or tweeting anything
  -f, --force-reply                                 Forces twitter mention validation to succeed, even if the bot has
                                                    already responded to a mention; very useful in combination with
                                                    --debug-tweet-ids
  -h, --help                                        Show help
  -n, --max-num-mentions-to-process <number>        Number of mentions to process per batch (default: 10)
      --no-mentions-cache                           Disables loading twitter mentions from the cache (which will always
                                                    hit the twitter api)
  -R, --resolve-all-mentions                        Bypasses the tweet mention cache and since mention id state to fetch
                                                    all mentions from the twitter api
  -s, --since-mention-id <string>                   Overrides the default since mention id

TODO

License

MIT © Dexa