\documentclass{article}

\usepackage{fontspec}% provides font selecting commands

\newfontfamily\farsifont[Script=Arabic]{XB Niloofar}
\makeatletter
\TeXXeTstate=1
\def\farsitext#1{\begingroup\beginR\farsifont#1\endR\endgroup}
\makeatother

\begin{document}
Salam, This is a test.

\hfill \farsitext{سلام، حال شما؟}

Hello\dotfill\farsitext{سلام}

Hello\hfill\farsitext{سلام}
\end{document}