Plugin Directory

Changeset 3234305


Ignore:
Timestamp:
02/03/2025 10:14:50 PM (14 months ago)
Author:
cmarcet
Message:

Release 1.4

Location:
agent700-ai-chat/trunk
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • agent700-ai-chat/trunk/README.md

    r3231603 r3234305  
    2222|---------------------|---------------------------------------------------------|----------|----------------------------------|
    2323| 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                    |
    2525| Chat Name           | Change the name of chat (how appear in chat bubble)     | -        | Expert                           |
    2626| Primary Color       | Change color of send button and scrollbar               | -        | #000000                        |
    2727| Message Title Color | Change color of message title. (chat messages and user) | -        | #000000                        |
    28 | Model               | Model of AI                                             | Yes      | gpt-4o                           |
    2928| Agent ID            | Provided by Agent 700                                   | Yes      | Empty                            |
     29| Chat Icon           | Change chat icon                                        | -        | Default image                    |
    3030| Shortcode           | Shortcode                                               | No       | [agent700_chat]                  |
     31| Layout type         | Select layout type. Available only in popup layout      | -        | Aside                            |
     32| Hide overlay        | Hide chat overlay                                       | -        | Uncheck                          |
    3133| Hide chat icon      | Hide bubble icon on site                                | -        | Uncheck                          |
    3234
  • agent700-ai-chat/trunk/agent700-ai-chat.php

    r3232187 r3234305  
    44Plugin URI: https://agent700.ai/
    55Description: Connect your WordPress site with Agent 700 AI for intelligent product assistance via live chat.
    6 Version: 1.3
     6Version: 1.4
    77Requires at least: 6.7
    88Requires PHP: 7.2
     
    1919function agent700_enqueue_scripts()
    2020{
    21     if (get_option('agent700_model') && get_option('agent700_agent_id')) {
     21    if (get_option('agent700_agent_id')) {
    2222        wp_enqueue_style('agent700-styles', home_url('/wp-content/plugins/agent700-ai-chat/styles/styles.css'), array(), '1.3');
    2323        wp_enqueue_script('agent700-chat', home_url('/wp-content/plugins/agent700-ai-chat/scripts/agent-chat.js'), array(), '1.3', true);
     
    2929function agent700_localize_script()
    3030{
    31     if (get_option('agent700_model') && get_option('agent700_agent_id')) {
     31    if (get_option('agent700_agent_id')) {
    3232        wp_localize_script('agent700-chat', 'agent700_config', array(
    33             'model' => get_option('agent700_model', 'gpt-4o'),
    3433            'agentId' => get_option('agent700_agent_id', ''),
    3534        ));
     
    134133            ?>
    135134        </form>
    136         <?php if (!get_option('agent700_model') || !get_option('agent700_agent_id')) : ?>
     135        <?php if (!get_option('agent700_agent_id')) : ?>
    137136            <div style="color: red; margin-top: 20px;">
    138                 <strong>Notice:</strong> The fields "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.
    139138            </div>
    140139        <?php endif; ?>
     
    166165        'sanitize_callback' => 'sanitize_hex_color',
    167166    ));
    168     register_setting('agent700_chat_settings', 'agent700_model', array(
    169         'type'              => 'string',
    170         'sanitize_callback' => 'sanitize_text_field',
    171     ));
    172167    register_setting('agent700_chat_settings', 'agent700_agent_id', array(
    173168        'type'              => 'string',
     
    186181        'sanitize_callback' => 'esc_url_raw',
    187182    ));
    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    ));
    189193    add_settings_section(
    190194        'agent700_chat_section',
     
    199203    add_settings_field('agent700_primary_color', 'Primary Color', 'agent700_primary_color_field_render', 'agent700_chat_settings', 'agent700_chat_section');
    200204    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');
    202205    add_settings_field('agent700_agent_id', 'Agent ID', 'agent700_agent_id_field_render', 'agent700_chat_settings', 'agent700_chat_section');
    203206    add_settings_field('agent700_chat_icon', 'Chat Icon', 'agent700_chat_icon_field_render', 'agent700_chat_settings', 'agent700_chat_section');
    204207    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');
    205210
    206211    // 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');
    208213}
    209214add_action('admin_init', 'agent700_register_settings');
     
    255260    $color = get_option('agent700_message_title_color', '#000000');
    256261    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) . "' />";
    264262}
    265263
     
    281279}
    282280
     281function 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
     296function 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
    283307function agent700_chat_add_link_settings($links) {
    284308    $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
     2if ( ! 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?>
    27
    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>
    510  <div class="agent700-container">
    611    <div id="agent-header">
    7       <span class="agent700-close">X</span>
     12      <span class="agent700-expand-contract"></span>
     13      <span class="agent700-close"></span>
    814      <span id="agent-header-avatar">
    915        <?php
  • agent700-ai-chat/trunk/readme.txt

    r3232187 r3234305  
    33Tags: AI, Chatbot, Customer Support, Product Assistance, Live Chat
    44Tested up to: 6.7
    5 Stable tag: 1.3
     5Stable tag: 1.4
    66License: GPLv2 or later
    77License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    2929- Customizable chat interface to match your brand.
    3030- 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)
    3134
    3235This plugin is perfect for e-commerce, product-based websites, or any business looking to provide fast, reliable support to their users.
     
    7275== Changelog ==
    7376
     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
    7484= 1.3 =
    7585- Added chat welcome message
  • agent700-ai-chat/trunk/scripts/agent-chat.js

    r3232187 r3234305  
    11class ChatBot {
    22  constructor() {
    3     this.main = document.getElementById("agent700-chat-aside");
     3    this.main = document.querySelector(".agent700-chat");
    44    this.chatBox = this.main.querySelector(".agent-chat-content");
     5    this.agent700ChatContainer = this.main.querySelector(".agent700-container");
    56    this.chatInputMsg = this.main.querySelector("#chatInputMsg");
    67    this.agentSendBtn = this.main.querySelector("#agentSendBtn");
    78    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");
    1110    this.chatCloseBtn = this.main.querySelector(".agent700-close");
     11    this.chatExpandBtn = this.main.querySelector(".agent700-expand-contract");
    1212    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");
    1614    this.chatIcon = document.querySelector(".chat-agent-icon");
    1715
    1816    // Get configurable variables from WordPress settings
    19     this.model = agent700_config.model;
    2017    this.agentId = agent700_config.agentId;
    2118    this.apiUrl = "https://app.agent700.ai/api/chat";
     
    2320
    2421    // Initialize conversation history
    25     this.conversationHistory = [];
     22    this.conversationHistory = [ {
     23      "role": "system",
     24      "content": ""
     25    }];
    2626
    2727    // Ensure input and send button states are initialized
     
    3434
    3535    if (this.chatIcon || this.buttonShortcode.length >= 1) {
     36      this.chatExpandBtn.addEventListener(
     37        "click",
     38        () => (this.expandContractChat())
     39      );
     40
    3641      this.chatCloseBtn.addEventListener(
    3742        "click",
    3843        () => (this.showChat = !this.isVisible)
    3944      );
     45
    4046      this.chatOverlay.addEventListener(
    4147        "click",
     
    7076          throw new Error(`HTTP error! Status: ${response.status}`);
    7177        }
    72         return response.json(); // Si la API responde con JSON
     78        return response.json();
    7379      })
    7480      .then((data) => {
     
    8288        console.error("Error:", error);
    8389      });
     90  }
     91
     92  expandContractChat() {
     93    this.agent700ChatContainer.classList.toggle("expanded");
    8494  }
    8595
     
    107117    this.agentStatusText.textContent = "Typing ...";
    108118    const requestData = {
    109       model: this.model,
    110119      agentId: this.agentId,
    111120      messages: this.conversationHistory,
  • agent700-ai-chat/trunk/styles/styles.css

    r3229896 r3234305  
    1414}
    1515
    16 #agent700-chat-aside * {
     16.agent700-chat * {
    1717  box-sizing: border-box;
    1818}
    1919
    20 #agent700-chat-aside {
     20.agent700-chat {
    2121  width: 100%;
    2222  height: 100%;
    23   background-color: white;
    2423  flex-direction: column;
    2524  position: fixed;
     
    3231}
    3332
    34 #agent700-chat-aside.show {
     33.agent700-chat.show {
    3534  opacity: 1;
    3635  pointer-events: all;
    3736}
    3837
    39 #agent700-chat-aside .agent700-overlay {
     38.agent700-chat .agent700-overlay {
    4039  width: 100vw;
    4140  height: 100vh;
     
    4342  background-color: #000000;
    4443  position: absolute;
    45   z-index: 10;
     44  z-index: 100;
    4645  transition: ease all .3s;
    4746}
    4847
    49 #agent700-chat-aside.show .agent700-overlay {
     48.agent700-chat.show .agent700-overlay.show {
    5049  opacity: 0.6;
    5150}
    5251
    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;
    5854  display: flex;
    5955  flex-direction: column;
    6056  max-width: 600px;
    6157  transition: all ease .3s;
     58}
     59
     60.agent700-chat.aside .agent700-container {
     61  position: relative;
     62  width: 100%;
     63  height: 100%;
    6264  transform: translateX(-100%);
    6365}
    6466
    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 {
    6684  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  }
    67100}
    68101
     
    80113}
    81114
     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
    82149.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;
    84157  color: #000000;
    85158  position: absolute;
    86159  right: 15px;
    87   top: 10px;
     160  top: 14px;
    88161  cursor: pointer;
    89162}
Note: See TracChangeset for help on using the changeset viewer.