Changeset 3234305
- Timestamp:
- 02/03/2025 10:14:50 PM (14 months ago)
- Location:
- agent700-ai-chat/trunk
- Files:
-
- 3 added
- 7 edited
-
README.md (modified) (1 diff)
-
agent700-ai-chat.php (modified) (9 diffs)
-
agent700-chat-template.php (modified) (1 diff)
-
assets/agent700-close-icon.svg (added)
-
assets/agent700-contract-icon.svg (added)
-
assets/agent700-expand-icon.svg (added)
-
assets/screenshot-2.png (modified) (previous)
-
readme.txt (modified) (3 diffs)
-
scripts/agent-chat.js (modified) (6 diffs)
-
styles/styles.css (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
agent700-ai-chat/trunk/README.md
r3231603 r3234305 22 22 |---------------------|---------------------------------------------------------|----------|----------------------------------| 23 23 | Chat Title | Change chat header title | - | Agent 700 | 24 | Chat Avatar | Change header image of chat | - | Placeholder image|24 | Chat Avatar | Change header image of chat | - | Default image | 25 25 | Chat Name | Change the name of chat (how appear in chat bubble) | - | Expert | 26 26 | Primary Color | Change color of send button and scrollbar | - | #000000 | 27 27 | Message Title Color | Change color of message title. (chat messages and user) | - | #000000 | 28 | Model | Model of AI | Yes | gpt-4o |29 28 | Agent ID | Provided by Agent 700 | Yes | Empty | 29 | Chat Icon | Change chat icon | - | Default image | 30 30 | Shortcode | Shortcode | No | [agent700_chat] | 31 | Layout type | Select layout type. Available only in popup layout | - | Aside | 32 | Hide overlay | Hide chat overlay | - | Uncheck | 31 33 | Hide chat icon | Hide bubble icon on site | - | Uncheck | 32 34 -
agent700-ai-chat/trunk/agent700-ai-chat.php
r3232187 r3234305 4 4 Plugin URI: https://agent700.ai/ 5 5 Description: Connect your WordPress site with Agent 700 AI for intelligent product assistance via live chat. 6 Version: 1. 36 Version: 1.4 7 7 Requires at least: 6.7 8 8 Requires PHP: 7.2 … … 19 19 function agent700_enqueue_scripts() 20 20 { 21 if (get_option('agent700_ model') && get_option('agent700_agent_id')) {21 if (get_option('agent700_agent_id')) { 22 22 wp_enqueue_style('agent700-styles', home_url('/wp-content/plugins/agent700-ai-chat/styles/styles.css'), array(), '1.3'); 23 23 wp_enqueue_script('agent700-chat', home_url('/wp-content/plugins/agent700-ai-chat/scripts/agent-chat.js'), array(), '1.3', true); … … 29 29 function agent700_localize_script() 30 30 { 31 if (get_option('agent700_ model') && get_option('agent700_agent_id')) {31 if (get_option('agent700_agent_id')) { 32 32 wp_localize_script('agent700-chat', 'agent700_config', array( 33 'model' => get_option('agent700_model', 'gpt-4o'),34 33 'agentId' => get_option('agent700_agent_id', ''), 35 34 )); … … 134 133 ?> 135 134 </form> 136 <?php if (!get_option('agent700_ model') || !get_option('agent700_agent_id')) : ?>135 <?php if (!get_option('agent700_agent_id')) : ?> 137 136 <div style="color: red; margin-top: 20px;"> 138 <strong>Notice:</strong> The field s "Model" and "Agent ID" are required. Without valid entries in these fields, the plugin will not function.137 <strong>Notice:</strong> The field "Agent ID" are required. Without valid entries in this field, the plugin will not function. 139 138 </div> 140 139 <?php endif; ?> … … 166 165 'sanitize_callback' => 'sanitize_hex_color', 167 166 )); 168 register_setting('agent700_chat_settings', 'agent700_model', array(169 'type' => 'string',170 'sanitize_callback' => 'sanitize_text_field',171 ));172 167 register_setting('agent700_chat_settings', 'agent700_agent_id', array( 173 168 'type' => 'string', … … 186 181 'sanitize_callback' => 'esc_url_raw', 187 182 )); 188 183 register_setting('agent700_chat_settings', 'agent700_layout_type', array( 184 'type' => 'string', 185 'sanitize_callback' => 'sanitize_text_field', 186 'default' => 'popup', 187 )); 188 register_setting('agent700_chat_settings', 'agent700_hide_overlay', array( 189 'type' => 'boolean', 190 'sanitize_callback' => 'rest_sanitize_boolean', 191 'default' => false, 192 )); 189 193 add_settings_section( 190 194 'agent700_chat_section', … … 199 203 add_settings_field('agent700_primary_color', 'Primary Color', 'agent700_primary_color_field_render', 'agent700_chat_settings', 'agent700_chat_section'); 200 204 add_settings_field('agent700_message_title_color', 'Message Title Color', 'agent700_message_title_color_field_render', 'agent700_chat_settings', 'agent700_chat_section'); 201 add_settings_field('agent700_model', 'Model', 'agent700_model_field_render', 'agent700_chat_settings', 'agent700_chat_section');202 205 add_settings_field('agent700_agent_id', 'Agent ID', 'agent700_agent_id_field_render', 'agent700_chat_settings', 'agent700_chat_section'); 203 206 add_settings_field('agent700_chat_icon', 'Chat Icon', 'agent700_chat_icon_field_render', 'agent700_chat_settings', 'agent700_chat_section'); 204 207 add_settings_field('agent700_chat_shortcode', 'Shortcode', 'agent700_chat_shortcode', 'agent700_chat_settings', 'agent700_chat_section'); 208 add_settings_field('agent700_layout_type', 'Layout Type', 'agent700_chat_layout_field_render', 'agent700_chat_settings', 'agent700_chat_section'); 209 add_settings_field('agent700_hide_overlay', 'Hide Overlay', 'agent700_chat_hide_overlay_render', 'agent700_chat_settings', 'agent700_chat_section'); 205 210 206 211 // Only one shortcode checkbox 207 add_settings_field('agent700_use_shortcode', 'Hide chat icon :', 'agent700_chat_shortcode_checkbox_render', 'agent700_chat_settings', 'agent700_chat_section');212 add_settings_field('agent700_use_shortcode', 'Hide chat icon', 'agent700_chat_shortcode_checkbox_render', 'agent700_chat_settings', 'agent700_chat_section'); 208 213 } 209 214 add_action('admin_init', 'agent700_register_settings'); … … 255 260 $color = get_option('agent700_message_title_color', '#000000'); 256 261 echo '<input type="color" id="message_title_color_picker" name="agent700_message_title_color" value="' . esc_attr($color) . '" />'; 257 }258 259 260 function agent700_model_field_render()261 {262 $model = get_option('agent700_model', 'gpt-4o');263 echo "<input type='text' name='agent700_model' value='" . esc_attr($model) . "' />";264 262 } 265 263 … … 281 279 } 282 280 281 function agent700_chat_layout_field_render() { 282 $layout_type = get_option('agent700_layout_type', 'popup'); 283 ?> 284 <label> 285 <input type="radio" name="agent700_layout_type" value="popup" <?php checked($layout_type, 'popup'); ?> /> 286 Popup 287 </label> 288 <br><br> 289 <label> 290 <input type="radio" name="agent700_layout_type" value="aside" <?php checked($layout_type, 'aside'); ?> /> 291 Aside 292 </label> 293 <?php 294 } 295 296 function agent700_chat_hide_overlay_render() { 297 $hide_overlay = get_option('agent700_hide_overlay', false); 298 ?> 299 <label> 300 <input type="checkbox" name="agent700_hide_overlay" value="1" <?php checked($hide_overlay, true); ?> /> 301 Enable this option to hide the overlay 302 </label> 303 <?php 304 } 305 306 //Add Settings link in plugins page 283 307 function agent700_chat_add_link_settings($links) { 284 308 $settings_link = '<a href="' . admin_url('options-general.php?page=agent700_chat_settings') . '">Settings</a>'; -
agent700-ai-chat/trunk/agent700-chat-template.php
r3229896 r3234305 1 <?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?> 1 <?php 2 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly 3 $layout_type = get_option('agent700_layout_type', 'popup'); 4 $hide_overlay = get_option('agent700_hide_overlay', false); 5 $overlay_class = $hide_overlay ? '' : 'show'; 6 ?> 2 7 3 <div id="agent700-chat-aside">4 <div class="agent700-overlay "></div>8 <div class="agent700-chat <?php echo esc_attr($layout_type); ?>"> 9 <div class="agent700-overlay <?php echo esc_attr($overlay_class); ?>"></div> 5 10 <div class="agent700-container"> 6 11 <div id="agent-header"> 7 <span class="agent700-close">X</span> 12 <span class="agent700-expand-contract"></span> 13 <span class="agent700-close"></span> 8 14 <span id="agent-header-avatar"> 9 15 <?php -
agent700-ai-chat/trunk/readme.txt
r3232187 r3234305 3 3 Tags: AI, Chatbot, Customer Support, Product Assistance, Live Chat 4 4 Tested up to: 6.7 5 Stable tag: 1. 35 Stable tag: 1.4 6 6 License: GPLv2 or later 7 7 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 29 29 - Customizable chat interface to match your brand. 30 30 - Ability to change the chat icon image 31 - Aside or Popup chat layout selection 32 - Added option to hide or show chat overlay 33 - Expanded popup layout (only with popup layout) 31 34 32 35 This plugin is perfect for e-commerce, product-based websites, or any business looking to provide fast, reliable support to their users. … … 72 75 == Changelog == 73 76 77 = 1.4 = 78 - Added popup layout 79 - Added option in admin that allows selecting layout type (aside or popup) 80 - Added option to hide or show chat overlay 81 - Added popup layout expand functionality (only with popup layout) 82 - Functionality fixes 83 74 84 = 1.3 = 75 85 - Added chat welcome message -
agent700-ai-chat/trunk/scripts/agent-chat.js
r3232187 r3234305 1 1 class ChatBot { 2 2 constructor() { 3 this.main = document. getElementById("agent700-chat-aside");3 this.main = document.querySelector(".agent700-chat"); 4 4 this.chatBox = this.main.querySelector(".agent-chat-content"); 5 this.agent700ChatContainer = this.main.querySelector(".agent700-container"); 5 6 this.chatInputMsg = this.main.querySelector("#chatInputMsg"); 6 7 this.agentSendBtn = this.main.querySelector("#agentSendBtn"); 7 8 this.agentChatFields = this.main.querySelector("#agentChatFields"); 8 this.agentStatusText = this.main.querySelector( 9 "#agent-header-status .agent-header-status-text" 10 ); 9 this.agentStatusText = this.main.querySelector("#agent-header-status .agent-header-status-text"); 11 10 this.chatCloseBtn = this.main.querySelector(".agent700-close"); 11 this.chatExpandBtn = this.main.querySelector(".agent700-expand-contract"); 12 12 this.chatOverlay = this.main.querySelector(".agent700-overlay"); 13 this.buttonShortcode = document.querySelectorAll( 14 ".chat-agent-shortcode-button" 15 ); 13 this.buttonShortcode = document.querySelectorAll(".chat-agent-shortcode-button"); 16 14 this.chatIcon = document.querySelector(".chat-agent-icon"); 17 15 18 16 // Get configurable variables from WordPress settings 19 this.model = agent700_config.model;20 17 this.agentId = agent700_config.agentId; 21 18 this.apiUrl = "https://app.agent700.ai/api/chat"; … … 23 20 24 21 // Initialize conversation history 25 this.conversationHistory = []; 22 this.conversationHistory = [ { 23 "role": "system", 24 "content": "" 25 }]; 26 26 27 27 // Ensure input and send button states are initialized … … 34 34 35 35 if (this.chatIcon || this.buttonShortcode.length >= 1) { 36 this.chatExpandBtn.addEventListener( 37 "click", 38 () => (this.expandContractChat()) 39 ); 40 36 41 this.chatCloseBtn.addEventListener( 37 42 "click", 38 43 () => (this.showChat = !this.isVisible) 39 44 ); 45 40 46 this.chatOverlay.addEventListener( 41 47 "click", … … 70 76 throw new Error(`HTTP error! Status: ${response.status}`); 71 77 } 72 return response.json(); // Si la API responde con JSON78 return response.json(); 73 79 }) 74 80 .then((data) => { … … 82 88 console.error("Error:", error); 83 89 }); 90 } 91 92 expandContractChat() { 93 this.agent700ChatContainer.classList.toggle("expanded"); 84 94 } 85 95 … … 107 117 this.agentStatusText.textContent = "Typing ..."; 108 118 const requestData = { 109 model: this.model,110 119 agentId: this.agentId, 111 120 messages: this.conversationHistory, -
agent700-ai-chat/trunk/styles/styles.css
r3229896 r3234305 14 14 } 15 15 16 #agent700-chat-aside* {16 .agent700-chat * { 17 17 box-sizing: border-box; 18 18 } 19 19 20 #agent700-chat-aside{20 .agent700-chat { 21 21 width: 100%; 22 22 height: 100%; 23 background-color: white;24 23 flex-direction: column; 25 24 position: fixed; … … 32 31 } 33 32 34 #agent700-chat-aside.show {33 .agent700-chat.show { 35 34 opacity: 1; 36 35 pointer-events: all; 37 36 } 38 37 39 #agent700-chat-aside.agent700-overlay {38 .agent700-chat .agent700-overlay { 40 39 width: 100vw; 41 40 height: 100vh; … … 43 42 background-color: #000000; 44 43 position: absolute; 45 z-index: 10 ;44 z-index: 100; 46 45 transition: ease all .3s; 47 46 } 48 47 49 #agent700-chat-aside.show .agent700-overlay{48 .agent700-chat.show .agent700-overlay.show { 50 49 opacity: 0.6; 51 50 } 52 51 53 #agent700-chat-aside .agent700-container { 54 position: relative; 55 z-index: 50; 56 width: 100%; 57 height: 100%; 52 .agent700-chat .agent700-container { 53 z-index: 3000; 58 54 display: flex; 59 55 flex-direction: column; 60 56 max-width: 600px; 61 57 transition: all ease .3s; 58 } 59 60 .agent700-chat.aside .agent700-container { 61 position: relative; 62 width: 100%; 63 height: 100%; 62 64 transform: translateX(-100%); 63 65 } 64 66 65 #agent700-chat-aside.show .agent700-container { 67 .agent700-chat.popup .agent700-container { 68 position: fixed; 69 bottom: 20px; 70 right: 20px; 71 width: 400px; 72 height: auto; 73 max-height: 400px; 74 max-width: 400px; 75 transform: translateX(0); 76 box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2); 77 background-color: #ffffff; 78 border-radius: 10px; 79 padding: 10px; 80 } 81 82 83 .agent700-chat.aside.show .agent700-container { 66 84 transform: translateX(0%); 85 } 86 87 @media (max-width: 480px) { 88 .agent700-chat .agent700-container { 89 max-width: 300px !important; 90 } 91 } 92 93 @media (min-width: 768px) { 94 .agent700-chat .agent700-container.expanded { 95 width: 100%; 96 max-width: 600px; 97 max-height: 450px; 98 height: 450px; 99 } 67 100 } 68 101 … … 80 113 } 81 114 115 .agent700-chat.popup .agent700-container .agent700-expand-contract { 116 background-image: url('../assets/agent700-expand-icon.svg'); 117 background-repeat: no-repeat; 118 background-position: center; 119 background-size: 100%; 120 display: none; 121 cursor: pointer; 122 width: 20px; 123 height: 17px; 124 position: absolute; 125 right: 50px; 126 top: 14px; 127 } 128 129 @media (min-width: 768px) { 130 .agent700-chat.popup .agent700-container .agent700-expand-contract { 131 display: block; 132 } 133 } 134 135 .agent700-chat.popup .agent700-container.expanded .agent700-expand-contract { 136 background-image: url('../assets/agent700-contract-icon.svg'); 137 background-repeat: no-repeat; 138 background-position: center; 139 background-size: 100%; 140 display: block; 141 cursor: pointer; 142 width: 26px; 143 height: 20px; 144 position: absolute; 145 right: 50px; 146 top: 14px; 147 } 148 82 149 .agent700-close { 83 font-size: 18px; 150 background-image: url('../assets/agent700-close-icon.svg'); 151 background-repeat: no-repeat; 152 background-position: center; 153 background-size: 100%; 154 display: block; 155 width: 20px; 156 height: 17px; 84 157 color: #000000; 85 158 position: absolute; 86 159 right: 15px; 87 top: 1 0px;160 top: 14px; 88 161 cursor: pointer; 89 162 }
Note: See TracChangeset
for help on using the changeset viewer.