Using questionary in action server

I am using the questionary module from Tom Bocklisch as part of an action in my action server. My environment is dockerized, i.e. I am using separate containers for NLU, Core and core_sdk.

The following code works perfectly when I run the basic code as a standalone script from rasa_core. However when I put it as an action in the action server running core_sdk, it fails.

def run(self, dispatcher, tracker, domain):
    acc = tracker.get_slot('account')
    dev_key = requests.get('https://xxxx', timeout=5.0) 
    questions = []

    api_url = 'https://xxxx/token/' + dev_key 
    api_key = requests.get(api_url, timeout=5.0)
    field_data_url = 'https://xxxx/fields/' + api_key + '/' + 'Account'
    fields = requests.get(field_data_url).json()
    field_list = fields['Object']

    for flds in field_list:
        if flds['IsRequired']:
            q_item = {'type': 'text', 'name': flds['FieldName'], 'message': flds['LabelText']}
    answers = qs.prompt(questions)
    #SlotSet('account_fields', answers)
    return answers

I guess it has something to do with interacting with CLI app over http but I am not sure how to deal with it. Any help would be highly appreciated.


The action server is run independently of rasa core. questionary is used to request input from the user: this means your action server is waiting for user input: if you are not providing any input there, your action will never complete. You can not use the library this way to prompt the chatbot user for input.