Search code examples
javascripttypescripttwilio-conversations

Display friendly name instead of identity on a conversation


i'm trying to display the user's friendly name in a conversation but seems like the Message resource only retrieves the identity string as the message author

I've tried to fetch the conversation participants, create a new array with the messages and add a new field with the friendly name for every message but i don't think this is the best solution


Solution

  • The User has a friendlyName property (link) which you could use to store the name into. From the Twilio Conversations Client SDK you can get the users Conversation.GetParticipants() (link), and from the participant you can get the user using Participant.GetUser() (link).

    Alternatively, Conversation, Participant, and User all have a attributes property where you can store custom data into related to the resource. You could store the names in attributes and then fetch them as needed.

    I'd create an object with the identities as the key and the friendly names as values. Then as you iterate through your messages, you can lookup the friendly names using your identity/name object.