First you need to determine what GW type you need, which is driven by what is the PSTN connection, i.e. SIP trunk, PRI, T1/E1-CAS, FXO, etc. and how many concurrent connections is required. Once you know that you can scope your router model and modules and licensing for CUBE sessions for example (if it's SIP trunk). Then you determine what protocol will be used between the GW/CUBE and CUCM, ideally SIP (but you could potentially do H323 or MGCP as well). Then in CUCM you add the GW as either SIP trunk if using SIP or GW (i.e. H323 or MGC). For inbound routing you configure the trunk/GW with inbound calling searching space which will determine which extensions the GW has permissions to route based on the CSS/PT configuration. For outbound you define Route patterns that point to Route List which points to Route Group(s) which point to the SIP trunk/GW(s) to establish your routing. There is many little things in between, most importantly the configuration of the actual router as GW, so nothing will shine the light better for you than actually getting your hands on it.