Skip to content

updated guide about context object setting section. #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 29 additions & 16 deletions android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ To ensure that your `AgentApplication` class is used as the application class, y

Now that you have installed and initialized the AI Agent SDK, follow the steps below to run your application.

> Note: Make sure to perform the following steps after the SDK has been successfully initialized. Once initialization is complete, set up the user session and launch the messenger.

### Manage user sessions

To use the SDK, session information is required.
Expand Down Expand Up @@ -238,13 +240,7 @@ However, if you’re using a custom or legacy activity, verify that it inherits
To add the MessengerLauncher to your screen, simply call the `attach()` function of `MessengerLauncher`, specifying the AI agent ID and configuration parameters:

```kotlin
val params = LauncherLayoutParams(
LaunchMode.ANCHORED,
LauncherMargin(12, 12, 12, 12),
LauncherLocation.BOTTOM_END
)

MessengerLauncher(this, it, params).attach()
MessengerLauncher(context, "your_ai_agent_id").attach()
```

- `LauncherLayoutParams` allows you to configure the MessengerLauncher’s behavior and appearance:
Expand Down Expand Up @@ -302,19 +298,36 @@ You can predefine customer-specific information such as country, language, or ot

This allows for a more personalized and context-aware interaction experience.

> Once the contexts are set, they will be used throughout the conversation to provide personalized and context-aware responses.
> Once the contexts are set, they will be used throughout the conversation to provide personalized and context-aware responses. The configured context is set when the conversation starts.
If you need to update the context during the conversation, you can use the Platform API to modify it.

#### 1. Applying settings data through MessengerLauncher
```kotlin
AIAgentMessenger.metadata.language = "en-US" // default: Locale.getDefault().toLanguageTag()
AIAgentMessenger.metadata.countryCode = "US" // default: Locale.getDefault().country

AIAgentMessenger.metadata.message.contextObject.put("key1", "value1")
AIAgentMessenger.metadata.message.contextObject.putAll(
mapOf(
MessengerLauncher(this, it, LauncherSettingsParams(
language = "en-US",
countryCode = "US",
context = mapOf(
"key1" to "value1",
"key2" to "value2"
)
)).attach()
```

#### 2. Applying settings data through full-screen conversation

```kotlin
startActivity(
ConversationActivity.newIntent(
context = context,
aiAgentId = aiAgentId,
conversationSettingsParams = ConversationSettingsParams(
language = "en-US",
countryCode = "US",
context = mapOf(
"key1" to "value1",
"key2" to "value2"
)
)
)
)
AIAgentMessenger.metadata.message.contextObject.remove("key1")
AIAgentMessenger.metadata.message.contextObject.clear()
```