Measurements of the cross sections for top quark pairs produced in association with a W or Z boson are presented, using 8 TeV pp collision data corresponding to an integrated luminosity of 19.5 fb-1, collected by the CMS experiment at the LHC. Final states are selected in which the associated W boson decays to a charged lepton and a neutrino or the Z boson decays to two charged leptons. Signal events are identified by matching reconstructed objects in the detector to specific final state particles from tt̄W or tt̄Z decays. The tt̄W cross section is measured to be (Formula Presented) fb with a significance of 4.8 standard deviations from the background-only hypothesis. The tt̄Z cross section is measured to be (Formula Presented) fb with a significance of 6.4 standard deviations from the background-only hypothesis. These measurements are used to set bounds on five anomalous dimension-six operators that would affect the tt̄W and tt̄Z cross sections.