How to trigger a user intent from within a custom action?

I’m currently working on a bot that negotiates the price with the user. I’m using a form to get a price offer from the user and based on some logic I’m setting the slot at the end of the custom action and re-triggering the action, again and again, to present new offers to the user. Now I want the bot to break this loop when the user reaches a particular threshold and ask him to make a new offer. At this point, I want to trigger a user intent from within the custom action. I will be using this intent to trigger a rule that will ask the user to make a new offer.

I’m aware of the UserUttered function from rasa_sdk.events but for some reason, that’s not working for me. I wasn’t able to figure out where I was going wrong.

Here is the snippet where I’m using UserUttered:

else:
                    new_price = 'none'
                    bargain_cycle = bargain_cycle + 1
                    dispatcher.utter_message(text = "Make me a new offer!")
                    UserUttered('/another_offer')

                    return [SlotSet('current_bargain','none'),SlotSet('current_bargain_price',new_price),SlotSet('bargain_cycle',bargain_cycle)]

Please ignore the slots as they are derived from the logic in the action and are working as expected.

I have an intent named ‘another_offer’ in the nlu.yml and that is the intent that I want to trigger from the action above. Here is the intent:

- intent: another_offer
  examples: |
    - i will make a fresh offer
    - i wanna make a fresh offer
    - i will make a new offer

Finally, here is the rule that would be triggered upon the intent occurrence:

- rule: new offer from user
  steps:
    - intent: another_offer
    - action: user_offer_form
    - active_loop: user_offer_form

Can someone help me with this or at least point me to the right resources? Thanks in advance!

@PraneethVasarla please cross check the code, I hope this should work.



else:
                    new_price = 'none'
                    bargain_cycle = bargain_cycle + 1
                    dispatcher.utter_message(text = "Make me a new offer!")
                    UserUttered('/another_offer', intent={'name': 'another_offer', 'confidence': 1.0}))

                    return [SlotSet('current_bargain','none'),SlotSet('current_bargain_price',new_price),SlotSet('bargain_cycle',bargain_cycle)]

@PraneethVasarla could you explain why you’d like to “trigger” a user intent from within an action? What is the ultimate problem you’re solving? Intents are meant to only describe messages sent by the user, which make me believe that your problem should be possible to solve in a different way, without “mis-using” intents…