The present invention provides a heterocyclic compound having an orexintype 2 receptor agonist activity. A compound represented by the formula (I) :whereineach symbol is as described in the specification, or a salt thereof, is usefulas an agentfor the prophylaxis treatment of narcolepsy.