Menu

Expand
Rate this page:

Conversations Attributes

Overview

The attributes property unlocks the potential to add additional context about specific objects. You can use this functionality to build many capabilities into your application. Some common use cases you could build are:

  • Skill-based routing for Conversations
  • Avatar URLs in a User profile
  • Context about customers (i.e. referral source, product type, etc.)
  • Message replies/threading
  • Emoji reactions to messages
  • Profile information
  • Message metadata
  • Customer loyalty status
  • Non-chat Participant display name

This property is optional, and the field value is a JSON object that can store up to 16 KB. If the attributes are not set, then an empty object is returned.

You can use the attributes field in any of the following Conversations objects:

  • Participant
  • User
  • Conversation
  • Message

Set or modify Attributes

You can set the attributes of an object by calling the update method on the object you want to add to. For example, you can add attributes to an existing Message by passing the correct method and specifying the attributes on that Message object.

You can also add attributes to objects when you create them. For example, you can set attributes when you add a Participant to a Conversation.

To retrieve the attributes for an object, just make sure to invoke the corresponding method or property. The attributes will be returned in JSON format.

Loading Code Sample...
        
        

        Set or Modify Attributes

        Listen for changes to these objects

        To receive events about updates to object attributes, listen for "update" events at the Client object (e.g. conversationUpdated, messageUpdated, etc.). The event update reason will indicate that the attributes were changed and include the updated object.

        What's Next?

        Well done! You can continue learning more about Conversations by checking out the following guides:

        Rate this page:

        Need some help?

        We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

        Loading Code Sample...
              
              
              

              Thank you for your feedback!

              Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

              Sending your feedback...
              🎉 Thank you for your feedback!
              Something went wrong. Please try again.

              Thanks for your feedback!

              thanks-feedback-gif