Help with command /tellraw

Command cannot read chat, including what the player writes to the chat. But you can ask the player to rename an item, such as a nametag, and copy the name of the item into the name of any entity, or have the player apply this tag to a specific entity. And then display this name in the chat using a selector.

For example:

# Create template entity
summon minecraft:marker ~ ~ ~ {Tags:["Player_Name"]}

# When the player is holding a renamed item in main hand.
data modify entity @e[type=marker,tag=Player_Name,limit=1] CustomName set from entity @p SelectedItem.tag.display.Name

# Write to chat on the new player name
tellraw @a [{"text":"<"},{"selector":"@e[type=marker,tag=Player_Name,limit=1]"},{"text":"> Hello world!"}]
/r/MinecraftCommands Thread