You should first create an animation Blueprint Class.
Right click in your content browser -> Animation -> Animation Blueprint.
Then compile and save. Modify and code it however you like. Then, in the character BP, click on the mesh component in the top-left. Then, on the right,in the Animation section, change the Anim class (From the top-down menu) to the one you have created.