Guided Conversation Variables

Global Variables

To effortlessly access variables within a guided conversation, simply click the lightning bolt icon located at the top right corner of your screen. You'll find the global variables listed at the bottom, highlighted in blue for easy identification.

{{conversation_transcript}}

This is the transcript of the specific conversation which is currently being used. An example way to use this would be to put it in the description of a Helpdesk ticket card. This would allow the helpdesk agent to see the full guided conversation back and forth while working the ticket.

{{org_uuid}}

This is the unique ID for your account. You may use this when building integrations with Capacity’s internal APIs.

{{org.reply_to_email}}

This is the reply-to email set on your account. Settings -> Org Settings > Email.

{{nlp.inquiry}}

This is the input from the chat user that triggered this conversation. An example of using this may be putting it into a description of a helpdesk ticket to let the agent know the original question from the chat user.

{{nlp.matched_input}}

This is the input that was matched to trigger this conversation.

{{nlp.matched_input_uuid}}

This is the unique ID of the input that was matched to trigger this conversation.

{{sys.utctime}}

This pulls the current UTC datetime stamp. Sometimes this timestamp is used for 3rd party integrations.

{{session.transcript}}

This is the transcript of the chat user’s entire session with the chat bot. This is best used in the Helpdesk Ticket card in “Additional Info”. Add a field here, name it “transcript” and add the session.transcript as the value. It will appear as a blue hyperlink in the right panel of any ticket made from the guided conversation. A modal will pop up with the full session transcript.

{{session.pretty_transcript}}

This is best used for 3rd party integrations that require us to send the session transcript. It will include HTML to display properly in other systems. For proper display in Capacity, {{session.transcript}} is recommended.

{{ai_tools.is_enabled}}

This is used to determine if your organization has AI enabled in settings. It can be used in logic to have conditional paths in a conversation based on if AI is enabled at the time of the conversation or not.

{{interface.is_authenticated}}

This is used to denote if the interface that is handling the conversation session is authenticated or not. It can be used in logic to create conditional paths for accessing content based on if the interface is authenticated or unauthenticated.

Magic Functions

In software development, data serialization and string manipulation are essential. At Capacity, we have a set of robust magic functions designed to simplify JSON processing and string formatting tasks. These functions can be appended to variables and make working with JSON objects and strings a breeze. Below, we explore these functions with some sample inputs and outputs to illustrate their usage.

  1. to_json: Converts an object to a JSON string, with no spaces and on a single line.

  2. to_pretty_json: Converts an object to a nicely formatted JSON string.

  3. from_json: Converts a JSON string back to an object.

  4. json_escape: Escapes a JSON object to be safely nested within another JSON object.

  5. nl_to_br: Replaces newline characters with <br> tags.

  6. escape_strings: Replaces single (') and double (") quotes with their escaped counterparts (\' and \").

1. to_json

Converts an object to a JSON string, without spaces and on a single line.

Sample Input:

{{obj|to_json}}

Output:

{"name":"Alice","age":30,"city":"Wonderland"}

2. to_pretty_json

Converts an object to a nicely formatted JSON string.

Sample Input:

{{obj|to_pretty_json}}

Output:

{
"name": "Alice",
"age": 30,
"city": "Wonderland"
}

3. from_json

Converts a JSON string back to an object.

Sample Input:

{{jsonStr|from_json}}

Output:

{
name: "Alice",
age: 30,
city: "Wonderland"
}

4. json_escape

Escapes a JSON object to be safely nested within another JSON object.

Sample Input:

{{nestedJson|json_escape}}

Output:

{\"data\":{\"name\":\"Alice\",\"age\":30}}

5. nl_to_br

Replaces newline characters with <br> tags.

Sample Input:

{{multilineStr|nl_to_br}}

Output:

Alice<br>30<br>Wonderland

6. escape_strings

Replaces single (') and double (") quotes with their escaped counterparts (\' and \").

Sample Input:

{{str|escape_strings}}

Output:

Alice said, \"Hello!\"

Conclusion

These magic functions greatly simplify common tasks when working with JSON and strings in Capacity. By using to_json, to_pretty_json, from_json, json_escape, nl_to_br, and escape_strings, developers are empowered to handle complex data transformations with minimal effort.


Was this article helpful?