# How to use dynamic buttons to set multiple slots in a form

**URL:** <https://forum.rasa.com/t/how-to-use-dynamic-buttons-to-set-multiple-slots-in-a-form/54214>\
**Category:** Rasa Open Source\
**Created:** [July 8, 2022, 7:29pm UTC](https://forum.rasa.com/t/how-to-use-dynamic-buttons-to-set-multiple-slots-in-a-form/54214 "2022-07-08T19:29:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![steve1](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@steve1](https://forum.rasa.com/u/steve1)\
**Post date:** [July 8, 2022, 7:29pm UTC](https://forum.rasa.com/t/how-to-use-dynamic-buttons-to-set-multiple-slots-in-a-form/54214/1 "2022-07-08T19:29:12Z")

</div>

In a Rasa 2.8.0 bot, I have a form that takes two entities, job\_type and job\_name. Using some of what I’ve seen on this site, I’ve setting up a piece of code that reads from a csv file and presents a list of buttons for the user to click in order to set the slot value:

```auto
#button_form.py
from typing import Text, List, Any, Dict
from rasa_sdk import Tracker, FormValidationAction
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.events import EventType
import csv

class ActionButton(Action):

    def name(self) -> Text:
        return "action_button"

    def run(
            self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
    ) -> List[EventType]:

        csv_file = 'button_list.csv'
        form_button_list = []
        
        #read csv for button
        with open(str(csv_file), 'rt') as f:
            reader = csv.reader(f)
            next(reader, None) # skip the headers
            csv_output = {rows[0]:rows[1] for rows in reader}

        
        logger.info(csv_output)
        
        #generate button for raasa
        for test_name in csv_output:
            form_button_list.append({"title": test_name, "payload": test_name})

        logger.info("form_button_list: "+str(form_button_list))
        dispatcher.utter_message(text="Which value stream do you want to execute:", buttons=form_button_list)
        return []

```

However, I not sure how to properly implement this in my rules file. Right now, it sits before the call to the active loop:

```auto
  - rule: Activate conv_job_check
    steps:
      - intent: intent_job_check
      - action: action_button
      - action: form_job_check
      - active_loop: form_job_check
  - rule: Submit conv_job_check
    condition:
      - active_loop: form_job_check
    steps:
      - action: form_job_check
      - active_loop: null
      - slot_was_set:
          - requested_slot: null
      - action: utter_job_check
      - action: action_job_check

```

This ends up calling the button list for the first slot, job\_type, but I end up needing to type in the value for the second slot, job\_name. What it should do is present the buttons for each slot. I thought that I could put it into the loop itself, but that resulted in a training error.

Here is my domain file for reference. I understand I could set up the buttons in this, but I do not want to hard code them:

```auto
version: '2.0'
entities:
  - job_name
  - job_type
intents:
  - intent_job_check
  - intent_job_status
actions:
  - utter_ask_job_name
  - action_job_check
  - utter_job_check
  - utter_ask_test_type
  - utter_ask_job_type
  - action_button
responses:
  utter_job_check:
    - text: Checking jobs...
  utter_ask_job_type:
    - text: 'Please select a job type:'
  utter_ask_job_name:
    - text: 'Please select a job name:'
slots:
  execute_action:
    type: text
  job_type:
    type: text
  job_name:
    type: text
forms:
  form_job_check:
    job_type:
      - type: from_text
        intent_name: None
    job_name:
      - type: from_text
        intent_name: None

```

What is the proper method for implementing these buttons for each slot?
