The place to start would be identifying how you are going to trigger the CCX script. If you have a premium license, you can use an HTTP trigger which probably makes the most sense. An external application server would perform an HTTP GET or POST to a URL on the CCX server which would trigger a script.
After that it's all in the CCX script. I'm not quite clear what specific item you're asking for help on beyond that.