How to create a flexible table schema for storing messages from different chats?

All modern chatting interfaces, without exception, implement a hierarchical and a not-chronological schema for chat. That means you have to use (the soon to be released) MySQL 8, as prior versions do not support recursive CTEs which are required to do this. Any workaround can't permit infinite depth, which is usually required or at the very least nice to have.

Rather than drawing up a schema here, you can see what one looks like in PostgreSQL here, where I answered a similar question. Essentially, each message has id|parent_id the parent_id points to the id on the same table. This creates a hierarchy. We call this implementation of hierarchy "self-referential", or "single-table hierarchy."

Moreover, you may wish to implement an array of tagged users or the like for better indexing.

Ultimately, if you're going to go down this route and you have no prior work, you should be using PostgreSQL -- which supports Recursive CTE's now, and sql-array's for easy tagging.

I'm not saying your schema has to look like those. You may have additional demands, but I wouldn't want to start off with an inferior feature set and the wrong tool.

For clarity this critique is specific to your chat_messages table. The chat sessioning would be done by just creating a seperate table for it, and linking all messages to an entry in that table. For instance,

CREATE TABLE chat_session (
  chat_session_id  int  PRIMARY KEY
  ....
);

Other tables..

CREATE TABLE chat_message (
  ts                             timestamp with time zone,
  chat_message_id                int PRIMARY KEY,
  chat_message_parent_id         int REFERENCES chat_message,
  chat_message_author_user_id    int REFERENCES user,
  chat_message_author_client_id  int REFERENCES client
);

Or the like.