How create drop down list from dynamic values

I want create drop down list of dynamic values,so how can I achieve that ?or any alternative way for this ?

Hello @Shweta_Mohite, drop down list for what? Please give an example with specific explanation.

Hey @Shweta_Mohite, it depends on the Chatbot UI you are using. Which UI are you using?

GitHub - JiteshGaikwad/Chatbot-Widget: ChatBot widget easy to connect to RASA bot through REST channel(HR bot) I have used and using REST api I have integrated with website.I am not understanding how I can use drop down menu inside chatbot and how to call it after specific intent as a response ? can you share any example or please explain.

@Ayad0net and @JiteshGaikwad I am fetching some values from database and wants to give user for selection using drop down list

hey @Shweta_Mohite, I haven’t added support for dropdown box in that UI but you can give it it a try, you can send the data using custom message from custom actions of Rasa and show it in the frontend.

1 Like

You can, by using custom action and send custom data to the frontend.

:one: [Frontend] -----> [Rasa]

:two: [Rasa] —> [Custom action] ----> [Prepare data] ----> [Frontend]

:three: [Frontend] ----> [Handle data and render it to dropdown list]

@Ayad0net Please can you share one example or explain more I didn’t get what exactly I can do with custom actions ?will I need to use jquery or angular js for this ?

hi @JiteshGaikwad can you please tell me if I’ll send data using dispatcher.utter_message(“json_message=”) then how I can fetch that data at front end.

Hey @Shweta_Mohite, just give me sometime I will create an example and show it to you, does that helps?

ok @JiteshGaikwad thanks alot

hey @Shweta_Mohite, I have added the support for dropdown message in the UI, you can test it out: file contents:

# This files contains your custom actions which can be used to run
# custom Python code.
# See this guide on how to implement these action:

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

from typing import Any, Text, Dict, List

from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher

class ActionHelloWorld(Action):

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

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
        dispatcher.utter_message(text="Hello World!",json_message=message)

        return []

Code for rendering the dropdown in the chat widget:



Let me know if this helps you :slight_smile:


Done !!! hey @JiteshGaikwad thank you very much ! really means alot !!

@Shweta_Mohite, Glad that it helped you :slight_smile:

1 Like

Hi @JiteshGaikwad I am able to get button value using this : if tracker.latest_message[‘intent’][‘name’] == ‘inform’: da =tracker.latest_message[‘text’] but I want to get this condition inside so I am not able to get slot name as a inform so is there any alternative way to take button value ?or how I can get slot name ‘infrom’ value?

@JiteshGaikwad do I have to mention ‘inform’ as intent in nlu file ? if yes can you tell how ?

Hey @Shweta_Mohite, sorry for the late response. You need to check whether that slot_name key exists

Hi @JiteshGaikwad I’m getting this warning

UserWarning: Failed to parse arguments in line ‘/inform{‘slot_name’:fcec1244-565d-5568-99d1-cbd127112e20}’. Failed to decode parameters as a json object. Make sure the intent is followed by a proper json object. Error: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

I have used this:

    if intent_name == 'check_balance':
        data = []
        for (id, acc_no) in zip(ac_ids, accounts):
            data.append({"label": acc_no, "value": "/inform{'slot_name':" + id+"}"})

can you tell where I am doinng wrong ?do I need to write ‘infrom’ as in intent in domain file or nlu ?

Hey @Shweta_Mohite, can you share the above error’s screenshot?