Cocoa is a tricky plant to grow. If you have a greenhouse which is a replicate the hot humid rainforest environment you have a higher chance of not only growing a plant but actually seeing some fruit.
The first task is to find good seeds. The seeds which are newly or recently picked from the fruit are suitable for growing, so it's better to obtain a fresh fruit. Old or dried seeds just won't do. A better option might be to purchase a seedling, which has already been adapted to local conditions and toughened for growing in a pot. Ask your local nursery if they could source one for you, or check online dealers.
The growing conditions are the temperature of 65 to 90 degrees F and humidity of at least 60 percent. If you don't have a greenhouse, you can use a humidifier and heater to get the desired conditions. You could also use an adjustable growing lamp with a filter to provide warmth, or put a plastic bag or tent over your seedling. Set a bowl of water next to it to release humidity. Cocoa likes rich, moist, but not overly wet soil, so spray sparingly but often. Mulching would help keep the earth moist longer, too.
Cocoa is an understory plant, and it is better to grow it under indirect, filtered sunlight. A spot under the canopy of tall, overhanging trees where it can receive about 25 percent shade.
The plant will flower within 4-5 years. Naturally, though, flowers are pollinated by midges — tiny flies that thrive in the thick, damp vegetation — so without these you'd have to pollinate the flowers yourself by hand. If fertilization is successful, you should be able to see fruit within 5-6 months.