我有一个与以下问题相同的问题:Get Intent Value in RASA Core/NLU 但是我想要用户为给定意图提供的值。
例如:
User: I want to take it (this sentence is an intent called: 'use_it')
Bot: ....
User: .... (Later in the chat I decide to answer with the same phrase of intent 'use it')
Bot: you said previously "I want to take it"
我该如何做:tracker.get_slot
,但出于意图?
我不需要最后一个意图的名称,我想要用户提供的意图的文本。
答案 0 :(得分:0)
在将意图文本存储在插槽中的意图之后执行custom action:
from rasa_core_sdk import Action
from rasa_core_sdk.events import SlotSet
class ActionStoreIntentMessage(Action):
"""Stores the bot use case in a slot"""
def name(self):
return "action_store_intent_message"
def run(self, dispatcher, tracker, domain):
# we grab the whole user utterance here as there are no real entities
# in the use case
message = tracker.latest_message.get('text')
return [SlotSet('intent_message', message)]
然后您可以在utter template中使用设置的插槽的值:
slots:
intent_message:
type: text
templates:
utter_last_intent:
- "you said previously: {intent_message}"
答案 1 :(得分:0)
您可以将跟踪器用于任务。
text=tracker.latest_message['text']