It's not cut and paste - but not terribly difficult either. Some JavaScipt skills are required. There is a great doc on creating your own custom widget that starts here: Naming conventions—Web AppBuilder for ArcGIS (Developer Edition) | ArcGIS for Developers
With the Widget framework it should be straight forward to plug it in.
To add to Jordan's advice here is a thread where I took a JS sample and migrated that to a widget (full code). That example may help you on your way to doing the same for the API sample you want to convert.