AI Topic Button Widget
The AI Topic Button Widget is a powerful extension of the Popup widget, designed to streamline user interactions by enabling a single OpenAI assistant to handle multiple predefined topics. This approach significantly reduces implementation effort and enhances user experience by providing targeted initial responses based on the selected topic.
Key Features
- Multiple Pre-configured Topics: Configure various conversation starters using a single assistant
- Streamlined User Experience: Users can select specific topics via intuitive button interfaces
- Customizable Styling: Comprehensive styling options for buttons to match your website's design
- Programmatic Control: Full JavaScript API for controlling widget behavior
Implementation Guide
Basic Installation
Add the Topic Button Widget to your website by including the following code:
<script type="module">
import Agent from 'https://cdn.jsdelivr.net/npm/@agent-embed/js@latest/dist/web.js'
Agent.initPopup({
agentName: "Assistant OpenAI-someId", //generated on the PD app
});
</script>
<!-- Topic Buttons -->
<ai-button id="1">Button For Topic #1</ai-button>
<ai-button id="2">Button For Topic #2</ai-button>
<!-- Additional buttons as needed -->
Configuring Topics
- Navigate to the Settings tab in your dashboard
- Select Topics to manage your topic configurations
- For each topic, define:
- Topic Message: The initial assistant response when a user selects this topic
- Exit Option: Enable to end the conversation after delivering the topic message
Topic Button Embedding
Each topic button can be individually embedded by copying its specific code from the settings:
<!-- Example for a specific topic button -->
<ai-button id="1">Button For Topic #1</ai-button>
Note: Button IDs increment automatically as you add topics, ensuring proper topic association.
AI-Generated Topic Messages
Create compelling topic messages by using the integrated AI generation feature:
- Click the ✨ button in the Topics section
- The system will use your OpenAI assistant to generate an appropriate initial response
Styling Options
Basic Button Styling
Style all topic buttons uniformly: You can style the ai-button using the ::part pseudo-element. Here's an example to set the font size:
<style>
ai-button::part(button) {
font-size: 20px;
/* Additional CSS properties */
}
</style>
This targets the button part of the ai-button component and adjusts its font size.
Tip: For WordPress users, If the styles don’t work as expected in your theme, try adding them to the Additional CSS section.