Get text box data after pressing button in plugin

It sounds like what you’re looking for is to make an API in Ruby that the JS can call. An example is the Data Explorer plugin, which implements a user input API with admin permission scope on the ruby side.

The JS for the data explorer is on the beefier side of things, so I’ll just give a simplified example of what you’d probably need.

import { ajax } from "discourse/lib/ajax";

...
  @action
  sendTextboxData() {
    ajax("/endpoint", {
        type: "POST",
        data: {
          key: "value"
        },
    }).then((result) => {
        // do something with the result
    };
  }

You can do the same thing with a native JS fetch() but it seems that the ajax() function that discourse provides handles a few minor things under the hood.

If your ruby code is light enough, you can probably fit it entirely within a single file for the controller. Otherwise you can organize it however you need.