How to get user name and password through custom action

Hi

I am doing a project in which i have to login through chat bot using username and password(it should not visible) so here i cannot defined username and password in nlu data as we have different formats of user name and password.so i decided to take username and password through custom action but through custom action i am not able to set these slots and it directly goes to next action with out setting username and password slots

i even try form action but here also the slots are getting set only if we mention username and password examples in nlu data

My purpose is to get username and password(while typing it should not visible) with out nlu data and store it in slots and use these values for calling api

can any one please help me with this it is urgent

Thanks in advance

can any one please help me with this

Hi @surya1994,

I think that we will need to give some nlu data for the username and password data pattern. I have also came across same situation I also tried, but it’s same at my side. I am also trying to achieve this but for the time being I havn’t got anything.

Unless you will need to provide some data to work it out. Even I also tryied to achieve this using regular expressions but even it’s not working.

At the end it requires data of that particular type. Let’s see reply from other memebers.

1 Like

Hi prashant_kamble

But even if we provide training data also there might be some cases in which both user name and password follows similar pattern and same length (because we cannot predict user he may give any pattern) if this is the case nlu might predict username as password and password as username which is wrong how can we over come this case if you know anything please let me know

@surya1994 How are you trying to set the slots in your custom action? If you’re trying to set the slot value to equal the whole text of the user input inside a custom action, it should work fine.

Also, just to confirm, you’re asking something like “Enter your username” and the user enters just the username (with no extra frills like “My username is …”), right?

I did not get your first point can you explain in detail

Yes for 2 nd case user will enter only username with no extra frills like My username is

Are you using setting your slot value to tracker.latest_message.text inside the run method of your custom action or something else?

Yes i am using tracker.latest_message.text in my custom action but some times i am facing with following error :

Traceback (most recent call last): File “/u01/app/anaconda3/envs/rasa/lib/python3.6/site-packages/rasa/core/actions/action.py”, line 397, in run json=json_body, method=“post”, timeout=DEFAULT_REQUEST_TIMEOUT File “/u01/app/anaconda3/envs/rasa/lib/python3.6/asyncio/coroutines.py”, line 110, in next return self.gen.send(None) File “/u01/app/anaconda3/envs/rasa/lib/python3.6/site-packages/rasa/utils/endpoints.py”, line 142, in request resp.status, resp.reason, await resp.content.read() rasa.utils.endpoints.ClientResponseError: 500, INTERNAL SERVER ERROR, body=‘b’\n500 Internal Server Error\n

Internal Server Error

\n

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

\n’’

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File “/u01/app/anaconda3/envs/rasa/lib/python3.6/site-packages/rasa/core/processor.py”, line 439, in _run_action events = await action.run(output_channel, nlg, tracker, self.domain) File “/u01/app/anaconda3/envs/rasa/lib/python3.6/asyncio/coroutines.py”, line 110, in next return self.gen.send(None) File “/u01/app/anaconda3/envs/rasa/lib/python3.6/site-packages/rasa/core/actions/action.py”, line 419, in run

core: File “/u01/app/anaconda3/envs/rasa/lib/python3.6/site-packages/flask/app.py”, line 2292, in wsgi_app response = self.full_dispatch_request() File “/u01/app/anaconda3/envs/rasa/lib/python3.6/site-packages/flask/app.py”, line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File “/u01/app/anaconda3/envs/rasa/lib/python3.6/site-packages/flask_cors/extension.py”, line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File “/u01/app/anaconda3/envs/rasa/lib/python3.6/site-packages/flask/app.py”, line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File “/u01/app/anaconda3/envs/rasa/lib/python3.6/site-packages/flask/_compat.py”, line 35, in reraise raise value File “/u01/app/anaconda3/envs/rasa/lib/python3.6/site-packages/flask/app.py”, line 1813, in full_dispatch_request rv = self.dispatch_request() File “/u01/app/anaconda3/envs/rasa/lib/python3.6/site-packages/flask/app.py”, line 1799, in dispatch_request return self.view_functionsrule.endpoint File “/u01/app/anaconda3/envs/rasa/lib/python3.6/site-packages/flask_cors/decorator.py”, line 128, in wrapped_function resp = make_response(f(*args, **kwargs)) File “/u01/app/anaconda3/envs/rasa/lib/python3.6/site-packages/rasa_sdk/endpoint.py”, line 59, in webhook response = executor.run(action_call) File “/u01/app/anaconda3/envs/rasa/lib/python3.6/site-packages/rasa_sdk/executor.py”, line 237, in run “No registered Action found for name ‘{}’.”.format(action_name) Exception: No registered Action found for name ‘action_custom_fallback’.

I am of opinion that i am getting this error because some times response time is more than 100000 ms if that is the case can you please let me know how to fix it(can i increase waiting time)

The above story is without forms but when i use forms i am not even able to set form action slots also(username and password) below is a story and actions.py

story:

Make_Payment_with_Login

  • user_payment_message
  • utter_message_login_credentials
  • utter_yes_no_buttons
  • affirm
  • user_login_form
  • form{“name”: “user_login_form”}
  • form{“name”:“null”}
  • action_outstanding_amount_preprocess
  • action_outstanding_amount
  • utter_payment_message
  • utter_yes_no_buttons
  • affirm

program: import logging import requests import json from rasa_sdk import Action from rasa_sdk.events import SlotSet from rasa_sdk.events import Restarted from rasa_sdk.events import UserUtteranceReverted from rasa_sdk.events import UserUttered from rasa_sdk.forms import FormAction from rasa_sdk import Tracker from rasa_sdk.executor import CollectingDispatcher from typing import Dict, Text, Any, List, Union, Optional

logger = logging.getLogger(name)

#Form action logic class UserLoginForm(FormAction): “”“Example of a custom form action”""

def name(self):
    """Unique identifier of the form"""

    return "user_login_form"

@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
    """A list of required slots that the form has to fill"""
    print("required slots")
    return ["user_id","password"]

def slot_mappings(self):
    # type: () -> Dict[Text: Union[Dict, List[Dict]]]
    """A dictionary to map required slots to
        - an extracted entity
        - intent: value pairs
        - a whole message
        or a list of them, where a first match will be picked"""
    print("user_id",user_id)
    print("password",password)
    return {"user_id": [self.from_text()],"password": [self.from_text()]}

def submit(self):
    """Define what the form has to do
        	after all required slots are filled"""
    dispatcher.utter_template("utter_submit", tracker)
    return []

can you please let me know what is the reason and solution for this mentioned error

Hi @surya1994,

Maybe this will help: How to extract username & password entities from text? - #2 by jabberlope

Hope that helps. :smile:

Thanks @lahsuk can you please let me know why i am getting above mentioned error

@surya1994,

I think you’re getting this error because it is not finding action_custom_fallback. Either you have forgotten to add this to domain.yml file or you don’t have an action that matches with this name.

Edit: Oh, and it’d be better if you formatted the error; it’s really hard to read it as it is. (You can format it with ``` three ticks).

Hi all,

I want get the username from the chat conversations

example:- bot:- Hi user:- Hi Bot: May i know your name? User: I am Karthik Bot : Thanks for providing details Karthik

Like the above example i have call the user with there name can anybody please help