How to fix my action

this is my dictionary :
rules = {‘I want (.*)’:

                    ['What would it mean if you got {0}',
                    'Why do you want {0}',
                     "What's stopping you from getting {0}"],
             'do you remember (.*)': ['Did you think I would forget {0}',
              "Why haven't you been able to forget {0}",
                'What about {0}',
                                    'Yes .. and?'],
               'do you think (.*)': ['if {0}? Absolutely.', 'No chance'],
                 'if (.*)': ["Do you really think it's likely that {0}",
                    'Do you wish that {0}',
                    'What do you think about {0}',

    'Really--if {0}']
    }

my action is :

lass ActionMatchWord(Action): def name(self) -> Text: return “action_match_word”

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

    message = ((tracker.latest_message)['text'])
    response, phrase = "default", None
    for pattern, responses in rules.items():
        match = re.search(pattern,message)
        if match is not None:
           response = random.choice(responses)
           if '{0}' in response:
               phrase = match.group(1)
                

    #final_mesg = " {0}  {1} ".format(response,phrase)
    dispatcher.utter_message(str(response)+ '' + str(phrase))
    
    return []

when I use rasa shell I receive that msg.

those are the answers why the 0 stay there :

if {0}? Absolutely. you are cute Your input -> do you think you are smart enough

if {0}? Absolutely.you are smart enough

Your input -> if you want
Do you wish that {0}you want

Your input -> if you want to be here

Do you wish that {0}you want to be here Your input -> if you bealive that
Really–if {0}you bealive that

Hi @hajoura! It is tough for me to figure out what you are referring to by "when I use rasa shell I receive that msg". Can you please try to state what the problem with your action is in one simple sentence? It would also be helpful if you clarified your example and provided some context (e.g. bot says: X, user says: Y, the action is intended to do Z, the user is trying to do W, your reasoning for why you think you need to use a dictionary of responses in a custom action, etc). As someone who knows nothing about your bot, it is challenging for me to understand what is going on in this conversation and what you are trying to do

ok

user : if you want

bot : Do you wish that {0}you want

user : if you want to be here

bot : Do you wish that {0}you want to be here

why he answer me with 0 in my code I said if 0 return to respones

@hajoura Have you tried stepping through your code with a debugger? I would recommend checking out pdb —The Python Debugger. You’ll want to make sure that rules.items() contains what you expect, match is what you expect (and not None), response is what you expect, {0} is in response, phrase is what you expect, and your final message is what you expect. dispatcher.utter_message() only responds with the string you give it, so somewhere your code seems to not reflect the logic you have in mind.

user : do you think …

bot : …do you th you nk

my code convert pronoun but why he went to verb and

convert the I on it to you

this my code

if ‘I’ in message: message = re.sub(‘I’,’ YOU ',message)

    if 'ARE' in message:
        message = re.sub('ARE',' AM ',message)

    if 'I WAS' in message:
        message = re.sub('I WAS','YOU WERE ',message)

    if 'WERE' in message:
        message = re.sub('WERE',' WAS ',message)

@hajoura I would make sure that you understand and are using re.sub() correctly