peixeprata
(Luli Oliveira)
1
Hello guys,
I have a greet action that returns an username, can I use that variable in a goodbye utterance without having to call another action?
Something like that:
Action:
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
utterances = ["Hello ##username##",
"Hi ##username##"]
utterance = random.choice(utterances)
dispatcher.utter_message(text=utterance, buttons=buttons)
Bye Utterance:
utter_bye:
- text: It was good chatting with you ##username##.
itsjhonny
(João Pedro Guimarães)
2
You can stored this value in slot
domain.yml
slots:
slot_username:
type: text
initial_value: null
influence_conversation: false
in action
from rasa_sdk.events import UserUtteranceReverted, SlotSet
#get value
username = tracker.get_slot('slot_username')
#set variable in slot
SlotSet('slot_username', 'some_username')
2 Likes
peixeprata
(Luli Oliveira)
3
Thanks João (Valeu João, salvou rs)!
Can I ask you something else? In Rasa 2 I should use that syntax in utterance?
utter_bye:
- text: It was good chatting with you ##username##.
Another thing is need to build a new action for that or I can set the slot inside the greet action?
itsjhonny
(João Pedro Guimarães)
4
I think the correct is
utter_bye:
- text: Nice to meet you, {slot_username}.
reference: Reaching Out to the User
You can set the slot inside your greet action
1 Like