Templates

Learn how to configure Templates for your app. This page includes descriptions and examples for defining Templates in a Kustomer app.

Templates are an outline of different features within Kustomer that give you a useful starting point to use right away or modify that template to a more specific use case for you.

Apps can currently configure Business Rules and Reporting Charts templates.

📘

Note

We currently recommend that you use the Kustomer UI to generate templates, then copying and pasting the response in the network console to be added to your app. We understand that this may be difficult, so if you need support using these app-installed templates, please contact [email protected].

Templates format in the app definition

The templates property takes an object of properties that define the following for each template category. Each category then has an array of templates that define the following for each template.

Templates definition example

The following sample JSON app definition includes a templates property definition that creates and configures Business Rules and Charts templates in Kustomer.

{
   "app":"ecommstore",
   "version":"0.0.1",
   "title":"E-comm Store",
   "templates":{
      "charts":[
         {
            "title":"Example Chart Template Title",
            "description":"Chart template description example.",
            "category":"Apps",
            "templateId":"example-chart-template",
            "labels":[
               {
                  "axis":{
                     "y":"",
                     "x":""
                  }
               }
            ],
            "queries":[
               {
                  "chartType":"datatable",
                  "queryContext":"conversation",
                  "data":{
                     "interval":"week",
                     "metrics":[
                        {
                           "field":"conversation_updated_at",
                           "type":"conversations_over_time",
                           "metrics":[
                              {
                                 "field":"conversation_prediction_corrected_by",
                                 "type":"conversations_term"
                              }
                           ]
                        }
                     ],
                     "range":{
                        "field":"conversation_updated_at"
                     },
                     "query":{
                        "and":[
                           {
                              "conversation_prediction_corrected_by":{
                                 "is_set":true
                              }
                           },
                           {
                              "conversation_prediction_status":{
                                 "equals":"corrected"
                              }
                           }
                        ],
                        "or":[
                           
                        ]
                     }
                  }
               }
            ]
         }
      ],
      "bizRules":[
         {
            "id":"example-bizRules-template",
            "pillIcon":"check",
            "pillType":"success",
            "title":"Example Biz Rules Title",
            "description":"Biz Rules template description example. This is a very long description to see how it would look on the UI",
            "category":"add_tag",
            "data":{
               "templateId":"example-bizRules-template",
               "name":"Example Name"
            }
         }
      ]
   }
}

Templates properties

The basic templates definition properties and their descriptions are listed below:

charts

Optional. An array with the following object as a Chart:

Example:

{
   "title":"Example Chart Template Title",
   "description":"Chart template description example.",
   "category":"Apps",
   "templateId":"example-chart-template",
   "labels":[
      {
         "axis":{
            "y":"",
            "x":""
         }
      }
   ],
   "queries":[
      {
         "chartType":"datatable",
         "queryContext":"conversation",
         "data":{
            "interval":"week",
            "metrics":[
               {
                  "field":"conversation_updated_at",
                  "type":"conversations_over_time",
                  "metrics":[
                     {
                        "field":"conversation_prediction_corrected_by",
                        "type":"conversations_term"
                     }
                  ]
               }
            ],
            "range":{
               "field":"conversation_updated_at"
            },
            "query":{
               "and":[
                  {
                     "conversation_prediction_corrected_by":{
                        "is_set":true
                     }
                  },
                  {
                     "conversation_prediction_status":{
                        "equals":"corrected"
                     }
                  }
               ],
               "or":[
                  
               ]
            }
         }
      }
   ]
}

bizRules

Optional. An array with the following object as a Business Rule:

Example:

{
   "id":"example-biz-rule-template",
   "title":"Example Biz Rule Template Title",
   "description":"Biz rule template description example",
   "data":{
      "templateId":"example-biz-rule-template",
      "name":"Example Biz Rule Template Title",
      "description":"Biz rule template description example",
      "trigger":"kustomer.conversation.update",
      "eventTrigger":"conversation.first_inbound_message",
      "criteria":{
         "and":[
            {
               "conversation_importedAt":{
                  "operator":"not_set"
               }
            }
         ],
         "or":[
            
         ]
      },
      "actions":[
         {
            "type":"draft",
            "app":"kustomer",
            "input":{
               "drafts":[
                  {
                     "body":"Hello {{customer.name}},\n\nThank you for contacting us. Someone will be with you shortly.\n\nThank you!",
                     "channel":"email",
                     "from":"",
                     "template":null,
                     "templateType":"email-reply"
                  }
               ]
            }
         }
      ],
      "enabled":false
   },
   "isVisibleOnPage":true,
   "category":"send_message",
   "categoryName":"category name",
   "pillIcon":"email",
   "pillType":"complete"
}

Generate a template

Instead of trying to write a Kustomer template entirely from scratch, we recommend following these steps to create a template:

  1. Build a Chart or Business Rule in Kustomer's corresponding feature.
  2. Select Create with the network tab open in the console.
  3. Copy the request body as your template.

Please reach out to [email protected] if you have any specific questions about generating templates in Kustomer.


Did this page help you?