Items
To provide better customer experience, the Chat offers support for predefined and customizable items displayed within the conversation flow.
Default Cards
The Chat supports rendering of hero cards through the RenderAttachments() method, which displays attachments with customizable layout options.
@(Html.Kendo().Chat()
.Name("chat")
)Adding Images to Hero Cards
You can add images to the hero card by passing image data to the attachments.content.images object.
<script>
var chat = $("#chat").data("kendoChat");
chat.renderAttachments({
attachments: [{
contentType: "heroCard",
content: {
title: "Product Card",
subtitle: "Featured Product",
text: "High-quality product example.",
images: [{
url: "https://example.com/image.png",
alt: "Product Image"
}]
}
}],
attachmentLayout: "carousel"
}, chat.getUser());
</script>
Suggested Actions
The Chat supports rendering of suggested actions through the RenderSuggestedActions() method. These appear as quick-reply options below the message input area, enabling users to select predefined responses.
@(Html.Kendo().Chat()
.Name("chat")
)Custom Templates
The Chat provides options for defining custom templates to render custom payload returned by your service. This allows you to display specialized content types beyond the default hero cards and suggested actions.
Registering and Using Custom Templates
- Define a template using the Kendo template syntax.
- Register the template with the Chat using
kendo.chat.registerTemplate(). - Use the registered template when rendering attachments.
<script id="quote-template" type="text/x-kendo-template">
<div class="#=styles.card# #=styles.cardRich#">
<div class="#=styles.cardBody#">
<div>
<strong>Type:</strong>
<span>#:coverage#</span>
</div>
<div>
<strong>Car model:</strong>
<span>#:make#</span>
</div>
<div>
<strong>Car cost:</strong>
<span>#:worth#</span>
</div>
<div>
<strong>Start date:</strong>
<span>#:startDate#</span>
</div>
<hr/>
<div>
<strong>Premium:</strong>
<span>#:premium#</span>
</div>
</div>
</div>
</script>