I’m clear that in order to retrieve first and last names from de objetct telegram.user of telegram.message i need to customize channel.py , return in get_metadata() values extracted from the message of Telegram writting in the tracker record metadata field.
I did this in my channel.py in rasa\core\channels\channel.py
def get_metadata(self, request: Request) -> Optional[Dict[Text, Any]]:
metadata=request.json#transfers the request to a python dictonary and make it readable in python
print("Metadata: ",str(metadata))
print("Type Metadaten: ",type(metadata))
print("User ID:", metadata["message"]["from"]["id"])
return metadata
In my actions.py I did this
class ActionGetSenderId(Action):
def name(self):
return "action_get_sender_id"
def run(self, dispatcher, tracker, domain):
input_data=tracker.latest_message
print(input_data["metadata"]["message"]["from"])
user_info=input_data["metadata"]["message"]["from"]
user_name=input_data["metadata"]["message"]["from"]["first_name"]
str_greet_name="Your name is "+user_name
dispatcher.utter_message(text=str_greet_name)
And like always you need to add you action to your domain and story…
Since I overwrote get_metadata it transvers the metadata to the telegram.py in my channels.