# Set values to variables using Trigger

Want to personalize chat or capture details about the visitor even before the chat is initiated? This is possible with Buraq where it allows you to inject custom variables from outside using the Trigger action block even before the chat is initiated.

The values can be anything like sending and storing the details like name of the visitor, utm parameters of where the visitor is coming from can be captured and mapped with the variables.

The values stored in these defined variables, and can later be used at any given point of time in the flow of the chat.

There are two methods in Buraq that a user can follow to parse the information into variables. They are:

### Via Query Params <a href="#via-query-params" id="via-query-params"></a>

Using this method, you will be able to send Query Params on the domain in which the bot is hosted & you will be able to map those params in the ‘Trigger’ action block with a variable name.

For example, [www.buraq.ai?utm\_source=google\&utm\_medium=website](http://www.wotnot.io/?utm_source=google\&utm_medium=website\&utm_content)

Let’s say I want to store the value of `utm_source` and `utm_medium`, I can simply map these names in the 'Object path/parameter' column.

And choose the variables in which this value is to be stored.

![](https://help.wotnot.io/~gitbook/image?url=https:%2F%2F360969599-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FsrMxU8nO3RjusUiYuXBB%252Fuploads%252FPUJ2CG3tnzlGPEd3epgq%252FCleanShot%25202023-06-06%2520at%252016.32.33.png%3Falt=media%26token=5ee61e96-d427-448a-b111-85f73f11e7ab\&width=300\&dpr=4\&quality=100\&sign=0690f4029d561455b2b46dfd772f7d75d27571ed657f4daa14d1a831b426011a)

You can add a maximum of 15 entries

#### Storing values for a WhatsApp chatbot <a href="#storing-values-for-a-whatsapp-chatbot" id="storing-values-for-a-whatsapp-chatbot"></a>

While using this section for a WhatsApp chatbot, you can store the payload received from the WhatsApp Business API provider.

This is helpful if you want to branch out the conversation flow based on button/text inputs from an outbound message sent.

<table><thead><tr><th>Provider</th><th>Button input</th><th>Text input</th></tr></thead><tbody><tr><td>Meta</td><td><pre><code>entry[0].changes[0].value.messages[0].button.payload
</code></pre></td><td><pre><code>entry[0].changes[0].value.messages[0].text.body
</code></pre></td></tr><tr><td>360Dialog</td><td><code>messages[0].button.text</code></td><td><code>messages[0].text.body</code></td></tr><tr><td>360Dialog Cloud</td><td><pre><code>entry[0].changes[0].value.messages[0].button.text
</code></pre></td><td><pre><code>entry[0].changes[0].value.messages[0].text.body
</code></pre></td></tr><tr><td>Twilio</td><td><code>payload.Body</code></td><td><code>payload.Body</code></td></tr><tr><td>GupShup</td><td><pre><code>payload.payload.text
</code></pre></td><td></td></tr></tbody></table>

### Injecting JSON in the code snippet <a href="#injecting-json-in-the-code-snippet" id="injecting-json-in-the-code-snippet"></a>

Using this method the user will be able to inject a JSON payload inside Buraq's code snippet. And using the trigger action block the user will be able to map the object path with a variable.

For example,

```
<script src="" data-session-payload='{"name": "Charles", "phone": "8164848686"}' defer></script>
```

In addition to the code snippet, we have added a data-session-payload section. Adding this section with a JSON payload allows Buraq's to read these values and store them in variables.

In the above example, we have passed the values of “name” and “phone”, so now to store these values, we will map these fields on the Trigger action block.

{% hint style="info" %}
It is essential to dynamically add this data-session-payload on Buraq's code snippet before the code snippet is fired, because Buraq only reads this data once.
{% endhint %}

To read the data again, visitors would have to refresh the page and start conversing with the bot again.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.buraq.ai/action-blocks/trigger/set-values-to-variables-using-trigger.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
