Skip to content

Add JavaScript bridge layer for setAdditionalContext#39

Open
robertson-waweru wants to merge 4 commits intosalesforce:devfrom
robertson-waweru:stack/additional-context/04-js-bridge-layer
Open

Add JavaScript bridge layer for setAdditionalContext#39
robertson-waweru wants to merge 4 commits intosalesforce:devfrom
robertson-waweru:stack/additional-context/04-js-bridge-layer

Conversation

@robertson-waweru
Copy link
Contributor

Part 4 of stacked PRs for additional context support (W-21447588, W-21447589).

Changes

  • Add setAdditionalContext method to AgentforceService
  • Import and re-export CopilotAdditionalContext types
  • Add validation for context structure and variables
  • Add comprehensive JSDoc documentation with examples
  • Handle errors gracefully with clear messages
  • Log context application for debugging

Testing

  • Run TypeScript compilation to verify types
  • Build both iOS and Android to verify end-to-end integration
  • Test with valid context (various value types)
  • Test error cases (no conversation, invalid structure)
  • Verify console logs show context being set

Stack Context

Depends on: #36 (TypeScript types), #37 (iOS bridge), #38 (Android bridge) - merge in order
Next: Documentation and cleanup (PR #5)

Completes JS bridge integration for W-21447588 and W-21447589.

69 lines added

- Add CopilotContext.ts with CopilotContextVariable and CopilotAdditionalContext interfaces
- Add CopilotContextVariableType enum with Android SDK type names (Text, Number, Boolean, etc.)
- Export types from types/index.ts and src/index.ts
- Add comprehensive JSDoc with examples and type mappings

Establishes type contract for additional context feature.
- Add setAdditionalContext React method to AgentforceModule
- Convert NSDictionary to AgentforceVariable array with JSEncodableValue enum
- Handle value type conversion (string, number, boolean, array, object)
- Validate conversation exists before applying context
- Add method declaration to AgentforceModule.m

iOS implementation of additional context support.
- Add setAdditionalContext React method to AgentforceModule.kt
- Convert ReadableMap to CopilotAdditionalContext object
- Import SDK classes: CopilotAdditionalContext, CopilotContextVariable
- Handle multiple value types (String, Number, Boolean, Map, Array)
- Validate conversation exists before applying context
- Use coroutine scope for async context setting

Android implementation of additional context support.
- Add setAdditionalContext method to AgentforceService
- Import and re-export CopilotAdditionalContext types
- Add validation for context structure and variables
- Add comprehensive JSDoc documentation with examples
- Handle errors gracefully with clear messages
- Log context application for debugging

Completes JS bridge integration for W-21447588 and W-21447589.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant