From fdddcc671488c0846b115cb8948adf6eb2e83e5e Mon Sep 17 00:00:00 2001 From: Andrew Schirmer Date: Wed, 1 Jul 2026 14:24:02 -0600 Subject: [PATCH] 1.6.0 documentation --- CHANGELOG.md | 9 ++++++ README.md | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 84 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c361d3..1f44d43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +**1.6.0** — 2026-07-01 + +- added `triggerEventReceived` listener for trigger event workflow steps +- added `sendTriggerEventResponse` to resume a conversation after a trigger event +- added `clearLocalData`, `launchQuery`, `updateConversationContext`, `updateConfigParams`, and `sendMessage` APIs +- changed the loading indicator to be black + +⸻ + **1.5.4** - 2026-06-25 - Fixed a crash when opening a link with no browser/handler installed diff --git a/README.md b/README.md index 29ffa87..77b1750 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ repositories { // add the dependency to the app's build.gradle dependencies { // Solve Android SDK - implementation "ai.forethought:solve-android-source:1.5.4" + implementation "ai.forethought:solve-android-source:1.6.0" } ``` @@ -44,7 +44,7 @@ repositories { // add the dependency to the app's build.gradle dependencies { // Solve Android SDK - implementation("ai.forethought:solve-android-source:1.5.4") + implementation("ai.forethought:solve-android-source:1.6.0") } ``` @@ -221,6 +221,79 @@ data class ForethoughtHandoffData( ) ``` +### Trigger Events + +A workflow can include a trigger event step that hands control back to your app to do native work (e.g. authenticate a user, look up account data) before resolving one or more context variables. When such a step is reached, the `triggerEventReceived` callback is invoked. + +```kotlin +data class ForethoughtTriggerEventData( + val event: String?, + // The event name configured on the trigger event step + val name: String?, + // Names of the context variables the host is expected to return + val expectedContextVariables: List?, + // Additional context from the step (includes `free_form_query`) + val additionalContext: Map?, +) +``` + +Implement `triggerEventReceived` (it has a default implementation, so it is optional), do your native work, then call `sendTriggerEventResponse` with the trigger event's `name` and the resolved context variables to resume the conversation. + +```java +// Java +@Override +public void triggerEventReceived(@NonNull ForethoughtTriggerEventData triggerEventData) { + // Do your native work here, then resolve the expected context variables. + Map payload = new HashMap<>(); + payload.put("cv1", "foo"); + payload.put("cv2", "bar"); + + Forethought.INSTANCE.sendTriggerEventResponse(triggerEventData.getName(), payload); +} + +// Kotlin +override fun triggerEventReceived(triggerEventData: ForethoughtTriggerEventData) { + // Do your native work here, then resolve the expected context variables. + Forethought.INSTANCE.sendTriggerEventResponse( + identifier = triggerEventData.name ?: "", + payload = mapOf("cv1" to "foo", "cv2" to "bar") + ) +} +``` + +### Widget Commands + +The following methods drive the widget while it is shown. Each is a no-op unless the Forethought Solve view is currently shown (`show()` has been called) and the widget has finished loading. + +- `launchQuery(query)` — launches the widget with an initial query on the user's behalf. +- `sendMessage(message)` — sends a message on the user's behalf. +- `updateConversationContext(context)` — merges the given key/value pairs into the conversation context. +- `updateConfigParams(params)` — updates the widget configuration parameters. +- `clearLocalData()` — clears the widget's locally stored data (e.g. conversation history). + +```java +// Java +Forethought.INSTANCE.launchQuery("How do I reset my password?"); +Forethought.INSTANCE.sendMessage("Hello"); + +Map context = new HashMap<>(); +context.put("", "new cv value"); +Forethought.INSTANCE.updateConversationContext(context); + +Map params = new HashMap<>(); +params.put("theme-color", "red"); +Forethought.INSTANCE.updateConfigParams(params); + +Forethought.INSTANCE.clearLocalData(); + +// Kotlin +Forethought.INSTANCE.launchQuery("How do I reset my password?") +Forethought.INSTANCE.sendMessage("Hello") +Forethought.INSTANCE.updateConversationContext(mapOf("" to "new cv value")) +Forethought.INSTANCE.updateConfigParams(mapOf("theme-color" to "red")) +Forethought.INSTANCE.clearLocalData() +``` + ### Plugins **⛔️ Plugins were removed in version 1.0.0 ⛔️**