Imposing local boundary conditions in nonlocal/peridynamic models is often desired/needed. Fictitious nodes methods (FNMs) are commonly used techniques for this purpose but they are limited, in general, to domains with simple geometry. FNMs also mitigate the well-known peridynamic surface/skin effect at boundaries/surfaces. Here, we introduce a general algorithm that automatically locates mirror nodes for fictitious nodes in the mirror-based FNM, without requiring an explicit mathematical description of the boundary. The algorithm is based on computing a nonlocal gradient, at fictitious nodes, to determine the “generalized” normal direction to the boundary of a domain with arbitrary geometry. We test several FNMs on peridynamic diffusion problems with or without singularities, that exist in the corresponding local models, along the boundaries. We find that the mirror-based FNM works best in agreeing with the classical solutions. We then test the new algorithm with this FNM for diffusion problems in domains with complex geometries, including one with intersecting cracks. The algorithm is general and should work for any type of peridynamic model, including those for problems with moving boundaries and growing cracks, for which enforcement of local-type boundary conditions is desired. Since high accuracy is critical near boundaries of arbitrary shape (including corners, notches, crack tips) in a variety of problems, the new algorithm has potential for high impact.