# For example I want to pay a bill how this we can be done in a single function and we get input in same function

**URL:** <https://forum.rasa.com/t/for-example-i-want-to-pay-a-bill-how-this-we-can-be-done-in-a-single-function-and-we-get-input-in-same-function/60914>\
**Category:** Rasa Open Source\
**Created:** [January 31, 2024, 10:16am UTC](https://forum.rasa.com/t/for-example-i-want-to-pay-a-bill-how-this-we-can-be-done-in-a-single-function-and-we-get-input-in-same-function/60914 "2024-01-31T10:16:53Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![aliasghar5124](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/aliasghar5124/32/23854_2.png) [@aliasghar5124](https://forum.rasa.com/u/aliasghar5124)\
**Post date:** [January 31, 2024, 10:16am UTC](https://forum.rasa.com/t/for-example-i-want-to-pay-a-bill-how-this-we-can-be-done-in-a-single-function-and-we-get-input-in-same-function/60914/1 "2024-01-31T10:16:53Z")

</div>

class ActionChooseBill(Action): def name(self) → Text: return “action\_choose\_bill”

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

    # Display options for bill payment
    dispatcher.utter_message("Choose which bill you want to pay:")
    dispatcher.utter_message("1. Press 1 For Electricity Bill\n2. Press 2 For Gas Bill\n3. Press 3 For Telephone Bill")

    selected_bill_number = input("Bill Type: ")
    # selected_bill_number = tracker.latest_message.get('text')
    if selected_bill_number.isdigit():
        selected_bill_number = int(selected_bill_number)

        bill_type = ["Electricity", "Gas", "Telephone"]
        if 1 <= selected_bill_number <= len(bill_type):
            selected_bill_type = bill_type[selected_bill_number - 1]

            dispatcher.utter_message(f"You have selected {selected_bill_type} bill.")
        else:
            dispatcher.utter_message("Invalid selection. Please choose a valid bill number.")
    else:
        dispatcher.utter_message("Invalid input. Please provide a valid number.")
	    
    bill_number = input("Enter Bill Number: ")
    dispatcher.utter_message(f"Your bill number is: {bill_number}.")
    return [SlotSet("bill_number", bill_number)]

```

this code get input in rasa action prompt how i get this input in rasa shell prompt

---

_[View the full topic](https://forum.rasa.com/t/for-example-i-want-to-pay-a-bill-how-this-we-can-be-done-in-a-single-function-and-we-get-input-in-same-function/60914)._
