> For the complete documentation index, see [llms.txt](https://docs.conva.ai/slang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.conva.ai/slang/advanced-topics/changing-the-assistant-behavior-at-runtime/accessing-and-setting-user-journey-context.md).

# Accessing and Setting User Journey Context

When the user journey callbacks are called, the Assistant passes details of the command via the Info parameter. But when users trigger the same user journey multiple times, the Assistant preserves the context of the previous invocation and reuses it. For example:

1. Let's say the user says "onions"
2. The Assistant invokes the `onSearch` callback and passes the `SearchInfo` object with "onions" as the value for the`productType` field. All other fields in the object will be empty.
3. Now let's say the user says "show me organic ones"
4. The Assistant now invokes the `onSearch` callback again and this time passes the SearchInfo object with two fields set:  `variant` with "organic" as the value and also `productType`with "onions" as the value. This way, it preserves the context between multiple invocations.&#x20;

Sometimes the app might want to access or set the context outside the scope of the callbacks.

The Assistant is built to be used in a multi-modal environment, where the users might use the UI to perform certain operations and voice to perform others. It's quite natural for the user to be searching for an item by typing it and then switch to voice to provide additional filters.  In such cases, the app can pass data to the Assistant explicitly via the appropriate user journey context APIs, as below:

{% tabs %}
{% tab title="Native Android" %}

```
SearchUserJourney.getContext().getProductType();
SearchUserJourney.getContext().setProductType("onions");
```

{% endtab %}

{% tab title="React Native" %}

```
var category = SearchUserJourney.context.getItemCategory();
SearchUserJourney.context.setItemCategory("grocery");
```

{% endtab %}

{% tab title="Flutter" %}

```
Under development
```

{% endtab %}

{% tab title="Web" %}

```
Under development
```

{% endtab %}
{% endtabs %}

&#x20;Sometimes, it could be important to not preserve context automatically. For example, if the user has cleared the results and started a new search, then this may need to be treated as a fresh search rather than as a continuation of the previous search.

In such cases, the app can easily clear the context as shown below

{% tabs %}
{% tab title="Native Android" %}

```
SearchUserJourney.getContext().clear();
```

{% endtab %}

{% tab title="React Native" %}

```
SearchUserJourney.context.clear();
```

{% endtab %}

{% tab title="Flutter" %}

```
SearchUserJourney.getContext().clear();
```

{% endtab %}

{% tab title="Web" %}

```
Under development
```

{% endtab %}
{% endtabs %}

##


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.conva.ai/slang/advanced-topics/changing-the-assistant-behavior-at-runtime/accessing-and-setting-user-journey-context.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
