Skip to content

Commit

Permalink
doc: Add template variables (#380)
Browse files Browse the repository at this point in the history
* Add template variables

* Apply suggestions from code review

---------

Co-authored-by: Vishnu Narayanan <vishnu@chatwoot.com>
  • Loading branch information
muhsin-k and vishnu-narayanan committed Jan 31, 2023
1 parent 9893e73 commit 950e9b1
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/sidebar/product.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ module.exports = [
"user-guide/features/keyboard-shortcuts",
"user-guide/features/segments",
"user-guide/features/commandbar",
"user-guide/features/template-variables",
"user-guide/features/multilingual-support",
{
Reports: [
Expand Down
1 change: 1 addition & 0 deletions docs/product.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ In this user guide, we’ve explained the features, capabilities, modes of opera
- [Reports](/docs/user-guide/features/reports/concepts)
- [Segments](/docs/user-guide/features/segments)
- [Pre Chat Form](/docs/user-guide/features/pre-chat-form)
- [Template Variables](/docs/user-guide/features/template-variables)

### Advanced

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions docs/user-guide/features/template-variables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: "Template variables"
---

Variables are placeholder text in messages that are dynamically replaced based on the information you've provided.

When you create a message with variables, Chatwoot will translate it to the appropriate value.

![variable list](./images/variables/variable-list.png)


If we send a message `Hey {{ contact.name }}, how may I help you?`, then Chatwoot will pick the contact name and send a message like `Hey John, how may I help you?`. This enables you to send personalized messages to the end user.

> Note: Chatwoot supports variables in canned response/macros/automation.
![variable demo](./images/variables/variable-demo.gif)

To use a variable, type two double curly brackets **{{** when composing a new message or creating a canned response. The variables will appear, and you can select the one you'd like to use.




The current list of template variables are:

<div class="table table-striped">

| Variable | Description |
| ----------------- | --------------------------------------------------------------------- |
| conversation.id | Numeric version of the conversation id |
| contact.id | Numeric version of the contact id |
| contact.name | Contact full name |
| contact.first_name | Contact first name |
| contact.last_name | Contact last name |
| contact.phone_number | Contact phone number |
| agent.name | Agent full name |
| agent.first_name | Agent first name |
| agent.last_name | Agent last name |
| agent.phone_number | Agent phone number |
</div>


**What if the variable doesn't exist?**

If you try to send an undefined variable, then Chatwoot will show a warning.


![undefined-variable](./images/variables/undefined-variables.png)


**How to add fallback text?**


When defining a fallback text, make sure you surround it with single quotes.

`{{ contact.first_name || 'there'}}`

0 comments on commit 950e9b1

Please sign in to comment.