I want to do it automatically by writing an application plugin but still don't know how to do it.

There isn't really an API as such to do this kind of thing although one will be offered in the near future (the framework is already in place for it).

You can start the Channel Wizard by opening a special URL (e.g. http://127.0.0.1:2604/subscribe?...) although this is deprecated and has already been replaced by a more flexible mechanism in one of the recent betas.

What kind of things are you looking to do and we'll keep it in mind when we start implementing the API.