Hi, I tried to get some values from user input and passed it to my custom action with below code:
This is my custom action
class ActionTrendingByHashTag(Action):
def name(self) -> Text:
return "action_trending_by_hashtag"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
hashtag = next(tracker.get_latest_entity_values("hashtag"),None)
result = get_tiktok_trending_by_hashtag(hashtag)
for video in result:
dispatcher.utter_message(text=video['title'], image=video['cover'])
return []
And here is intent:
- intent: confirm_hashtag
examples: |
- [cosplay](hashtag) nha
- Hashtag là [cosplay abc](hashtag)
- Từ khóa là [cosplay](hashtag)
- hashtag anh muốn tìm là [cosplay](hashtag)
- Từ khóa cần tìm kiếm là [cosplay](hashtag)
- Anh muốn tìm về từ khóa [cosplay](hashtag)
first check that are you able to get the user input whilst using the print statement
print(hashtag)
then next like
get_tiktok_trending_by_hashtag({hashtag})
check
print(result)
Thanks for your reply, when I print(hashtag), it give me None. When I type ‘cosplay’ same with examples, entity can get this value but the other word hashtag is None. Any idea about it?
@nik202 My partner tried with new intent:
And he made all files like me, the result he got is:
I don’t know why he success but not me.
Should I create an lookup example for the entity? But the entity I want to get value is unpredictable such as hashtag, … because it has very many different values.
@nik202 I don’t change my code, now it the same with above. I don’t know where is my mistake to fix that Do you need more code, tell me, I will show it. Thanks so much!
@baodv1001 I already shared the solution’s, suggestion and even proposed to schedule a meeting but you have not shown any interest so sorry I can not help much on this. Good Luck!
@nik202 Thanks for you support. I realize that if I want to get some value like email, phone number … I should use entity and regex to extract that entity. But with dynamic value like name, hashtag, … should use form to extract value. I will try this idea soon. Thanks again!