Type Definition
Overview
Targets allows you to specify DOM elements where the SDK should automatically insert the generated response text and brand link. This enables seamless integration without manual DOM manipulation.
Properties
Target element for the AI-generated response text. Can be:
- CSS selector (string): e.g.,
"#response",".ai-text","[data-ai-response]" - HTMLElement: Direct DOM element reference
textContent or innerHTML.Target element for the brand affiliate link. Can be:
- CSS selector (string): e.g.,
"#brand-link",".brand-url" - HTMLElement: Direct DOM element reference (typically an
<a>tag)
href attribute if it’s an anchor tag, or inserted as text content for other elements.Examples
Using CSS Selectors
Using Direct Element References
Text Target Only
Link Target Only
DOM Integration Patterns
Chat Interface
Dynamic Content Cards
Form Integration
Multiple Targets Pattern
Advanced Usage
Custom Element Handling
Progressive Enhancement
Related Types
- AnswerRequest - Used alongside targets in the answer() method
- AnswerResponse - Response structure with text and link data
