*Edit: The suggested answer does not work as the robots are not just randomly crawling from my index, they are visiting a specific link when it is entered in a FB message.*

I've created a basic chat application in Flask on App Engine. It allows the user to invite others by adding their ID or by giving them a private sharelink that auto-adds who ever goes to it (similar to youtube or google drive).

A serious flaw I have found is that if a user posts the link into a facebook message, Facebook will crawl/visit the link and by design of my system add them as a user to the conversation. All of a sudden you'll see 3 random users join the conversation.

My chat system is completely anonymous and designed to be temporary so theres no login or authentication other than a unique key for each user saved in their session.

So Facebook bots visit the link, get assigned an ID and get authenticated into the conversation because they used the users share-link, is there a way I can stop this via either Flask/Python or App Engine? Could I IP ban facebook?

Some code for the sake of code, does this for every new visitor:

```
def requires_session(f):
  @wraps(f)
  def decorated(*args, **kwargs):
    if 'profile' not in session:
        user_ref = fs_database.collection('users').document()

        data = {
            'id': user_ref.id,
            'date': datetime.now(timezone.utc)
        }
        # add the user to the database
        user_ref.set(data)

        # save their id to their session
        session['profile'] = data.get('id')

        # create a hash for later on to create a sharelink
        session['share'] = hashlib.sha256(data.get('id').encode('utf-8')).hexdigest()
    return f(*args, **kwargs)
  return decorated

```

I could maybe add a check first `if Facebook-bot: return False`