How to include properties in chat messages, REST api, and set property

Learn how to enhance your Customerly chat interactions by including user, conversation, environment, and company properties in chat messages, through the REST API, and the set property feature. This guide covers the types of properties available and how to use them effectively.

Elena
Written by ElenaLast update 19 days ago

Customerly provides a powerful feature to dynamically include properties (also called merge tags) in chat messages, REST API requests, and when setting properties.

This functionality can help you personalize interactions, automate responses, and streamline data management. In this article, we will explore the different types of properties you can use and provide examples of how to include them in various contexts.

Types of Properties

Customerly supports four types of properties that can be included in chat messages and other contexts:

  1. Contact Properties: Information related to the contact.

  2. Conversation Properties: Data specific to the conversation.

  3. Environment Properties (env): Variables from the environment.

  4. Company Properties: Details related to the company.

Using Properties in Chat Messages

You can include properties directly in your chat messages by using curly braces ({{ }}) syntax. When typing a message, Customerly will provide a selector to choose from available properties. Here’s how you can use each type:

Contact Properties

To include contact properties in a message:

Hi {{ contact.name }}, welcome back!

This will be resolved to:

Hi Gianni, welcome back!

Conversation Properties

To include conversation properties:

Your conversation ID is {{ conversation._id }}.

This will be resolved to:

Your conversation ID is 123456.

Environment Properties

To include environment properties:

{
  "auth": "{{ env.slack_token }}"
}

This will be resolved to:

{
  "auth": "ifijrie349349340NISIASi20202=="
}

Company Properties

To include company properties:

We are checking your {{ company.name }} invoicing, we'll send shortly all the invoices related to {{ company.name }}.

This will be resolved to:

We are checking your ACME invoicing, we'll send shortly all the invoices related to ACME.

Using Fallback Values

If a property value is null or empty, you can provide a fallback text:

Hi {{ contact.name | "there" }}!

if for any reason the user.name is null or empty this will be resolved to:

Hi there!

Using Properties in REST API Requests

Properties can also be included in REST API requests. Here’s how to structure a request that includes properties:

POST /api/v1/messages Content-Type: application/json 
{ 
   "user_id": {{ contact.id }}, 
   "conversation_id": {{ conversation._id }}, 
   "message": "Hello, {{ contact.name }}!" 
}

This will be resolved to:

{ 
   "user_id": 123, 
   "conversation_id": 530288302, 
   "message": "Hello, Elena!" 
}

Conclusion

By effectively using properties in chat messages, REST API requests, and setting properties, you can create a more personalized and efficient customer service experience. Use the provided examples to start leveraging these powerful features in your Customerly account. If you need further assistance, feel free to reach out to our support team.

Did this answer your question?