# This files contains your custom actions which can be used to run
# custom Python code.
#
# See this guide on how to implement these action:
# https://rasa.com/docs/rasa/core/actions/#custom-actions/


# This is a simple example for a custom action which utters "Hello World!"

from typing import Any, Text, Dict, List
#
from rasa_sdk import  Tracker
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.forms import FormAction
#
class PendaftaranForm(FormAction):

    def name(self):
        """Unique identifier of the form"""
        return "pendaftaran_form"
    @staticmethod
    def required_slots(tracker: Tracker) -> List[Text]:
        """A list of required slots that the form has to fill"""

        return ["jalur"]

    def submit(
        self,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
      ) -> List[Dict]:
      if tracker.get_slot('jalur') == 'karyawan':
         dispatcher.utter_message(template="utter_tanya_syarat_pendaftaran_karyawan")
      elif tracker.get_slot('jalur') == 'pindahan':
         dispatcher.utter_message(template="utter_tanya_jalur_pindahan")
      else:
         dispatcher.utter_message(template="tanya_syarat_pendaftaran")
      return []
