# Jinja Templating

## Variables

When deploying an AI Agent, your API calls will typically consist of two types of content:

* **Fixed content** Static instructions or context that remain constant across multiple interactions
* **Variable content:** Dynamic elements that change with each request or conversation, such as:
  * User inputs
  * Retrieved content for Retrieval-Augmented Generation (RAG)
  * Conversation context such as user account history
  * System-generated data such as tool use results fed in from other independent calls to Claude

The variable content is denoted with **`{{double brackets}}`**, making them easily identifiable and allowing for quick testing of different values.

<figure><img src="https://2450152260-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNWqgWAjD0VVJgjYDpsN5%2Fuploads%2FdJ8d4DmhCy4J3VwUKv2C%2FScreenshot%202025-05-15%20at%2012.51.59%E2%80%AFPM.png?alt=media&#x26;token=6f32b4f0-0566-4627-8c68-b12061f00998" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2450152260-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNWqgWAjD0VVJgjYDpsN5%2Fuploads%2FPfkGNB9tDoOTXerF2I66%2FScreenshot%202025-01-02%20at%2012.48.16%E2%80%AFPM.png?alt=media&#x26;token=dbdb3e26-14cb-4e02-bd54-8bad2261f0b7" alt=""><figcaption></figcaption></figure>

In the example below,  there is a JSON object with a `title` and `pageContent` that is passed to the LLM Prompt

{% code title="AI Prompt" overflow="wrap" %}

```
{% if pageJSON %}
# Inputs
pageJSON: {{ pageJSON }}
By default, assume that the subject of enquiry is {{ pageJSON.title }}. 
{% endif %}
```

{% endcode %}

{% code title="JSON Object as a Variable {{ pageJSON }}" %}

```json
{
  "title": "Deploy to WhatsApp",
  "pageContent": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <title>Deploy to WhatsApp</title>\n</head>\n<body>\n  <h1>Deploy to WhatsApp</h1>\n  <p><strong>One-click integration for your AI Copilot</strong></p>\n\n  <h2>How to deploy on WhatsApp</h2>\n  <h3>Prerequisites</h3>\n  <ul>\n    <li>Verified Facebook business account</li>\n    <li>A new or spare phone number for the WhatsApp bot</li>\n  </ul>\n\n  <h3>Integration</h3>\n  <p>Click on the <a href=\"https://gooey.ai/copilot/integrations/\">Integrations tab</a> in the copilot workflow</p>\n  <ul>\n    <li>Use the \u201cWhatsApp\u201d button</li>\n    <li>You\u2019ll be redirected to Facebook Login Page</li>\n  </ul>\n\n  <blockquote>\n    <strong>NOTE:</strong> Gooey connects to a Facebook profile, not a Facebook Page. If you don\u2019t have access to the organization\u2019s Facebook profile, create a dedicated one.\n  </blockquote>\n\n  <ol>\n    <li><strong>Step 1:</strong> Fill Business Information</li>\n    <li><strong>Step 2:</strong> Choose your business account (or create a new one)</li>\n    <li><strong>Step 3:</strong> Add a phone number for your WhatsApp bot</li>\n    <li><strong>Step 4:</strong> Verify the phone number</li>\n  </ol>\n\n  <p><strong>YOUR BOT IS NOW READY!</strong></p>\n\n  <h3>Test</h3>\n  <p>You can test your bot by heading to the registered number!</p>\n\n  <h3>Share</h3>\n  <p>To share the link with others, share the number like this: <a href=\"https://wa.me/\">https://wa.me/&lt;number&gt;</a></p>\n\n  <h2>Frequently Asked Questions</h2>\n\n  <h3>Q: I have got a new number for the WhatsApp integration but it isn't working. What should I do?</h3>\n  <p>A: Avoid these mistakes:</p>\n  <ul>\n    <li>Activating the SIM on a smartphone with WhatsApp</li>\n    <li>Registering the phone number directly on Facebook</li>\n    <li>Registering the phone number on WhatsApp Manager</li>\n  </ul>\n  <p>You\u2019ll need to deactivate these before integrating with Gooey Copilot.</p>\n\n  <h3>Q: The integration worked successfully, but it's not working now. Why is this?</h3>\n  <p>A: After integration, do not use the number with a WhatsApp client. That breaks the bot integration.</p>\n\n  <h3>Q: The integration worked successfully, why did the bot stop working after the first day?</h3>\n  <p>A: Facebook requires a credit card on file to keep the number active. Even if they don\u2019t charge anything, it\u2019s necessary to pass their verification process.</p>\n\n  <h2>Need a WhatsApp Number?</h2>\n  <p>Upgrade to a business plan at <a href=\"https://gooey.ai/pricing\">https://gooey.ai/pricing</a></p>\n  <p>Or <a href=\"https://gooey.ai/contact\">book a sales call</a> if you have questions.</p>\n</body>\n</html>"
}
```

{% endcode %}

{% embed url="<https://gooey.ai/copilot/json-object-test-colgggewwvbo/>" %}
See the Example here
{% endembed %}

## Conditional statements

It is a common use-case that the same AI Agent example might be deployed/integrated on various platforms like SLACK, WHATSAPP, WEB and so on. In this scenario, formatting and text outputs might be needed, which means you need different prompts for each platform. With Jinja Templating, this issue is solved. You can use the prompt example below and tweak it as needed:

{% code title="if statement in prompts" overflow="wrap" %}

```
{% if platform in [ "WHATSAPP", "SLACK" ] %}
Remember, you are a {{ platform }} agent, so do not use HTML, latex or any other markup language, instead use only the following formatting styles: 
italic: single underscore
bold: single asterix. Do not use 2 asterix as per markdown, instead use {{ platform }} guidelines and use 1 asterix only
strikethrough: single tilde
code: single backtick
code block: 3 backticks
quoted text: place an angle bracket and space before the text
headings: just use bold style with 1 asterix.

{% elif platform == "TWILIO"  %}
Remember, you are a voice agent, so do not use markdown, HTML, latex or any other markup language, instead, output plain text without any formatting characters like asterisk, hyphen, bracket, hash, underscore etc. 
{% endif %}
```

{% endcode %}

{% embed url="<https://gooey.ai/copilot/>" %}
