Snippets Collections
add_filter( 'media_library_infinite_scrolling', '__return_true' );
add_filter( 'admin_footer_text', function ( $text ) {
    return sprintf(
        'Thank you for visiting %s',
        esc_url( home_url() ),
        esc_html( get_bloginfo( 'name' ) )
    );
} );
function rd_duplicate_post_as_draft(){
  global $wpdb;
  if (! ( isset( $_GET['post']) || isset( $_POST['post'])  || ( isset($_REQUEST['action']) && 'rd_duplicate_post_as_draft' == $_REQUEST['action'] ) ) ) {
    wp_die('No post to duplicate has been supplied!');
  }

  /*
   * Nonce verification
   */
  $nonce_url = wp_nonce_url('admin.php?action=rd_duplicate_post_as_draft&post=' . absint($_GET['post']), basename(__FILE__), 'duplicate_nonce');
  if ( empty( $_GET['duplicate_nonce'] ) || ! wp_verify_nonce( $_GET['duplicate_nonce'], 'duplicate_nonce' ) ) {
    wp_die('Security check failed.');
  }

  /*
   * get the original post id
   */
  $post_id = absint( $_GET['post'] );
  /*
   * and all the original post data then
   */
  $post = get_post( $post_id );

  /*
   * if you don't want the current user to be the new post author,
   * then change the next couple of lines to this: $new_post_author = $post->post_author;
   */
  $current_user = wp_get_current_user();
  $new_post_author = $current_user->ID;

  /*
   * if post data exists, create the post duplicate
   */
  if (isset( $post ) && $post != null) {

    /*
     * new post data array
     */
    $args = array(
      'comment_status' => $post->comment_status,
      'ping_status'    => $post->ping_status,
      'post_author'    => $new_post_author,
      'post_content'   => $post->post_content,
      'post_excerpt'   => $post->post_excerpt,
      'post_name'      => $post->post_name,
      'post_parent'    => $post->post_parent,
      'post_password'  => $post->post_password,
      'post_status'    => 'draft',
      'post_title'     => $post->post_title,
      'post_type'      => $post->post_type,
      'to_ping'        => $post->to_ping,
      'menu_order'     => $post->menu_order
    );

    /*
     * insert the post by wp_insert_post() function
     */
    $new_post_id = wp_insert_post( $args );

    /*
     * get all current post terms and set them to the new post draft
     */
    $taxonomies = get_object_taxonomies($post->post_type); // returns array of taxonomy names for post type, ex array("category", "post_tag");
    foreach ($taxonomies as $taxonomy) {
      $post_terms = wp_get_object_terms($post_id, $taxonomy, array('fields' => 'slugs'));
      wp_set_object_terms($new_post_id, $post_terms, $taxonomy, false);
    }

    /*
     * duplicate all post meta just in two SQL queries
     */
    $post_meta_infos = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id");
    if (count($post_meta_infos)!=0) {
      $sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
      foreach ($post_meta_infos as $meta_info) {
        $meta_key = $meta_info->meta_key;
        if( $meta_key == '_wp_old_slug' ) continue;
        $meta_value = addslashes($meta_info->meta_value);
        $sql_query_sel[]= "SELECT $new_post_id, '$meta_key', '$meta_value'";
      }
      $sql_query .= implode(" UNION ALL ", $sql_query_sel);
      $wpdb->query($sql_query);
    }

    /*
     * finally, redirect to the edit post screen for the new draft
     */
    wp_redirect( admin_url( 'post.php?action=edit&post=' . $new_post_id ) );
    exit;
  } else {
    wp_die('Post creation failed, could not find the original post: ' . $post_id);
  }
}
add_action( 'admin_action_rd_duplicate_post_as_draft', 'rd_duplicate_post_as_draft' );

/*
 * Add the duplicate link to action list for post_row_actions
 */
function rd_duplicate_post_link( $actions, $post ) {
  if (current_user_can('edit_posts') && in_array($post->post_type, array('post', 'page'))) {
    $nonce_url = wp_nonce_url('admin.php?action=rd_duplicate_post_as_draft&post=' . $post->ID, basename(__FILE__), 'duplicate_nonce');
    $actions['duplicate'] = 'Duplicate';
  }
  return $actions;
}

add_filter( 'post_row_actions', 'rd_duplicate_post_link', 10, 2 );
add_filter( 'page_row_actions', 'rd_duplicate_post_link', 10, 2 );
/**
 * Convert Uploaded Images to WebP Format
 *
 * This snippet converts uploaded images (JPEG, PNG, GIF) to WebP format
 * automatically in WordPress. Ideal for use in a theme's functions.php file,
 * or with plugins like Code Snippets or WPCodeBox.
 * 
 * @package    WordPress_Custom_Functions
 * @autor      Mark Harris
 * @link       www.christchurchwebsolutions.co.uk
 *
 * Usage Instructions:
 * - Add this snippet to your theme's functions.php file, or add it as a new
 *   snippet in Code Snippets or WPCodeBox.
 * - The snippet hooks into WordPress's image upload process and converts
 *   uploaded images to the WebP format.
 *
 * Optional Configuration:
 * - By default, the original image file is deleted after conversion to WebP.
 *   If you prefer to keep the original image file, simply comment out or remove
 *   the line '@unlink( $file_path );' in the wpturbo_handle_upload_convert_to_webp function.
 *   This will preserve the original uploaded image file alongside the WebP version.
 */

add_filter('wp_handle_upload', 'wpturbo_handle_upload_convert_to_webp');

function wpturbo_handle_upload_convert_to_webp($upload) {
    if ($upload['type'] == 'image/jpeg' || $upload['type'] == 'image/png' || $upload['type'] == 'image/gif') {
        $file_path = $upload['file'];

        // Check if ImageMagick or GD is available
        if (extension_loaded('imagick') || extension_loaded('gd')) {
            $image_editor = wp_get_image_editor($file_path);
            if (!is_wp_error($image_editor)) {
                $file_info = pathinfo($file_path);
                $dirname   = $file_info['dirname'];
                $filename  = $file_info['filename'];

                // Create a unique file path for the WebP image
                $def_filename = wp_unique_filename($dirname, $filename . '.webp');
                $new_file_path = $dirname . '/' . $def_filename;

                // Attempt to save the image in WebP format
                $saved_image = $image_editor->save($new_file_path, 'image/webp');
                if (!is_wp_error($saved_image) && file_exists($saved_image['path'])) {
                    // Success: replace the uploaded image with the WebP image
                    $upload['file'] = $saved_image['path'];
                    $upload['url']  = str_replace(basename($upload['url']), basename($saved_image['path']), $upload['url']);
                    $upload['type'] = 'image/webp';

                    // Optionally remove the original image
                    @unlink($file_path);
                }
            }
        }
    }

    return $upload;
}
git clone git@github.com:thespacedoctor/sherlock.git
cd sherlock
python setup.py install
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{

    public Transform target;
    public Vector3 offset;

    // Update is called once per frame
    void Update()
    {
        transform.position = target.position + offset;
    }
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    public float moveSpeed;
    public float jumpForce;
    public Rigidbody rig;

    private bool isGrounded;


    // Update is called once per frame
    void Update()
    {
        float x = Input.GetAxisRaw("Horizontal") * moveSpeed;
        float z = Input.GetAxisRaw("Vertical") * moveSpeed;

        rig.velocity = new Vector3(x, rig.velocity.y, z);

        Vector3 vel = rig.velocity;
        vel.y = 0;
        if (vel.x != 0 || vel.z != 0)
        {
            transform.forward = rig.velocity;
        }

        if(Input.GetKeyDown(KeyCode.Space) && isGrounded == true)
        {
            isGrounded = false;
            rig.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
        }
    }

    void OnCollisionEnter(Collision collision)
    {
        if(collision.GetContact(0).normal == Vector3.up)
        {
            isGrounded = true;
        }
    }
}
.elementor-button-icon {line-height:0;}

.elementor-button-content-wrapper {align-items: center}
selector {
  aspect-ratio: 1200 / 600; 
  background-color: tomato; 
  mask-image: url("/* SVG URL */");
  -webkit-mask-image: url("/* SVG URL also here */");
  mask-repeat: no-repeat;
  -webkit-mask-repeat: no-repeat;
  mask-size: 100% auto;
  -webkit-mask-size: 100% auto;
  /* mask-size: contain; */
  /* -webkit-mask-size: contain; */
}
{
	"blocks": [
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": ":powerup-shroom: Boost Day Thursday, October 10th :powerup-shroom:",
				"emoji": true
			}
		},
		{
			"type": "rich_text",
			"elements": [
				{
					"type": "rich_text_section",
					"elements": [
						{
							"type": "text",
							"text": "Hi everyone,\n\nPower up with these Boost Day perks!\n\n"
						},
						{
							"type": "emoji",
							"name": "coffee",
							"unicode": "2615"
						},
						{
							"type": "text",
							"text": " Xero Cafe: ",
							"style": {
								"bold": true
							}
						},
						{
							"type": "text",
							"text": "Enjoy coffee and café-style beverages from our partner, Blue Sparrow, by showing your Xero ID\n"
						},
						{
							"type": "text",
							"text": "Be sure to hit the tip button before you walk away.",
							"style": {
								"code": true
							}
						},
						{
							"type": "text",
							"text": "\n\n\n"
						},
						{
							"type": "emoji",
							"name": "burrito",
							"unicode": "1f32f",
							"style": {
								"bold": true
							}
						},
						{
							"type": "text",
							"text": "  Lunch",
							"style": {
								"bold": true
							}
						},
						{
							"type": "text",
							"text": ": "
						},
						{
							"type": "emoji",
							"name": "pokeball-shake",
							"style": {
								"bold": true,
								"italic": true
							}
						},
						{
							"type": "text",
							"text": " Poke House!",
							"style": {
								"bold": true,
								"italic": true
							}
						},
						{
							"type": "text",
							"text": "\n"
						},
						{
							"type": "emoji",
							"name": "beers",
							"unicode": "1f37b",
							"style": {
								"bold": true,
								"italic": true
							}
						},
						{
							"type": "text",
							"text": "  Happy Hour: Hispanic themed Kahoot, drinks, and light snacks ",
							"style": {
								"bold": true,
								"italic": true
							}
						},
						{
							"type": "text",
							"text": "Sponsored by Los Xeros ERG for Hispanic Heritage Month from 4-5pm\n\n"
						},
						{
							"type": "text",
							"text": "Come say farewell",
							"style": {
								"bold": true,
								"italic": true
							}
						},
						{
							"type": "emoji",
							"name": "bye-1",
							"style": {
								"bold": true,
								"italic": true
							}
						},
						{
							"type": "text",
							"text": " to ",
							"style": {
								"bold": true,
								"italic": true
							}
						},
						{
							"type": "user",
							"user_id": "U02PGT7HTD0",
							"style": {
								"bold": true,
								"italic": true
							}
						},
						{
							"type": "text",
							"text": " ",
							"style": {
								"bold": true,
								"italic": true
							}
						}
					]
				}
			]
		}
	]
}
ejemplo en carga_operaciones del sistema de sig indicadores, este es el formulario


<div class="col-xs-4" style="display: block;" id='id_estado'>
                                                    <?= $form->field($model, 'id_estado')->dropDownList(ArrayHelper::map(Estados::find()/*->where(['id_municipio'=> 2])*/->orderBy('desc_estado')->all(), 'id_estado', 'desc_estado'), ['prompt' => 'Seleccione ', 'id' => 'id-estado']); ?>
                                                </div>

                                                <div class="col-xs-4" style="display: block;" id='id_municipio'>

                                                    <?= $form->field($model, 'id_municipio')->widget(DepDrop::classname(), [
                                                        'options' => ['id' => 'id-ubicacion'],
                                                        'data' => $model->isNewRecord ? [] : ArrayHelper::map(Municipios::find()->where([ 'id_estado'=>$model->id_estado])->orderBy('desc_municipio')->asArray()->all(), 'id_municipio', 'desc_municipio'),
                                                        // ensure at least the preselected value is available
                                                        'pluginOptions' => [
                                                            'depends' => ['id-estado'],
                                                            // the id for cat attribute
                                                            'placeholder' => 'Seleccione un municipio...',
                                                            'url' => Url::to(['municipios/listar'])
                                                        ]
                                                    ]);
                                                    ?>
                                                </div>

                                                <div class="col-xs-4" style=" display: block;" id='id_parroquia'>
                                                    <?= $form->field($model, 'id_parroquia')->widget(DepDrop::classname(), [
                                                        //'options'=>['id'=>'co_art_'.$regla->cod_linea.''],

                                                        'data' => $model->isNewRecord ? [] : ArrayHelper::map(Parroquias::find()->where(['id_municipio'=>$model->id_municipio])->orderBy('desc_parroquia')->asArray()->all(), 'id_parroquia', 'desc_parroquia'),
                                                        // ensure at least the preselected value is available
                                                        'pluginOptions' => [
                                                            'depends' => ['id-ubicacion'],
                                                            // the id for cat attribute
                                                            'placeholder' => 'Seleccione una parroquia...',
                                                            'url' => Url::to(['parroquias/listar'])
                                                        ]
                                                    ]);
                                                    ?>
                                                </div>

este es el modelo de carga operaciones es decir el mismo:

public function getMunicipio()
  {
    if ($this->id_municipio):
      $p = Municipios::findOne(['id_municipio' => $this->id_municipio]);
      if ($p):
        $p = $p->desc_municipio;
      endif;
    else:
      $p = "";
    endif;

    return $p;
  }

  public function getParroquia()
  {
    if ($this->id_parroquia):
      $p = Parroquias::findOne(['id_parroquia' => $this->id_parroquia]);
      if ($p):
        $p = $p->desc_parroquia;
      endif;
    else:
      $p = "";
    endif;

    return $p;
  }

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Player Details</title>
    <style>
        body {
            font-family: Arial, sans-serif;
        }
        .header {
            background-color: #00e6e6;
            color: white;
            padding: 10px;
            text-align: center;
            font-size: 24px;
            font-weight: bold;
        }
        .player-list {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
        }
        .player-card {
            border: 1px solid #ccc;
            width: 30%;
            margin: 15px;
            text-align: center;
            padding: 10px;
            box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
        }
        .player-card img {
            width: 150px;
            height: auto;
        }
        .player-card h3 {
            color: teal;
        }
        .player-card p {
            font-size: 16px;
            margin: 5px 0;
        }
        .update-btn {
            background-color: lightblue;
            border: none;
            padding: 10px;
            cursor: pointer;
        }
        .popup {
            display: none;
            position: fixed;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            background-color: white;
            padding: 20px;
            box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.5);
        }
        .popup input, .popup button {
            margin: 10px 0;
            padding: 10px;
        }
    </style>
</head>
<body>

<div class="header">Player Details</div>

<div class="player-list" id="player-list">
    <!-- Player cards will be dynamically generated here -->
</div>

<!-- Popup for updating rank -->
<div class="popup" id="update-popup">
    <h3>Update The Rank</h3>
    <p id="player-name">Player Name</p>
    <label for="rank">Rank:</label>
    <input type="number" id="rank" min="1">
    <br>
    <button id="saveButton">SaveUpdate</button>
    <button onclick="closePopup()">Cancel</button>
</div>

<script>
    const players = [
        {name: "MS Dhoni", role: "Batsman", matches: 206, rank: 13, img: "https://app.e-box.co.in/uploads/Image/6107/dhoni.png"},
        {name: "Ravendra Jadeja", role: "Batsman", matches: 185, rank: 17, img: "https://app.e-box.co.in/uploads/Image/6107/jadeja.png"},
        {name: "Rohit Sharma", role: "Bowler", matches: 165, rank: 21, img: "https://app.e-box.co.in/uploads/Image/6107/sharma.png"},
        {name: "Suresh Raina", role: "Bowler", matches: 135, rank: 35, img: "https://app.e-box.co.in/uploads/Image/6107/raina.png"},
        {name: "Virat Kohli", role: "Batsman", matches: 190, rank: 12, img: "https://app.e-box.co.in/uploads/Image/6107/kohli.png"},
        {name: "Yuvraj Singh", role: "Bowler", matches: 142, rank: 26, img: "https://app.e-box.co.in/uploads/Image/6107/yuvaraj.png"}
    ];

    let currentPlayer = null;

    function displayPlayers() {
        const playerList = document.getElementById('player-list');
        playerList.innerHTML = '';
        players.forEach((player, index) => {
            const playerCard = `
                <div class="player-card" id="player${index + 1}">
                    <img src="${player.img}" alt="${player.name}">
                    <h3>${player.name}</h3>
                    <p>Role: ${player.role}</p>
                    <p>Total Matches: ${player.matches}</p>
                    <p>Rank: <span id="player-rank${index + 1}">${player.rank}</span></p>
                    <button class="update-btn" id="player-button${index + 1}" onclick="openPopup(${index})">Update Player</button>
                </div>
            `;
            playerList.innerHTML += playerCard;
        });
    }

    function openPopup(index) {
        currentPlayer = index;
        document.getElementById('player-name').textContent = players[index].name;
        document.getElementById('rank').value = players[index].rank;
        document.getElementById('update-popup').style.display = 'block';
    }

    function closePopup() {
        document.getElementById('update-popup').style.display = 'none';
    }

    document.getElementById('saveButton').addEventListener('click', function() {
        const newRank = document.getElementById('rank').value;
        if (currentPlayer !== null && newRank) {
            players[currentPlayer].rank = newRank;
            document.getElementById(`player-rank${currentPlayer + 1}`).textContent = newRank;
            closePopup();
        }
    });

    // Display the player cards on page load
    displayPlayers();
</script>

</body>
</html>
   
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Playlist Generator</title>
    <style>
        textarea {
            width: 100%;
            height: 150px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }
        table, th, td {
            border: 1px solid black;
        }
        th, td {
            padding: 8px;
            text-align: left;
        }
        th {
            background-color: #f2f2f2;
        }
    </style>
</head>
<body>

<h2>XML Parsing to Display Playlist</h2>

<textarea id="input">
<songs>
    <song rating="4.5">
        <name>Hum thu hi</name>
        <artist>Arijit</artist>
        <movie>Aashiqui 2</movie>
    </song>
    <song rating="4.0">
        <name>Thu hi mera</name>
        <artist>Sunidhi Chauhan</artist>
        <movie>Special 26</movie>
    </song>
</songs>
</textarea>
<br>
<button id="genform">Generate Playlist</button>

<div id="playlist"></div>

<script>
    document.getElementById('genform').addEventListener('click', function() {
        // Get the XML from the textarea
        const xmlText = document.getElementById('input').value;
        
        // Parse the XML string
        const parser = new DOMParser();
        const xmlDoc = parser.parseFromString(xmlText, 'text/xml');
        
        // Get all the song elements
        const songs = xmlDoc.getElementsByTagName('song');
        
        // Start building the HTML for the table
        let table = '<table><tr><th>Title</th><th>Artist</th><th>Movie</th><th>Rating</th></tr>';
        
        // Loop through the songs and extract the information
        for (let i = 0; i < songs.length; i++) {
            const name = songs[i].getElementsByTagName('name')[0].textContent;
            const artist = songs[i].getElementsByTagName('artist')[0].textContent;
            const movie = songs[i].getElementsByTagName('movie')[0].textContent;
            const rating = songs[i].getAttribute('rating');
            
            table += `<tr><td>${name}</td><td>${artist}</td><td>${movie}</td><td>${rating}</td></tr>`;
        }
        
        // Close the table HTML
        table += '</table>';
        
        // Insert the table into the playlist div
        document.getElementById('playlist').innerHTML = table;
    });
</script>

</body>
</html>
   
            <Conditional condition={data.admin}>
              <Link href="/secure/admin//data/menteith-updater" passHref>
                <NavigationMenuLink>
                  <UserCog size={16} className="me-2" />
                  Menteith Updater
                </NavigationMenuLink>
              </Link>
            </Conditional>
import React, { useState } from "react";
import { useDropzone } from "react-dropzone";
import * as XLSX from "xlsx";
import {
  BackHomeButton,
  CommandPalletteButton,
  MinimalPage,
  PageHeading,
} from "ui";
import { BugReportButton, CommandInterface, Navigation } from "@/components";

interface VesselManagerRecord {
  IMONumber: string;
  EffectiveControl: string;
}

const UpdateVesselManager: React.FC = () => {
  const [file, setFile] = useState<File | null>(null);
  const [tableData, setTableData] = useState<VesselManagerRecord[]>([]);

  const onDrop = (acceptedFiles: File[]) => {
    const uploadedFile = acceptedFiles[0];
    setFile(uploadedFile);

    const reader = new FileReader();
    reader.onload = (e) => {
      const data = e.target?.result;
      const workbook = XLSX.read(data, { type: "binary" });
      const worksheet = workbook.Sheets["Recent Changes (EffControl)"];
      const jsonData = XLSX.utils.sheet_to_json<VesselManagerRecord>(worksheet);
      setTableData(jsonData);
    };
    reader.readAsBinaryString(uploadedFile);
  };

  const { getRootProps, getInputProps } = useDropzone({ onDrop });

  return (
    <MinimalPage
      pageTitle={"Update Vessel Manager | Vessel Interface"}
      pageDescription={"Vessel Interface | Update Vessel Manager"}
    >
      <div className="flex w-full flex-row justify-between pl-1 pt-1">
        <div>
          <BackHomeButton />
        </div>
        <Navigation />
        <div className="flex flex-row gap-4">
          <BugReportButton />
          <CommandPalletteButton />
          <CommandInterface />
        </div>
      </div>

      <PageHeading text="Update Vessel Manager" />

      <div className="mt-6 flex w-full flex-col gap-2 p-2 sm:w-1/2">
        <div className="mt-4">
          <div
            {...getRootProps({
              className:
                "dropzone border-2 border-dashed p-4 rounded-md text-center cursor-pointer text-white",
            })}
          >
            <input {...getInputProps()} />
            <p>
              Drag & drop a vessel manager update file here, or click to select
              one
            </p>
          </div>
        </div>

        {file && (
          <div className="mt-4">
            <p className="text-white">File: {file.name}</p>
          </div>
        )}

        {tableData.length > 0 && (
          <div className="mt-6 overflow-x-auto">
            <table className="min-w-full border-collapse border border-gray-400">
              <thead>
                <tr>
                  <th className="border border-gray-300 px-4 py-2 text-white">
                    IMO Number
                  </th>
                  <th className="border border-gray-300 px-4 py-2 text-white">
                    Effective Control
                  </th>
                </tr>
              </thead>
              <tbody>
                {tableData.map((record, index) => (
                  <tr key={index}>
                    <td className="border border-gray-300 px-4 py-2 text-white">
                      {record.IMONumber}
                    </td>
                    <td className="border border-gray-300 px-4 py-2 text-white">
                      {record.EffectiveControl}
                    </td>
                  </tr>
                ))}
              </tbody>
            </table>
          </div>
        )}
      </div>
    </MinimalPage>
  );
};

export default UpdateVesselManager;
// Update manager - Raf
export async function updateVesselManagerInDB(imo: string, managerId: number) {
  return new Promise<void>((resolve, reject) => {
    rdsConnection.query(
      `UPDATE spotship_vessel SET manager_id = ? WHERE imo = ?`,
      [managerId, imo],
      (error: unknown) => {
        if (error) {
          return reject(error);
        }
        return resolve();
      }
    );
  });
}
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.naive_bayes import MultinomialNB
from sklearn.metrics import classification_report, confusion_matrix

data = pd.read_csv('email.csv')
data['Message'] = data['Message'].str.lower()
data['Category'] = data['Category'].map({'spam': 1, 'ham': 0})
data = data.dropna(subset=['Category'])

X_train, X_test, y_train, y_test = train_test_split(data['Message'], data['Category'], test_size=0.2, random_state=42)

vectorizer = TfidfVectorizer(stop_words='english')
X_train_tfidf = vectorizer.fit_transform(X_train)
X_test_tfidf = vectorizer.transform(X_test)

model = MultinomialNB()
model.fit(X_train_tfidf, y_train)
y_pred = model.predict(X_test_tfidf)

print(confusion_matrix(y_test, y_pred))
print(classification_report(y_test, y_pred))
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn import metrics
from sklearn.linear_model import LinearRegression

df = pd.read_csv("Housing.csv")
newdf = df[["price", "bedrooms"]]
X = newdf.drop(['price'], axis=1)
Y = newdf['price']

X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.2, random_state=2)

model = LinearRegression()
model.fit(X_train, Y_train)
Y_predict = model.predict(X_test)

score_1 = metrics.r2_score(Y_test, Y_predict)
score_2 = metrics.mean_absolute_error(Y_test, Y_predict)
score_3 = metrics.mean_squared_error(Y_test, Y_predict)

print('Mean Squared Error:', score_3)
print('R Squared Error:', score_1)
print('Mean Absolute Error:', score_2)
{
	"blocks": [
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": ":magic_wand::xero-unicorn: Xeros Connect: End of Year Celebration – A Sprinkle of Magic! :xero-unicorn::magic_wand:",
				"emoji": true
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*Hi Singapore!* \nGet ready to wrap up the year with a sprinkle of magic and a lot of fun at our End of Year Event! Here’s everything you need to know:"
			}
		},
		{
			"type": "divider"
		},
		{
			"type": "section",
			"fields": [
				{
					"type": "mrkdwn",
					"text": "*📅 When:* Wednesday 11th December"
				},
				{
					"type": "mrkdwn",
					"text": "*📍 Where:*\n<https://www.google.com/maps?sca_esv=81b62b241f3359c7&rlz=1C5GCCM_en&output=search&q=oche&source=lnms&fbs=AEQNm0AeMNWKf4PpcKMI-eSa16lJoRPMIuyspCxWO6iZW9F1Nu5UXlEfGU2YX1CrW9Nmm9Q3JIJZUqyMsLxos5tPU_UnM4mnBED_NsBtYJwhu9OaLjQpzn0pySwUSKm9zjjZ6FJf82N0QSPjwpHS_aSKjAkyDvchej2j7Ds2GJq122SoPsxeojGz9Q9KyJmfY-CpwM5u4MZVBK_r1kLudCbP3X7_BXmLQg&entry=mc&ved=1t:200715&ictx=111|*Oche Clarke Quay*> \n#01-05/06 Riverside Point, 30 Merchant Road, Singapore 058282"
				},
				{
					"type": "mrkdwn",
					"text": "*⏰ Time:*\n4PM - 7PM"
				}
			]
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*:magic_wand::xero-unicorn: Theme:*\n_A Sprinkle of Magic_ – Our theme is inspired by the Xero Unicorn, embracing creativity, inclusivity, and diversity. Expect unique decor, magical moments, and a fun-filled atmosphere!"
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*:dress: Dress Code:*\n*Smart casual* – Show your personality, but no Xero tees or lanyards, please!\nIf you're feeling inspired by the theme, why not add a little 'Sprinkle of Magic' to your outfit? Think glitter, sparkles, or anything that shows off your creative side! (Totally optional, of course! :sparkle-sparkle:)"
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*🚍 Transport Info:* Please make your own way to the event venue. The nearest MRT station is Clarke Quay and takes 3-5 mins on foot."
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*🎤 :hamburger: Entertainment & Food:*\nPrepare for a game of darts at Oche alongside delicious bites and refreshing drinks! ✨🎶"
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*:admission_tickets: RSVP Now:* Click<https://xero-wx.jomablue.com/reg/store/eoy_sgp|* here*> to RSVP! Make sure you RSVP by *_Friday, 22nd November 2024_*!"
			}
		},
		{
			"type": "divider"
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": ":question:Got questions? See the <https://docs.google.com/document/d/1iygJFHgLBRSdAffNsg3PudZCA45w6Wit7xsFxNc_wKM/edit|FAQs> doc or post in the Slack channel.\n\n We can’t wait to celebrate with you! :partying_face: :xero-love:"
			}
		}
	]
}
{
	"blocks": [
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": ":magic_wand::xero-unicorn: Xeros Connect: End of Year Celebration – A Sprinkle of Magic! :xero-unicorn::magic_wand:",
				"emoji": true
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*Hi Perth!* \nGet ready to wrap up the year with a sprinkle of magic and a lot of fun at our End of Year Event! Here’s everything you need to know:"
			}
		},
		{
			"type": "divider"
		},
		{
			"type": "section",
			"fields": [
				{
					"type": "mrkdwn",
					"text": "*📅 When:*\nFriday 13th December"
				},
				{
					"type": "mrkdwn",
					"text": "*📍 Where:*\n<https://www.google.com/maps?sca_esv=d161937f2a63904d&rlz=1C5GCCM_en&output=search&q=Leederville+Sporting+Club+Inc&source=lnms&fbs=AEQNm0AeMNWKf4PpcKMI-eSa16lJoRPMIuyspCxWO6iZW9F1NsHpGSbY6p65aYtb0pKhithD3nYIUrgYcer9L65Lp5hOnCqfrWx3I5HhZsSL93Fgy5Zqgq5vAS4DA73LOERqmDqhPhBwQhXhQFypczALGOnzgRlIDqMs7LIDX30Ew_emgrbF_rTyrRSHFOAQJWIU3rWBoTxMR8QlHGZYK_4CuMD857Hikw&entry=mc&ved=1t:200715&ictx=111|*Leederville Sporting Club*> \n78 Cambridge St, West Leederville WA 6007"
				},
				{
					"type": "mrkdwn",
					"text": "*⏰ Time:*\n12PM - 5PM"
				}
			]
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*:magic_wand::xero-unicorn: Theme:*\n_A Sprinkle of Magic_ – Our theme is inspired by the Xero Unicorn, embracing creativity, inclusivity, and diversity. Expect unique decor, magical moments, and a fun-filled atmosphere!"
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*:dress: Dress Code:*\n*Smart casual* – Show your personality, but no Xero tees or lanyards, please!\nIf you're feeling inspired by the theme, why not add a little 'Sprinkle of Magic' to your outfit? Think glitter, sparkles, or anything that shows off your creative side! (Totally optional, of course! :sparkle-sparkle:)"
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*🚍 Transport Info:* Please make your own way to the event venue."
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*🎤 :hamburger: Entertainment & Food:*\nPrepare for a game of lawn bowl activity at the Leederville Sporting Club Inc, followed by delicious bites and refreshing drinks after at Servo Restaurant! ✨🎶"
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*🎟 RSVP Now:* Click<https://xero-wx.jomablue.com/reg/store/eoy_per|* here*> to RSVP! Make sure you RSVP by *_Wednesday, 20th November 2024_*!"
			}
		},
		{
			"type": "divider"
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": ":question:Got questions? See the <https://docs.google.com/document/d/1iygJFHgLBRSdAffNsg3PudZCA45w6Wit7xsFxNc_wKM/edit|FAQs> doc or post in the Slack channel.\n\n We can’t wait to celebrate with you! :partying_face: :xero-love:"
			}
		}
	]
}
{
	"blocks": [
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": ":star: What's on in Melbourne this week! :star:"
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "\n\n Hey Melbourne, happy Monday! Please see below for what's on this week. "
			}
		},
		{
			"type": "divider"
		},
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": "Xero Café :coffee:",
				"emoji": true
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "\n :new-thing: *This week we are offering:* \n\n Double Dipped Finger Biscuits, Chocolate Chip Cookies, and Caramel & Macadamia Slice (Gluten Free) \n\n *Weekly Café Special*: _ Caramel Iced Latte_"
			}
		},
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": " Wednesday, 16th October :calendar-date-16:",
				"emoji": true
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "\n\n:icecream: *Afternoon Tea*: From *2pm* in the L3 kitchen + breakout space! \n\n:massage:*Wellbeing - Yin Yoga & Breathwork*: Confirm your spot <https://docs.google.com/spreadsheets/d/1iKMQtSaawEdJluOmhdi_r_dAifeIg0JGCu7ZSPuwRbo/edit?gid=0#gid=0/|*here*>. Please note we have a maximum of 15 participants per class, a minimum notice period of 2 hours is required if you can no longer attend. \n\n :eat-up: Our last Eat Up sandwich making session for the year! Register <https://docs.google.com/forms/d/e/1FAIpQLSfGWtG8mfkCu-gltX0M3fL-SmB3m4i-sOIK3-9qj1lCm1P9dg/viewform?usp=sf_link|*here*> to join in on the fun!"
			}
		},
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": "Thursday, 17th October :calendar-date-17:",
				"emoji": true
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": ":breakfast: *Breakfast*: Provided by *Kartel Catering* from *8:30am - 10:30am* in the Wominjeka Breakout Space.\n\n"
			}
		},
		{
			"type": "divider"
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*Later this month:* We have our Hackathon Themed Social+ on the 31st of October! \n\nStay tuned to this channel for more details, and make sure you're subscribed to the <https://calendar.google.com/calendar/u/0?cid=Y19xczkyMjk5ZGlsODJzMjA4aGt1b3RnM2t1MEBncm91cC5jYWxlbmRhci5nb29nbGUuY29t|*Melbourne Social Calendar*> :party-wx:"
			}
		}
	]
}
import logging
from telegram import Update
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext
from collections import defaultdict
import time
from threading import Thread

# Enable logging
logging.basicConfig(
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    level=logging.INFO
)
logger = logging.getLogger(__name__)

# Predefined admin user ID
ADMIN_ID = 123456789  # Replace with your actual Telegram user ID

# Store user data
user_media_count = defaultdict(int)
shared_content = defaultdict(list)  # Store content temporarily
whitelist = set()  # Whitelisted user IDs
banned_users = set()  # Banned user IDs
user_deadlines = {}  # Deadlines for media submissions

# Cleanup function to remove expired content
def cleanup_expired_content():
    while True:
        current_time = time.time()
        for user_id in list(user_deadlines.keys()):
            if current_time >= user_deadlines[user_id]:
                banned_users.add(user_id)
                del user_deadlines[user_id]
                logger.info(f"User {user_id} has been banned for not submitting media.")
        time.sleep(60)  # Check every minute

# Start command
def start(update: Update, context: CallbackContext) -> None:
    user_id = update.message.from_user.id
    if user_id in banned_users:
        return  # No response for banned users

    user_deadlines[user_id] = time.time() + 86400  # 24 hours in seconds
    update.message.reply_text(
        'Welcome to the Anonymous Sharing Bot! '
        'You need to send 2 media files within 24 hours to remain in the bot. '
        'Share media files to gain access to shared content or send a message anonymously.'
    )

# Countdown command
def countdown(update: Update, context: CallbackContext) -> None:
    user_id = update.message.from_user.id
    if user_id in banned_users:
        return  # No response for banned users

    if user_id in user_deadlines:
        remaining_time = int(user_deadlines[user_id] - time.time())
        if remaining_time > 0:
            hours, remainder = divmod(remaining_time, 3600)
            minutes, seconds = divmod(remainder, 60)
            update.message.reply_text(f"You have {hours} hours, {minutes} minutes, and {seconds} seconds left to submit your media.")
        else:
            update.message.reply_text("Your time has expired. You have been banned.")
    else:
        update.message.reply_text("You haven't started the submission process yet.")

# Help command
def help_command(update: Update, context: CallbackContext) -> None:
    commands = (
        "/start - Start using the bot\n"
        "/help - Show this help message\n"
        "/countdown - Check remaining time to submit media\n"
        "/wl_add <user_id> - Whitelist a user\n"
        "/ban <user_id> - Ban a user\n"
        "/delban <message_id> - Delete a message and ban the user\n"
        "/forward <media_id> - Forward media to your own cloud or group"
    )
    update.message.reply_text(f"Available commands:\n{commands}")

# Acknowledgment for media uploads
def acknowledge_upload(update: Update, context: CallbackContext) -> None:
    update.message.reply_text("Your media has been received successfully!")

# Add to whitelist command
def wl_add(update: Update, context: CallbackContext) -> None:
    if update.message.from_user.id != ADMIN_ID:
        update.message.reply_text("You do not have permission to whitelist users.")
        return
    
    if not context.args:
        update.message.reply_text("Please provide a Telegram ID to whitelist.")
        return
    
    user_id = int(context.args[0])
    whitelist.add(user_id)
    update.message.reply_text(f"User {user_id} has been whitelisted.")

# Ban command
def ban_user(update: Update, context: CallbackContext) -> None:
    if update.message.from_user.id != ADMIN_ID:
        update.message.reply_text("You do not have permission to ban users.")
        return
    
    user_id = update.message.reply_to_message.from_user.id if update.message.reply_to_message else None
    if user_id:
        banned_users.add(user_id)
        del user_deadlines[user_id]  # Remove deadline if user is banned
        update.message.reply_text(f"User {user_id} has been banned from using the bot.")
    else:
        update.message.reply_text("No user found to ban.")

# Delete and ban command
def delban(update: Update, context: CallbackContext) -> None:
    if update.message.from_user.id != ADMIN_ID:
        update.message.reply_text("You do not have permission to use this command.")
        return

    if not context.args:
        update.message.reply_text("Please provide the message ID to delete and ban the user.")
        return

    message_id = int(context.args[0])
    user_id = update.message.reply_to_message.from_user.id if update.message.reply_to_message else None

    if user_id:
        banned_users.add(user_id)
        del user_deadlines[user_id]  # Remove deadline if user is banned
        try:
            chat_id = update.effective_chat.id
            context.bot.delete_message(chat_id=chat_id, message_id=message_id)
            update.message.reply_text(f"Message {message_id} has been deleted and user {user_id} has been banned.")
        except Exception as e:
            logger.error(f"Error deleting message or banning user: {e}")
            update.message.reply_text("An error occurred while trying to delete the message or ban the user.")
    else:
        update.message.reply_text("No user found to ban.")

# Handle media messages
def handle_media(update: Update, context: CallbackContext) -> None:
    user_id = update.message.from_user.id
    
    if user_id in banned_users:
        return  # No response for banned users

    user_media_count[user_id] += 1

    try:
        if update.message.photo:
            media_type = "image"
            media = update.message.photo[-1].file_id
        elif update.message.video:
            media_type = "video"
            media = update.message.video.file_id
        else:
            update.message.reply_text('Please share an image or video.')
            return

        shared_content[user_id].append({'type': media_type, 'media': media, 'timestamp': time.time()})
        
        acknowledge_upload(update, context)  # Acknowledge the upload

        # Reset timer if the user has sent enough media
        if user_media_count[user_id] <= 2:
            user_deadlines[user_id] = time.time() + 86400  # Reset deadline to 24 hours from now
            if user_media_count[user_id] == 2:
                update.message.reply_text('Thank you for sharing 2 media files! You are allowed to stay in the bot.')

        if user_media_count[user_id] >= 5:
            update.message.reply_text('Thank you for sharing! You now have access to all shared content.')

        # Notify user of their media count
        update.message.reply_text(f"You have uploaded {user_media_count[user_id]} media files.")

    except Exception as e:
        logger.error(f"Error handling media from user {user_id}: {e}")
        update.message.reply_text("An error occurred while processing your media. Please try again.")

# Forward media to user-defined destinations
def forward_media(update: Update, context: CallbackContext) -> None:
    if not context.args:
        update.message.reply_text("Please provide the media ID you want to forward.")
        return

    media_id = context.args[0]
    user_id = update.message.from_user.id

    # Check if media exists for the user
    if user_id in shared_content:
        for content in shared_content[user_id]:
            if content['media'] == media_id:
                if content['type'] == 'image':
                    context.bot.send_photo(chat_id=update.effective_chat.id, photo=media_id)
                elif content['type'] == 'video':
                    context.bot.send_video(chat_id=update.effective_chat.id, video=media_id)
                update.message.reply_text("Media has been forwarded successfully.")
                return
    update.message.reply_text("Media not found.")

# Handle text messages
def handle_text(update: Update, context: CallbackContext) -> None:
    user_id = update.message.from_user.id

    if user_id in banned_users:
        return  # No response for banned users

    if user_media_count[user_id] < 5:
        update.message.reply_text('You need to share 5 media files first to access this feature.')
        return

    try:
        shared_content[user_id].append({'type': 'text', 'message': update.message.text, 'timestamp': time.time()})
        update.message.reply_text('Your anonymous message has been shared!')

    except Exception as e:
        logger.error(f"Error handling text from user {user_id}: {e}")
        update.message.reply_text("An error occurred while sharing your message. Please try again.")

def main() -> None:
    # Create Updater and pass it your bot's token
    updater = Updater("YOUR_BOT_TOKEN")  # Replace with your bot token

    # Get the dispatcher to register handlers
    dp = updater.dispatcher

    # Register handlers
    dp.add_handler(CommandHandler("start", start))
    dp.add_handler(CommandHandler("countdown", countdown))
    dp.add_handler(CommandHandler("help", help_command))
    dp.add_handler(CommandHandler("wl_add", wl_add))
    dp.add_handler(CommandHandler("ban", ban_user))
    dp.add_handler(CommandHandler("delban", delban))
    dp.add_handler(MessageHandler(Filters.photo | Filters.video, handle_media))
    dp.add_handler(MessageHandler(Filters.text & ~Filters.command, handle_text))

    # Start the Bot
    updater.start_polling()

    # Start the cleanup thread
    Thread(target=cleanup_expired_content, daemon=True).start()

    # Run the bot until you send a signal to stop
    updater.idle()

if __name__ == '__main__':
    main()
@AuraEnabled
    public static void updateContactAndAccountRecords(List<Map<String, Object>> updatedRecords) {
        system.debug(updatedRecords + ' updatedRecords');
        List<Contact> contactsToUpdate = new List<Contact>();
        List<Account> accountsToUpdate = new List<Account>();

        for (Map<String, Object> record : updatedRecords) {
            
            if (record.containsKey('Id')) {
                Contact c = new Contact();
                c.Id = (String) record.get('Id');
                
                if (record.containsKey('Phone')) {
                    c.Phone = (String) record.get('Phone');
                }
                contactsToUpdate.add(c);
            }

            
            if (record.containsKey('AccountId')) {
                Account a = new Account();
                a.Id = (String) record.get('AccountId');
                Boolean hasOtherFields = false;

                if (record.containsKey('AccountName')) {
                    a.Name = (String) record.get('AccountName');  
                    hasOtherFields = true; 
                }
                if (record.containsKey('AccountIndustry')) {
                    a.Industry = (String) record.get('AccountIndustry');
                    hasOtherFields = true; 
                }
                if (record.containsKey('AccountShippingCountry')) {
                    a.ShippingCountry = (String) record.get('AccountShippingCountry');
                    hasOtherFields = true;
                }
            
               
                if (hasOtherFields) {
                    accountsToUpdate.add(a);
                }
            }
        }

        
        if (!contactsToUpdate.isEmpty()) {
            update contactsToUpdate; 
        }
        if (!accountsToUpdate.isEmpty()) {
            update accountsToUpdate; 
        }
    }
<div class="avia-button-wrap avia-button-center black-button popup-cta">
    <span class="popmake-1101 avia-button avia-size-large avia-position-left avia-color-theme-color">
        <span class="avia_iconbox_title">Book Now</span>
    </span>
</div>
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

vector<vector<int>> save(int n, int k) {
    vector<vector<int>> save; // Vector để lưu trữ các vector con
    vector<vector<int>> done; 

    // Thêm từng chỉ số từ 1 đến n vào save như một vector con
    for (int i = 1; i <= n; i++) {
        vector<int> temp; // Tạo một vector tạm
        temp.push_back(i); // Thêm chỉ số i vào vector tạm
        save.push_back(temp); // Thêm vector tạm vào save
    }
    
    while (!save.empty()) {
        vector<int> A = save.back(); // Lấy vector con cuối cùng
        save.pop_back(); // Xóa vector đó khỏi save
        int a = A.back(); // Lấy phần tử cuối cùng của vector A
        int gap = k; // Bắt đầu với độ giãn là k
        
        while (true) {
            // Kiểm tra vị trí hợp lệ
            if (a + gap <= n) {
                vector<int> x = A; // Sao chép A vào x
                x.push_back(a + gap); // Thêm chỉ số hợp lệ vào x
                save.push_back(x); // Thêm x vào save
            } else {
                done.push_back(A); // Thêm A vào done
                break; // Thoát khỏi vòng lặp
            }
            gap++; // Tăng độ giãn lên 1
        }
    }
    
    return done; // Trả về các vector con đã tìm thấy
}

int main() {
    int n, k;
    
    cout << "Nhap n: ";
    cin >> n; // Nhập vào n
    
    cout << "Nhap k: ";
    cin >> k; // Nhập vào k

    vector<vector<int>> result = save(n, k);

    // Đếm số lần xuất hiện của từng phần tử trong result
    unordered_map<int, int> countMap; // Sử dụng unordered_map để đếm số lần xuất hiện

    cout << "Cac vector trong done:" << endl; // In ra các vector trong done
    for (const auto& vec : result) {
        for (int num : vec) {
            countMap[num]++; // Tăng số lần xuất hiện của phần tử num
        }
        // In ra từng vector
        cout << "{ ";
        for (int num : vec) {
            cout << num << " ";
        }
        cout << "}" << endl; // Xuống dòng
    }

    // Tính tổng
    int totalSum = 0;
    for (const auto& pair : countMap) {
        totalSum += pair.first * pair.second; // Tính tổng theo yêu cầu
        // In ra số lần xuất hiện của từng phần tử
        cout << "Phan tu " << pair.first << " xuat hien " << pair.second << " lan." << endl;
    }

    cout << "Tong cac phan tu xuat hien trong save: " << totalSum << endl; // In ra tổng

    return 0;
}
public class Section4Method {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        //instantiate
        Calculator calc = new Calculator();
        
        calc.originalPrice = 10.00;
        System.out.print("person1:$");
        calc.findTotal();
        
        calc.originalPrice = 12.00;
        System.out.print("person2:$");
        calc.findTotal();
        
        calc.originalPrice = 9.00;
        System.out.print("person3:$");
        calc.findTotal();
        
        calc.originalPrice = 8.00;
        System.out.print("person4:$");
        calc.findTotal();
        
        calc.originalPrice = 7.00;
        System.out.print("person5:$");
        calc.findTotal();
        
        calc.originalPrice = 15.00;
        System.out.print("person6:$");
        calc.findTotal();
        
        calc.originalPrice = 11.00;
        System.out.print("person7:$");
        calc.findTotal();
        
        calc.originalPrice = 30.00;
        System.out.print("person8:$");
        calc.findTotal();
    }
    
}



////PUBLIC CLASS CALCULATOR
public class Calculator {
    //public to be access main
    public double tax = .05;
    public double tip = .15;
    public double originalPrice = 0.0;
    
    public void findTotal(){//2 paremeters of price and string name
        double total = originalPrice * (1 + tax + tip);
        System.out.println(total);
        
    }
    
}
public class Section4 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        double tax= .05;
        double tip= .15;
        double person1=10.00;
        double person2=12.00;
        double person3=9.00;
        double person4=8.00;
        double person5=7.00;
        double person6=15.00;
        double person7=11.00;
        double person8=30.00;
        
        
       System.out.println("Person1:$" + person1 * (1+tip+tax));
       System.out.println("Person2:$" + person2 * (1+tip+tax));
       System.out.println("Person3:$" + person3 * (1+tip+tax));
       System.out.println("Person4:$" + person4 * (1+tip+tax));
       System.out.println("Person5:$" + person5 * (1+tip+tax));
       System.out.println("Person6:$" + person6 * (1+tip+tax));
       System.out.println("Person7:$" + person7 * (1+tip+tax));
       System.out.println("Person8:$" + person8 * (1+tip+tax));
        
        
        
        
    }
    
}
{
	"blocks": [
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": ":magic_wand::xero-unicorn: Xeros Connect: End of Year Celebration – A Sprinkle of Magic! :xero-unicorn::magic_wand:",
				"emoji": true
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*Hi Melbourne!* \nGet ready to wrap up the year with a sprinkle of magic and a lot of fun at our End of Year Event! Here’s everything you need to know:"
			}
		},
		{
			"type": "divider"
		},
		{
			"type": "section",
			"fields": [
				{
					"type": "mrkdwn",
					"text": "*📅 When:*\nThursday 28th November"
				},
				{
					"type": "mrkdwn",
					"text": "*📍 Where:*\n<https://www.google.com/maps/place/The+Timber+Yard/@-37.8331021,144.918894,17z/data=!3m1!4b1!4m6!3m5!1s0x6ad667735e56fcab:0x966480f06c58c00c!8m2!3d-37.8331021!4d144.9214743!16s/g/11gyy7sy4c?entry=ttu&g_ep=EgoyMDI0MDkxOC4xIKXMDSoASAFQAw==/|*The Timber Yard*> \n351 Plummer Street, Port Melbourne"
				},
				{
					"type": "mrkdwn",
					"text": "*⏰ Time:*\n4PM - 10PM"
				}
			]
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*:magic_wand::xero-unicorn: Theme:*\n_A Sprinkle of Magic_ – Our theme is inspired by the Xero Unicorn, embracing creativity, inclusivity, and diversity. Expect unique decor, magical moments, and a fun-filled atmosphere!"
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*:dress: Dress Code:*\n*Smart casual* – Show your personality, but no Xero tees or lanyards, please!\nIf you're feeling inspired by the theme, why not add a little 'Sprinkle of Magic' to your outfit? Think glitter, sparkles, or anything that shows off your creative side! (Totally optional, of course! :sparkle-sparkle:)"
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*🚍 Transport Info:*\n*Public Transport:* Via bus routes 234 & 235 - 5 min walk from bus stop\n*Parking:* 200+ unmetered and untimed spaces on Plummer & Smith Street"
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*🎤 :hamburger: Entertainment & Food:*\nPrepare to be dazzled by live music, enchanting magic shows, cozy chill-out zones, delicious bites, refreshing drinks, and plenty of surprises! ✨🎶"
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*🎟 RSVP Now:*\nPlease click <https://xero-wx.jomablue.com/reg/store/eoy_mel|here> to RSVP! \nMake sure you RSVP by *_14th November 2024_*"
			}
		},
		{
			"type": "divider"
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": ":question:Got questions? See the <https://docs.google.com/document/d/1iygJFHgLBRSdAffNsg3PudZCA45w6Wit7xsFxNc_wKM/edit|FAQs> doc or post in the Slack channel.\n\n We can’t wait to celebrate with you! :partying_face: :xero-love:"
			}
		}
	]
}
#include <iostream>
using namespace std;

// Function to sort the array using insertion sort algorithm.
void processInsertionSort(int arr[], int n) {
  
   for(int j=1;j<n;j++){
    int key= arr[j];
    int i=j-1;
        while(i>=0 && arr[i]>key){
            arr[i+1] = arr[i];
            i--;
        }
        arr[i+1] = key;
    }
  
}

void displayArray(int arr[], int n) {
  for (int i = 0; i < n; i++) {
    cout << arr[i] << " ";
  }
  cout << endl;
}

// Function to dynamically allocate an array and fill it with random values.
void fillDynamicArrayWithRandomValues(int** arr, int* n) {
    cout << "Enter the size of the array: ";
    cin >> *n;
    *arr = new int[*n];
    srand(time(0)); // Seed for random number generation
    for (int i = 0; i < *n; i++) {
        (*arr)[i] = rand() % 1000; // Fill with random numbers between 0 and 999
    }
}

int main() {
    int* arr;
    int n;
    fillDynamicArrayWithRandomValues(&arr, &n);
    cout << "Unsorted array: ";
    displayArray(arr, n);
    processInsertionSort(arr, n);
    cout << "Sorted array: ";
    displayArray(arr, n);
    delete[] arr; // Deallocate dynamically allocated memory
    return 0;
}
#include <iostream>
#include <vector>
using namespace std;

// Hàm sàng nguyên tố - sử dụng Sieve of Eratosthenes để tìm tất cả các số nguyên tố <= 3*n
vector<bool> sieve(int maxN) {
    vector<bool> is_prime(maxN + 1, true);

    is_prime[0] = is_prime[1] = false;  // 0 và 1 không phải là số nguyên tố

    for (int i = 2; i * i <= maxN; i++) {
        if (is_prime[i]) {
            for (int j = i * i; j <= maxN; j += i) {
                is_prime[j] = false;  // Đánh dấu các bội số của i là không phải số nguyên tố
            }
        }
    }

    return is_prime;  // Trả về mảng đánh dấu số nguyên tố
}

// Hàm tìm và in các cặp (x, y) sao cho x + 2*y là số nguyên tố
void findValidPairs(int n, const vector<bool>& is_prime) {
    for (int x = 1; x <= n; x++) {
        for (int y = 1; y <= n; y++) {
            int sum = x + 2 * y;
            if (sum <= is_prime.size() && is_prime[sum]) {
                cout << "(" << x << ", " << y << ") -> x + 2*y = " << sum << " là số nguyên tố" << endl;
            }
        }
    }
}

int main() {
    int n;
    cout << "Nhập n: ";
    cin >> n;

    // Giới hạn tối đa để kiểm tra số nguyên tố cho biểu thức x + 2*y là 3*n
    int maxSum = 3 * n;

    // Gọi hàm sàng nguyên tố cho các số từ 0 đến maxSum
    vector<bool> is_prime = sieve(maxSum);

    // Tìm các cặp (x, y) sao cho x + 2*y là số nguyên tố
    cout << "Các cặp (x, y) thỏa mãn điều kiện là: " << endl;
    findValidPairs(n, is_prime);

    return 0;
}
import java.util.Scanner;

public class Insertion {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        System.out.println("Enter size of array: ");

        int n = sc.nextInt();

        int arr[] = new int[n];

        System.out.println("enter array elements: ");

        for (int i = 0; i < n; i++) {

            arr[i] = sc.nextInt();

        }

        for (int i = 1; i < arr.length; i++) {

            int current = arr[i];

            int j;

            for (j = i - 1; j >= 0 && arr[j] > current; j--) {

                arr[j + 1] = arr[j];

            }

            arr[j + 1] = current;

        }

        System.out.println("sorted array: ");

        for (int i = 0; i < arr.length; i++) {

            System.out.print(arr[i] + " ");

        }

    }

}
<!DOCTYPE html>
<html lang="en">
    <head>
        <title></title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link href="css/style.css" rel="stylesheet">
    </head>
    <body>
    <p>
    <div class="cmain" style="display:inline-block; width:auto; height:auto; overflow:hidden;">
    <div class="container" style="display:inline-block; ">
    <iframe frameborder="no" src="https://embed.waze.com/es/iframe?zoom=15&lat=18.505706347986067&lon=-69.85666856117285&pin=1"
  width="800" height="670"></iframe>
  </div>
    </div>
    </body> 
</html>
public class TowerOfHanoi {

    public static void solve(int n, char source, char target, char auxiliary) {
        if (n == 1) {
            System.out.println("Move disk 1 from " + source + " to " + target);
            return;
        }
        solve(n - 1, source, auxiliary, target);
        System.out.println("Move disk " + n + " from " + source + " to " + target);
        solve(n - 1, auxiliary, target, source);
    }

    public static void main(String[] args) {
        int n = 3; // Number of disks
        solve(n, 'A', 'C', 'B'); // A, B and C are the names of the rods
    }
}
import java.util.Scanner;

public class Gcd {
    
    public static int gcd(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.print("Enter two numbers: ");
        int a = scanner.nextInt();
        int b = scanner.nextInt();

        int result = gcd(a, b);
        System.out.println("GCD of " + a + " and " + b + " is: " + result);

        scanner.close();
    }
}
import java.util.Scanner;

public class P1 {

    public static void print(int arr[]) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.print("Enter the size of the array: ");
        int n = scanner.nextInt();

        int arr[] = new int[n];

        System.out.println("Enter the array elements:");
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }

        int temp;
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] > arr[j + 1]) {
                    temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }

        System.out.println("Sorted array in ascending order:");
        print(arr);
        
        scanner.close();
    }
}
import java.util.Scanner;

public class Selection {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.print("Enter the size of the array: ");
        int n = scanner.nextInt();

        int arr[] = new int[n];

        System.out.println("Enter the array elements:");
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }

        for (int i = 0; i < arr.length - 1; i++) {
            int minimum = i;

            for (int j = i + 1; j < arr.length; j++) {
                if (arr[j] < arr[minimum]) {
                    minimum = j;
                }
            }

            int temp = arr[minimum];
            arr[minimum] = arr[i];
            arr[i] = temp;
        }

        System.out.println("Sorted array in descending order:");
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }

        scanner.close();
    }
}
#include <iostream>
using namespace std;

// Function to sort the array using bubble sort algorithm.
void processBubbleSort(int arr[], int n) {
  // Your code here
  int length =n;
  bool swapped = true;
  while(swapped){
    swapped = false;
    for (int i=0 ; i<length-1 ; i++){
        if(arr[i] > arr[i+1]){
            swapped = true;
            int largeElement = arr[i];
            arr[i] = arr[i+1];
            arr[i+1] = largeElement;
        }
    }
    length = length-1;
  }
}

void displayArray(int arr[], int n) {
  for (int i = 0; i < n; i++) {
    cout << arr[i] << " ";
  }
  cout << endl;
}

// Function to dynamically allocate an array and fill it with random values.
void fillDynamicArrayWithRandomValues(int** arr, int* n) {
    cout << "Enter the size of the array: ";
    cin >> *n;
    *arr = new int[*n];
    srand(time(0)); // Seed for random number generation
    for (int i = 0; i < *n; i++) {
        (*arr)[i] = rand() % 1000; // Fill with random numbers between 0 and 999
    }
}

int main() {
    int* arr;
    int n;
    fillDynamicArrayWithRandomValues(&arr, &n);
    cout << "Unsorted array: ";
    displayArray(arr, n);
    processBubbleSort(arr, n);
    cout << "Sorted array: ";
    displayArray(arr, n);
    delete[] arr; // Deallocate dynamically allocated memory
    return 0;
}
#include <iostream>
#include <vector>
using namespace std;

// Hàm sàng nguyên tố - sử dụng Sieve of Eratosthenes để tìm tất cả các số nguyên tố <= n
vector<int> sieve(int n) {
    vector<bool> is_prime(n + 1, true);
    vector<int> primes;

    is_prime[0] = is_prime[1] = false;  // 0 và 1 không phải là số nguyên tố

    for (int i = 2; i <= n; i++) {
        if (is_prime[i]) {
            primes.push_back(i);  // Nếu i là số nguyên tố, thêm vào danh sách
            for (int j = i * 2; j <= n; j += i) {
                is_prime[j] = false;  // Đánh dấu các bội số của i là không phải số nguyên tố
            }
        }
    }

    return primes;  // Trả về danh sách các số nguyên tố
}

// Hàm tìm và in các cặp (i, j) sao cho i + j = 5
void findPairsWithSum5(int n) {
    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j++) {
            if (i + j == 5) {
                cout << "(" << i << ", " << j << ")" << endl;
            }
        }
    }
}

int main() {
    int n;
    cout << "Nhập n: ";
    cin >> n;

    // Gọi hàm sàng nguyên tố và in kết quả
    vector<int> primes = sieve(n);
    cout << "Các số nguyên tố <= " << n << " là: ";
    for (int prime : primes) {
        cout << prime << " ";
    }
    cout << endl;

    // Tìm các cặp có tổng bằng 5
    cout << "Các cặp (i, j) có tổng bằng 5 là: " << endl;
    findPairsWithSum5(n);

    return 0;
}
//////////////////////////////// Fetching dymamic messages Start ///////////////////////////////////////////////////////////
messages = zoho.crm.getRecords("Chatbot_Messages");
// info messages;
for each  dynamic_message in messages
{
	if(dynamic_message.get("Type") == "Welcome")
	{
		welcome_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "HIPAA Disclaimer")
	{
		hippa_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Chat End")
	{
		chat_end_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Departments")
	{
		departments_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Issue")
	{
		issue_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Connect to Agent")
	{
		connect_to_agent_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "User Not Identified")
	{
		user_not_identified_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Other Email")
	{
		other_mail_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Select Product")
	{
		select_product_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "No Support Agreement")
	{
		no_support_agreement_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Category")
	{
		category_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Read Article")
	{
		read_article_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Article Found")
	{
		article_found_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Issue Resolved with Article")
	{
		issue_resolved_with_article_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Tallk to Agent")
	{
		talk_to_agent_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Thank You for Information")
	{
		thank_you_for_information_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Need Further Help")
	{
		need_further_help_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Thank You")
	{
		thank_you_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Ticket Created for Team")
	{
		ticket_created_for_team_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Ticket Created for Reference")
	{
		ticket_created_for_reference_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Issue Resolved")
	{
		issue_resolved_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "What Can I Help You")
	{
		how_can_i_help_you_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Operator Busy")
	{
		operator_busy_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Classification")
	{
		classification_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Ticket Not Created")
	{
		ticket_not_created_message = dynamic_message.get("Message");
	}
}
//////////////////////////////// Fetching dymamic messages Ends ///////////////////////////////////////////////////////////
response = Map();
departmentID = visitor.get("department_id");
if(failed_response.get("action").equalsIgnoreCase("forward"))
{
	code = cause.get("code").toNumber();
	if(code == 1001 || code == 1002 || code == 1003)
	{
		// Outside business hours // Busy Opertator /// Invalid Operator
		response.put("action","reply");
		response.put("replies",{operator_busy_message});
		if(departmentID == "655171000000007001")
		{
			// Sales Department
			getAccessToken = invokeurl
			[
				url :"https://accounts.zoho.com/oauth/v2/token?refresh_token=1000.35651ab6143ca5cf40a77d63143f2da4.dc85264b1c57b1203ae869a971598215&client_id=1000.D5KNOCDNNRDIJQO0WUATY3X7DYUUWE&client_secret=efd3a5b025c48fdb46843a14853197ad12b924aa20&grant_type=refresh_token"
				type :POST
			];
			// 			info getAccessToken.get("access_token");
			headerMap = Map();
			headerMap.put("Authorization","Zoho-oauthtoken " + getAccessToken.get("access_token"));
			// 			info headerMap;
			queryMap = Map();
			queryMap.put("select_query","select Issue_Type, Required_Information from ChatBot_Actions where Department = 'Sales'");
			response = invokeurl
			[
				url :"https://www.zohoapis.com/crm/v4/coql"
				type :POST
				parameters:queryMap.toString()
				headers:headerMap
			];
			// 	info response;
			responseData = response.get("data");
			issueTypeList = List();
			issueTypeVSRequiredInformation = Map();
			for each  option in responseData
			{
				if(!issueTypeList.contains(option.get("Issue_Type")))
				{
					issueTypeList.add(option.get("Issue_Type"));
				}
				////////////////////////////IssueType VS Required Information  /////////////////////////////
				if(issueTypeVSRequiredInformation.containKey(option.get("Issue_Type")))
				{
					requiredInformationList = issueTypeVSRequiredInformation.get(option.get("Issue_Type"));
					if(!requiredInformationList.contains(option.get("Required_Information")))
					{
						requiredInformationList.add(option.get("Required_Information"));
						issueTypeVSRequiredInformation.put(option.get("Issue_Type"),requiredInformationList);
					}
				}
				else
				{
					requiredInformationList = List();
					requiredInformationList.add(option.get("Required_Information"));
					issueTypeVSRequiredInformation.put(option.get("Issue_Type"),requiredInformationList);
				}
			}
			// 	info "issueType = "+issueTypeList;
			// 	info "issuetype vs recquired info ="+issueTypeVSRequiredInformation;
			response.put("action","context");
			response.put("context_id","salesIssueType");
			question = {"name":"issueType","replies":{issue_message},"input":{"type":"select","options":issueTypeList}};
			response.put("questions",{question});
			tempStoreMap = Map();
			tempStoreMap.put("salesIssuetypeVSrequiredInfo",issueTypeVSRequiredInformation);
			storeData = zoho.salesiq.visitorsession.set("mediproinc",tempStoreMap,"zoho_salesiq");
		}
	}
}
return response;
//////////////////////////////// Fetching dymamic messages Start ///////////////////////////////////////////////////////////
messages = zoho.crm.getRecords("Chatbot_Messages");
// info messages;
for each  dynamic_message in messages
{
	if(dynamic_message.get("Type") == "Welcome")
	{
		welcome_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "HIPAA Disclaimer")
	{
		hippa_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Chat End")
	{
		chat_end_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Departments")
	{
		departments_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Issue")
	{
		issue_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Connect to Agent")
	{
		connect_to_agent_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "User Not Identified")
	{
		user_not_identified_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Other Email")
	{
		other_mail_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Select Product")
	{
		select_product_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "No Support Agreement")
	{
		no_support_agreement_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Category")
	{
		category_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Read Article")
	{
		read_article_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Article Found")
	{
		article_found_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Issue Resolved with Article")
	{
		issue_resolved_with_article_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Tallk to Agent")
	{
		talk_to_agent_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Thank You for Information")
	{
		thank_you_for_information_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Need Further Help")
	{
		need_further_help_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Thank You")
	{
		thank_you_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Ticket Created for Team")
	{
		ticket_created_for_team_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Ticket Created for Reference")
	{
		ticket_created_for_reference_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Issue Resolved")
	{
		issue_resolved_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "What Can I Help You")
	{
		how_can_i_help_you_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Operator Busy")
	{
		operator_busy_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Classification")
	{
		classification_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Ticket Not Created")
	{
		ticket_not_created_message = dynamic_message.get("Message");
	}
}
//////////////////////////////// Fetching dymamic messages Ends ///////////////////////////////////////////////////////////
response = Map();
response.put("action","context");
response.put("context_id",context_id);
/////////////////////////Checking and Creating Sessions//////////////////////////////////////////////
departmentId = "810990000000014005";
deskDepartmentId = "206833000002271242";
data_mp = zoho.salesiq.visitorsession.get("mediproinc","data_mp","zoho_salesiq").get("data_mp");
if(!isNull(data_mp))
{
	department = data_mp.get("department");
	if(department == "Sales")
	{
		//sales
		departmentId = "810990000000014003";
		deskDepartmentId = "206833000001963132";
	}
	else if(department == "Client Care")
	{
		//client care		
		departmentId = "810990000000014005";
		deskDepartmentId = "206833000002271242";
	}
	accountID = data_mp.get("accountID");
	activeAgreement = data_mp.get("activeAgreement");
}
//////////////////////////////////////////////////////////////////////
if(context_id.equals("verifyContact"))
{
	contactEmail = answers.get("otherEmail").get("text");
	info contactEmail;
	///////////////////////////////////////////////////////////////////
	set_map = Map();
	set_map.put("otherEmail",contactEmail);
	temp_store = zoho.salesiq.visitorsession.set("mediproinc",set_map,"zoho_salesiq");
	info "Storing data = " + temp_store;
	////////////////////////////////////////////////////////
	searchContact = invokeurl
	[
		url :"https://www.zohoapis.com/crm/v3/Contacts/search?criteria=(Email:equals:" + contactEmail + ")"
		type :GET
		connection:"zohocrm"
	];
	// 	info searchContact;
	if(isNull(searchContact))
	{
		// Chat Forward
		response.put("action","forward");
		response.put("department",departmentId);
		response.put("replies",{connect_to_agent_message});
	}
	else
	{
		/////////////// User found ///////////////
		info "Record Found";
		contactDetials = searchContact.get("data").get(0);
		accountID = contactDetials.get("Account_Name").get("id");
		chatBotActions = invokeurl
		[
			url :"https://www.zohoapis.com/crm/v2/functions/erphub_test/actions/execute?auth_type=apikey&zapikey=1003.54e865e56692ea2154455b76012a7b71.1a7eab6552466d5f0187d84f8f1785b0&accountID=" + accountID
			type :POST
		];
		info "From function = " + chatBotActions;
		classifications = chatBotActions.get("details").get("output").get("classifications");
		///////////////////////////////////////////////////
		if(!classifications.isEmpty())
		{
			////////////////////////////////////////////////////////////////////////////////////////
			searchAgreement = invokeurl
			[
				url :"https://www.zohoapis.com/crm/v3/Contracts/search?criteria=((Account:equals:" + accountID + ")and(Status:equals:Active))"
				type :GET
				connection:"zohocrm"
			];
			info "searchAgreement: " + searchAgreement;
			activeAgreement = false;
			if(searchAgreement.size() > 0)
			{
				activeAgreement = true;
			}
			else
			{
				activeAgreement = false;
			}
			/////////////////////////////////////////////////////////////////////
			classification_rep_list = List();
			if(activeAgreement == true)
			{
				classification_rep_list.add(classification_message);
			}
			else
			{
				classification_rep_list.add(no_support_agreement_message);
				classification_rep_list.add(classification_message);
			}
			//////////////////////info show question/////////////////////////////
			response.put("action","context");
			response.put("context_id","clientCare");
			question = {"name":"classification","replies":classification_rep_list,"input":{"type":"select","options":classifications}};
			response.put("questions",{question});
			/////////////////////Create Session//////////////////////////////////
			data_mp = Map();
			data_mp.put("accountID",accountID);
			data_mp.put("activeAgreement",activeAgreement);
			data_mp.put("department","Client Care");
			set_map = Map();
			set_map.put("data_mp",data_mp);
			temp_store = zoho.salesiq.visitorsession.set("mediproinc",set_map,"zoho_salesiq");
			info "Storing data = " + temp_store;
			/////////////////////////////////////////////////////////////////////
		}
		else
		{
			// Chat End
			response.put("action","end");
			response.put("replies",{chat_end_message});
		}
	}
}
///////////////////// Sales Department ////////////////////////////////////
if(context_id.equals("salesIssueType"))
{
	if(!answers.containsKey("whatCanIhelpYouWith"))
	{
		selectedIssueType = answers.get("issueType").get("text");
		///////////////////////////////////////////////////////////////////////////////
		response.put("context_id","salesIssueType");
		question = {"name":"whatCanIhelpYouWith","replies":{how_can_i_help_you_message}};
		response.put("questions",{question});
	}
	else
	{
		selectedIssueType = answers.get("issueType").get("text");
		helpAnswer = answers.get("whatCanIhelpYouWith").get("text");
		leadMap = Map();
		fullName = visitor.get("name");
		if(fullName.contains(" "))
		{
			leadMap.put("First_Name",fullName.getPrefix(" "));
			leadMap.put("Last_Name",fullName.getSuffix(" "));
		}
		else
		{
			leadMap.put("Last_Name",fullName);
		}
		leadMap.put("Company",fullName);
		leadMap.put("Email",visitor.get("email"));
		leadMap.put("Phone",visitor.get("phone"));
		leadMap.put("Lead_Source","Chat");
		leadMap.put("Description",helpAnswer);
		options = Map();
		optionlist = list();
		optionlist.add("workflow");
		options.put("trigger",optionlist);
		leadResponse = zoho.crm.createRecord("leads",leadMap,options,"zohocrm");
		// 		info "Creating lead: " + leadResponse;
		// Chat Forward
		response.put("action","forward");
		response.put("department",departmentId);
		response.put("replies",{connect_to_agent_message});
	}
}
///////////////////// Sales Department End /////////////////////////
///////////////////// Client Care //////////////////////////////
////// User not identified ///////////////
if(context_id.equals("userNotIdentified"))
{
	if(!answers.containsKey("couldNotIdentify"))
	{
		response.put("action","context");
		response.put("context_id","userNotIdentified");
		couldNotIdentify = {"name":"couldNotIdentify","replies":{user_not_identified_message},"input":{"type":"select","options":{"Yes","No"}}};
		response.put("questions",{couldNotIdentify});
	}
	else
	{
		couldNotIdentify = answers.get("couldNotIdentify").get("text");
		if(couldNotIdentify.toString() == "Yes")
		{
			if(!answers.containsKey("otherEmail"))
			{
				response.put("action","context");
				response.put("context_id","verifyContact");
				otherEmail = {"name":"otherEmail","replies":{other_mail_message}};
				response.put("questions",{otherEmail});
			}
		}
		else
		{
			// Chat Forward
			response.put("action","forward");
			response.put("department",departmentId);
			response.put("replies",{connect_to_agent_message});
		}
	}
}
////// User not identified End ///////////////
//////////////////  Client Care /////////////////////
if(context_id.equals("clientCare"))
{
	chatBotActions = invokeurl
	[
		url :"https://www.zohoapis.com/crm/v2/functions/erphub_test/actions/execute?auth_type=apikey&zapikey=1003.54e865e56692ea2154455b76012a7b71.1a7eab6552466d5f0187d84f8f1785b0&accountID=" + accountID
		type :POST
	];
	// 	info "From function = " + chatBotActions;
	classifications = chatBotActions.get("details").get("output").get("classifications");
	classificationsVsCategories = chatBotActions.get("details").get("output").get("classificationsVsCategories");
	catergoriesVsIssueTypes = chatBotActions.get("details").get("output").get("catergoriesVsIssueTypes");
	issueTypeVsrequireInfo = chatBotActions.get("details").get("output").get("issueTypeVsrequireInfo");
	if(answers.containsKey("classification") && !answers.containsKey("category"))
	{
		classification = answers.get("classification").get("text");
		response.put("context_id","clientCare");
		category = {"name":"category","replies":{category_message},"input":{"type":"select","options":classificationsVsCategories.get(classification)}};
		response.put("questions",{category});
	}
	else
	{
		keyCombination_issueType = answers.get("classification").get("text") + "/" + answers.get("category").get("text");
		returnedCategories = catergoriesVsIssueTypes.get(keyCombination_issueType);
		if(!returnedCategories.contains("Empty") && answers.containsKey("classification") && answers.containsKey("category") && !answers.containsKey("issueType"))
		{
			category = answers.get("category").get("text");
			response.put("context_id","clientCare");
			issueType = {"name":"issueType","replies":{issue_message},"input":{"type":"select","options":returnedCategories}};
			response.put("questions",{issueType});
		}
		else
		{
			keyCombination = answers.get("classification").get("text") + "/" + answers.get("category").get("text") + "/" + ifnull(answers.get("issueType"),{"text":"Empty"}).get("text");
			info keyCombination;
			crmRecordId = issueTypeVsrequireInfo.get(keyCombination);
			/////////////////////////////////////////////////////////////////////////////////////////////
			tempStoreMap = Map();
			tempStoreMap.put("crmRecordId",crmRecordId);
			tempStoreMap.put("classification",answers.get("classification").get("text"));
			tempStoreMap.put("category",answers.get("category").get("text"));
			tempStoreMap.put("issueType",ifnull(answers.get("issueType"),{"text":"Empty"}).get("text"));
			storeData = zoho.salesiq.visitorsession.set("mediproinc",tempStoreMap,"zoho_salesiq");
			/////////////////////////////////////////////////////////////////////////////////////////////
			chatBotActionsRecId = invokeurl
			[
				url :"https://www.zohoapis.com/crm/v2/functions/Chatbot_Actions_Using_RecId/actions/execute?auth_type=apikey&zapikey=1003.54e865e56692ea2154455b76012a7b71.1a7eab6552466d5f0187d84f8f1785b0&recId=" + crmRecordId
				type :POST
			];
			requiredInfoType = chatBotActionsRecId.get("details").get("output").get("requiredInfoType");
			///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			Free_Typing_Questions_Instructions = chatBotActionsRecId.get("details").get("output").get("Free_Typing_Questions_Instructions");
			KB_Instruction_Article = chatBotActionsRecId.get("details").get("output").get("KB_Instruction_Article");
			Free_Typing_Formatted_Questions = chatBotActionsRecId.get("details").get("output").get("Free_Typing_Formatted_Questions");
			///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			Multi_Option_Message = chatBotActionsRecId.get("details").get("output").get("Multi_Option_Message");
			Multi_Option_Question = chatBotActionsRecId.get("details").get("output").get("Multi_Option_Question");
			Multiple_Options = chatBotActionsRecId.get("details").get("output").get("Multiple_Options");
			Option_vs_Output_Messages = chatBotActionsRecId.get("details").get("output").get("Option_vs_Output_Messages");
			Option_vs_Output_Actions = chatBotActionsRecId.get("details").get("output").get("Option_vs_Output_Actions");
			Option_vs_Output_Article = chatBotActionsRecId.get("details").get("output").get("Option_vs_Output_Article");
			///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			Output_Message = chatBotActionsRecId.get("details").get("output").get("Output_Message");
			Output_Action = chatBotActionsRecId.get("details").get("output").get("Output_Action");
			KB_Article = chatBotActionsRecId.get("details").get("output").get("KB_Article");
			///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			if(requiredInfoType == "Free Typing Question")
			{
				response.put("action","context");
				response.put("context_id","output");
				////////////////////////////////////////////////
				question_count = 1;
				questions_list = List();
				for each  val in Free_Typing_Formatted_Questions
				{
					replies = Collection();
					if(question_count == 1)
					{
						if(Free_Typing_Questions_Instructions != "-" && Free_Typing_Questions_Instructions != null)
						{
							if(KB_Instruction_Article != null && KB_Instruction_Article != "-")
							{
								replies.insert({"type":"links","text":Free_Typing_Questions_Instructions,"links":{{"url":KB_Instruction_Article,"text":read_article_message}}});
							}
							else
							{
								replies.insert(Free_Typing_Questions_Instructions);
							}
						}
					}
					info val;
					replies.insert(val);
					question = {"name":val,"replies":replies};
					questions_list.add(question);
					////////////////////////////////////////////
					question_count = question_count + 1;
				}
				response.put("questions",questions_list);
			}
			else if(requiredInfoType == "Multi Option Question")
			{
				response.put("action","context");
				response.put("context_id","multi_option_context");
				////////////////////////////////////////////////
				replies = Collection();
				if(!isNull(Multi_Option_Message))
				{
					replies.insert(Multi_Option_Message);
				}
				replies.insert(Multi_Option_Question);
				question = {"name":"multiOptionSelection","replies":replies,"input":{"type":"select","options":Multiple_Options}};
				response.put("questions",{question});
			}
			else if(requiredInfoType == "Article Only")
			{
				replies = Collection();
				KB_Article = ifnull(KB_Article,"https://www.medipro.com/");
				if(Output_Message != "-" && Output_Message != null)
				{
					replies.insert({"type":"links","text":Output_Message,"links":{{"url":KB_Article,"text":read_article_message}}});
				}
				else
				{
					replies.insert({"type":"links","text":article_found_message,"links":{{"url":KB_Article,"text":read_article_message}}});
				}
				response.put("action","end");
				response.put("replies",replies);
			}
		}
	}
}
////////////////////////////////////////////
if(context_id.equals("multi_option_context"))
{
	crmRecordId = zoho.salesiq.visitorsession.get("mediproinc","crmRecordId","zoho_salesiq").get("crmRecordId");
	/////////////////////////////////////////////////////////////////////////////////////////////
	chatBotActionsRecId = invokeurl
	[
		url :"https://www.zohoapis.com/crm/v2/functions/Chatbot_Actions_Using_RecId/actions/execute?auth_type=apikey&zapikey=1003.54e865e56692ea2154455b76012a7b71.1a7eab6552466d5f0187d84f8f1785b0&recId=" + crmRecordId
		type :POST
	];
	requiredInfoType = chatBotActionsRecId.get("details").get("output").get("requiredInfoType");
	Check_Support_Agreement = chatBotActionsRecId.get("details").get("output").get("Check_Support_Agreement");
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	Multi_Option_Message = chatBotActionsRecId.get("details").get("output").get("Multi_Option_Message");
	Multi_Option_Question = chatBotActionsRecId.get("details").get("output").get("Multi_Option_Question");
	Multiple_Options = chatBotActionsRecId.get("details").get("output").get("Multiple_Options");
	Option_vs_Output_Messages = chatBotActionsRecId.get("details").get("output").get("Option_vs_Output_Messages");
	Option_vs_Output_Actions = chatBotActionsRecId.get("details").get("output").get("Option_vs_Output_Actions");
	Option_vs_Output_Article = chatBotActionsRecId.get("details").get("output").get("Option_vs_Output_Article");
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////		
	if(requiredInfoType == "Multi Option Question")
	{
		selectedValue = answers.get("multiOptionSelection").get("text");
		/////////////////////////////////////////////////////////////////////////////////////////////
		tempStoreMap = Map();
		tempStoreMap.put("multiOptionSelection",selectedValue);
		storeData = zoho.salesiq.visitorsession.set("mediproinc",tempStoreMap,"zoho_salesiq");
		/////////////////////////////////////////////////////////////////////////////////////////////
		selectedMessages = ifnull(Option_vs_Output_Messages.get(selectedValue),"-");
		info "Line 463";
		info "selected Messages = " + selectedMessages;
		////////////////////////////////////////////////
		if(selectedMessages.matches("\d+\.") || selectedMessages.contains("?") || selectedMessages.contains(":"))
		{
			response.put("action","context");
			response.put("context_id","output");
			mainQuestion = selectedMessages.getPrefix(":");
			if(mainQuestion == null)
			{
				mainQuestion = selectedMessages;
			}
			subQuestions = selectedMessages.getSuffix(":");
			if(subQuestions != null)
			{
				finalSubQuestion = subQuestions.replaceAll("\d+\.","<q>").replaceFirst("<q>","").toList("<q>");
			}
			////////////////////////////////////////////////
			question_count = 1;
			questions_list = List();
			for each  val in finalSubQuestion
			{
				trimmedQuestion = val.trim();
				replies = Collection();
				if(question_count == 1)
				{
					if(mainQuestion != "-" && mainQuestion != null)
					{
						replies.insert(mainQuestion);
					}
				}
				replies.insert(trimmedQuestion);
				question = {"name":trimmedQuestion,"replies":replies};
				questions_list.add(question);
				////////////////////////////////////////////
				question_count = question_count + 1;
			}
			response.put("questions",questions_list);
		}
		else
		{
			selectedActions = Option_vs_Output_Actions.get(selectedValue);
			selectedArticle = Option_vs_Output_Article.get(selectedValue);
			finalActions = selectedActions;
			finalArticle = ifnull(selectedArticle,"https://www.medipro.com/");
			//////////////////////////////////////////////////////////////////////////////////////////////
			if(activeAgreement == false && Check_Support_Agreement == true)
			{
				finalActions.removeElement("Talk to an Agent");
			}
			//////////////////////////////////////////////////////
			////////////////  Create Ticket //////////////////////////////////////////////////////////
			ticketId = "";
			ticketNumber = "";
			if(finalActions.contains("Open Ticket") || finalActions.contains("Closed Ticket"))
			{
				otherEmail = zoho.salesiq.visitorsession.get("mediproinc","otherEmail","zoho_salesiq").get("otherEmail");
				email = ifnull(otherEmail,visitor.get("email"));
				search_param_map = Map();
				search_param_map.put("email",email);
				Get_Contact = invokeurl
				[
					url :"https://desk.zoho.com/api/v1/contacts/search?"
					type :GET
					parameters:search_param_map
					connection:"zoho_desk"
				];
				// 			info "Searching Customer = "+Get_Contact;
				if(Get_Contact.get("data").size() > 0)
				{
					//// Contact found 
					deskContactID = Get_Contact.get("data").get(0).get("id");
				}
				else
				{
					/// Create Contact
					contactMap = Map();
					fullName = visitor.get("name");
					if(fullName.contains(" "))
					{
						contactMap.put("firstName",fullName.getPrefix(" "));
						contactMap.put("lastName",fullName.getSuffix(" "));
					}
					else
					{
						contactMap.put("lastName",fullName);
					}
					otherEmail = zoho.salesiq.visitorsession.get("mediproinc","otherEmail","zoho_salesiq").get("otherEmail");
					email = ifnull(otherEmail,visitor.get("email"));
					contactMap.put("email",email);
					contactMap.put("phone",visitor.get("phone"));
					creatingDeskContact = invokeurl
					[
						url :"https://desk.zoho.com/api/v1/contacts"
						type :POST
						parameters:contactMap.toString()
						connection:"zoho_desk"
					];
					info "creatingDeskContact = " + creatingDeskContact;
					deskContactID = creatingDeskContact.get("id");
				}
				////////////////////////////////////////////////////////////
				classification = zoho.salesiq.visitorsession.get("mediproinc","classification","zoho_salesiq").get("classification");
				category = zoho.salesiq.visitorsession.get("mediproinc","category","zoho_salesiq").get("category");
				issueType = zoho.salesiq.visitorsession.get("mediproinc","issueType","zoho_salesiq").get("issueType");
				////////////////////////////////////////////////////////////
				//// Creating Ticket
				create_map = Map();
				create_map.put("subject","Ticket submitted by " + visitor.get("name") + " via Chatbot.");
				create_map.put("contactId",deskContactID);
				create_map.put("departmentId",deskDepartmentId);
				create_map.put("channel","Chat");
				create_map.put("description","");
				create_map.put("classification",classification.replaceAll("[\"#%&'+,;<=>\\^`{}|~]",""));
				create_map.put("category",category.replaceAll("[\"#%&'+,;<=>\\^`{}|~]",""));
				if(issueType.toString() != "Empty")
				{
					cf = Map();
					cf.put("cf_issue_type",issueType.replaceAll("[\"#%&'+,;<=>\\^`{}|~]",""));
					create_map.put("cf",cf);
				}
				createTicketResp = invokeurl
				[
					url :"https://desk.zoho.com/api/v1/tickets"
					type :POST
					parameters:create_map + ""
					connection:"zoho_desk"
				];
				info "createTicketResp = " + createTicketResp;
				if(createTicketResp.containsKey("modifiedTime"))
				{
					ticketId = createTicketResp.get("id");
					ticketNumber = createTicketResp.get("ticketNumber");
				}
			}
			/////////////////////////////////////////////////////////////////////////////////////////////
			tempStoreMap = Map();
			tempStoreMap.put("ticketId",ticketId);
			tempStoreMap.put("ticketNumber",ticketNumber);
			tempStoreMap.put("finalActions",finalActions);
			storeData = zoho.salesiq.visitorsession.set("mediproinc",tempStoreMap,"zoho_salesiq");
			/////////////////////////////////////////////////////////////////////////////////////////////
			////////////////// Article - Agent - > True ///////////////////////////////////////////////////////
			if(finalActions.contains("KB Article") && !finalActions.contains("Talk to an Agent") && !finalActions.contains("Open Ticket") && !finalActions.contains("Closed Ticket"))
			{
				replies = Collection();
				if(selectedMessages != "-")
				{
					replies.insert(selectedMessages);
				}
				finalArticle = ifnull(finalArticle,"https://www.medipro.com/");
				if(selectedMessages != "-" && selectedMessages != null)
				{
					replies.insert({"type":"links","text":article_found_message,"links":{{"url":finalArticle,"text":read_article_message}}});
				}
				else
				{
					replies.insert({"type":"links","text":article_found_message,"links":{{"url":finalArticle,"text":read_article_message}}});
				}
				response.put("action","end");
				response.put("replies",replies);
			}
			else if(finalActions.contains("KB Article"))
			{
				response.put("action","context");
				response.put("context_id","issue_resolved_with_kb");
				replies = Collection();
				if(selectedMessages != "-")
				{
					replies.insert(selectedMessages);
				}
				replies.insert({"type":"links","text":article_found_message,"links":{{"url":finalArticle,"text":read_article_message}}});
				replies.insert(issue_resolved_with_article_message);
				question = {"name":"issueResolvedWithKb","replies":replies,"input":{"type":"select","options":{"Yes","No"}}};
				response.put("questions",{question});
			}
			////////////////// Article - > True  | Agent  -> False /////////////////////////////////////////	
			else if(!finalActions.contains("KB Article") && finalActions.contains("Talk to an Agent"))
			{
				response.put("action","context");
				response.put("context_id","talk_to_human");
				replies = Collection();
				if(selectedMessages != "-")
				{
					replies.insert(selectedMessages);
				}
				if(ticketNumber != null && ticketNumber != "")
				{
					ticket_message = ticket_created_for_team_message.getPrefix("{{") + ticketNumber + ticket_created_for_team_message.getSuffix("}}");
					replies.insert(ticket_message);
				}
				replies.insert(talk_to_agent_message);
				question = {"name":"connectTo","replies":replies,"input":{"type":"select","options":{"Yes","No"}}};
				response.put("questions",{question});
			}
			//////////////////  Agent - Article  -> False /////////////////////////////////////////		
			else if(!finalActions.contains("KB Article") && !finalActions.contains("Talk to an Agent"))
			{
				if(ticketId != null)
				{
					//////////////////////////////// Attaching chat Transcript on the Ticket Starts //////////////////////////////////////////
					conversation_id = visitor.get("active_conversation_id");
					param = Map();
					param.put("data","messages");
					param.put("format","pdf");
					export_chat = invokeurl
					[
						url :"https://salesiq.zoho.com/api/v2/mediproinc/conversations/" + conversation_id + "/export"
						type :POST
						parameters:param + ""
						connection:"zoho_salesiq"
					];
					info "Exporting Chat = " + export_chat;
					export_chat.setParamName("file");
					header = Map();
					header.put("Content-Type","multipart/form-data");
					////// attach file to ticket ////
					attach = invokeurl
					[
						url :"https://desk.zoho.com/api/v1/tickets/" + ticketId + "/attachments?isPublic=true"
						type :POST
						headers:header
						files:export_chat
						connection:"zoho_desk"
					];
					//////////////////////////////// Attaching chat Transcript on the Ticket Ends //////////////////////////////////////////
				}
				replies = Collection();
				if(selectedMessages != "-")
				{
					replies.insert(selectedMessages);
				}
				if(finalActions.contains("Closed Ticket"))
				{
					update_map = Map();
					update_map.put("status","Closed");
					updateTicketResp = invokeurl
					[
						url :"https://desk.zoho.com/api/v1/tickets/" + ticketId + ""
						type :PATCH
						parameters:update_map + ""
						connection:"zoho_desk"
					];
					//////////////////////////////////////////////////////////////
					replies.insert(thank_you_for_information_message);
					need_help_message = need_further_help_message.getPrefix("{{") + ticketNumber + need_further_help_message.getSuffix("}}");
					replies.insert(need_help_message);
					replies.insert(thank_you_message);
				}
				else
				{
					replies.insert(thank_you_for_information_message);
					ticket_team_message = ticket_created_for_team_message.getPrefix("{{") + ticketNumber + ticket_created_for_team_message.getSuffix("}}");
					replies.insert(ticket_team_message);
					replies.insert(thank_you_message);
				}
				response.put("action","end");
				response.put("replies",replies);
			}
		}
	}
}
/////// Output ///////
if(context_id.equals("output"))
{
	crmRecordId = zoho.salesiq.visitorsession.get("mediproinc","crmRecordId","zoho_salesiq").get("crmRecordId");
	info "Line: 362: crmRecordId: " + crmRecordId;
	/////////////////////////////////////////////////////////////////////////////////////////////
	chatBotActionsRecId = invokeurl
	[
		url :"https://www.zohoapis.com/crm/v2/functions/Chatbot_Actions_Using_RecId/actions/execute?auth_type=apikey&zapikey=1003.54e865e56692ea2154455b76012a7b71.1a7eab6552466d5f0187d84f8f1785b0&recId=" + crmRecordId
		type :POST
	];
	info "Line: 369: chatBotActionsRecId: " + chatBotActionsRecId;
	requiredInfoType = chatBotActionsRecId.get("details").get("output").get("requiredInfoType");
	Check_Support_Agreement = chatBotActionsRecId.get("details").get("output").get("Check_Support_Agreement");
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	Output_Action = chatBotActionsRecId.get("details").get("output").get("Output_Action");
	KB_Article = chatBotActionsRecId.get("details").get("output").get("KB_Article");
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	Option_vs_Output_Actions = chatBotActionsRecId.get("details").get("output").get("Option_vs_Output_Actions");
	Option_vs_Output_Article = chatBotActionsRecId.get("details").get("output").get("Option_vs_Output_Article");
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	if(requiredInfoType == "Free Typing Question")
	{
		finalActions = Output_Action;
		finalArticle = ifnull(KB_Article,"https://www.medipro.com/");
	}
	else if(requiredInfoType == "Multi Option Question")
	{
		selectedValue = zoho.salesiq.visitorsession.get("mediproinc","multiOptionSelection","zoho_salesiq").get("multiOptionSelection");
		info "selectedValue: " + selectedValue;
		selectedActions = Option_vs_Output_Actions.get(selectedValue);
		selectedArticle = Option_vs_Output_Article.get(selectedValue);
		finalActions = selectedActions;
		finalArticle = ifnull(selectedArticle,"https://www.medipro.com/");
	}
	//////////////////////////////////////////////////////////////////////////////////////////////
	if(activeAgreement == false && Check_Support_Agreement == true)
	{
		finalActions.removeElement("Talk to an Agent");
	}
	info "Final ACtions: " + finalActions;
	//////////////////////////////////////////////////////
	inputValuesString = "Questions:<br><br>";
	for each  keyVal in answers.keys()
	{
		info keyVal;
		inputValuesString = inputValuesString + keyVal + " : " + answers.get(keyVal).get("text") + "<br><br>";
	}
	info "inputValuesString: " + inputValuesString;
	info finalActions;
	info finalArticle;
	////////////////  Create Ticket //////////////////////////////////////////////////////////
	ticketId = "";
	ticketNumber = "";
	if(finalActions.contains("Open Ticket") || finalActions.contains("Closed Ticket"))
	{
		otherEmail = zoho.salesiq.visitorsession.get("mediproinc","otherEmail","zoho_salesiq").get("otherEmail");
		email = ifnull(otherEmail,visitor.get("email"));
		search_param_map = Map();
		search_param_map.put("email",email);
		Get_Contact = invokeurl
		[
			url :"https://desk.zoho.com/api/v1/contacts/search?"
			type :GET
			parameters:search_param_map
			connection:"zoho_desk"
		];
		// 			info "Searching Customer = "+Get_Contact;
		if(Get_Contact.get("data").size() > 0)
		{
			//// Contact found 
			deskContactID = Get_Contact.get("data").get(0).get("id");
		}
		else
		{
			/// Create Contact
			contactMap = Map();
			fullName = visitor.get("name");
			if(fullName.contains(" "))
			{
				contactMap.put("firstName",fullName.getPrefix(" "));
				contactMap.put("lastName",fullName.getSuffix(" "));
			}
			else
			{
				contactMap.put("lastName",fullName);
			}
			otherEmail = zoho.salesiq.visitorsession.get("mediproinc","otherEmail","zoho_salesiq").get("otherEmail");
			email = ifnull(otherEmail,visitor.get("email"));
			contactMap.put("email",email);
			contactMap.put("phone",visitor.get("phone"));
			creatingDeskContact = invokeurl
			[
				url :"https://desk.zoho.com/api/v1/contacts"
				type :POST
				parameters:contactMap.toString()
				connection:"zoho_desk"
			];
			info "creatingDeskContact = " + creatingDeskContact;
			deskContactID = creatingDeskContact.get("id");
		}
		////////////////////////////////////////////////////////////
		classification = zoho.salesiq.visitorsession.get("mediproinc","classification","zoho_salesiq").get("classification");
		category = zoho.salesiq.visitorsession.get("mediproinc","category","zoho_salesiq").get("category");
		issueType = zoho.salesiq.visitorsession.get("mediproinc","issueType","zoho_salesiq").get("issueType");
		////////////////////////////////////////////////////////////		
		//// Creating Ticket
		create_map = Map();
		create_map.put("subject","Ticket submitted by " + visitor.get("name") + " via Chatbot.");
		create_map.put("contactId",deskContactID);
		create_map.put("departmentId",deskDepartmentId);
		create_map.put("channel","Chat");
		create_map.put("description",ifnull(inputValuesString,""));
		create_map.put("classification",classification.replaceAll("[\"#%&'+,;<=>\\^`{}|~]",""));
		create_map.put("category",category.replaceAll("[\"#%&'+,;<=>\\^`{}|~]",""));
		if(issueType.toString() != "Empty")
		{
			cf = Map();
			cf.put("cf_issue_type",issueType.replaceAll("[\"#%&'+,;<=>\\^`{}|~]",""));
			create_map.put("cf",cf);
		}
		createTicketResp = invokeurl
		[
			url :"https://desk.zoho.com/api/v1/tickets"
			type :POST
			parameters:create_map + ""
			connection:"zoho_desk"
		];
		info "createTicketResp = " + createTicketResp;
		if(createTicketResp.containsKey("modifiedTime"))
		{
			ticketId = createTicketResp.get("id");
			ticketNumber = createTicketResp.get("ticketNumber");
		}
	}
	/////////////////////////////////////////////////////////////////////////////////////////////
	tempStoreMap = Map();
	tempStoreMap.put("ticketId",ticketId);
	tempStoreMap.put("ticketNumber",ticketNumber);
	tempStoreMap.put("finalActions",finalActions);
	storeData = zoho.salesiq.visitorsession.set("mediproinc",tempStoreMap,"zoho_salesiq");
	/////////////////////////////////////////////////////////////////////////////////////////////
	////////////////// Article - Agent - > True ///////////////////////////////////////////////////////
	if(finalActions.contains("KB Article"))
	{
		info "IN: KB Article Condition";
		response.put("action","context");
		response.put("context_id","issue_resolved_with_kb");
		replies = Collection();
		replies.insert({"type":"links","text":article_found_message,"links":{{"url":finalArticle,"text":read_article_message}}});
		replies.insert(issue_resolved_with_article_message);
		question = {"name":"issueResolvedWithKb","replies":replies,"input":{"type":"select","options":{"Yes","No"}}};
		response.put("questions",{question});
	}
	////////////////// Article - > True  | Agent  -> False /////////////////////////////////////////	
	else if(!finalActions.contains("KB Article") && finalActions.contains("Talk to an Agent"))
	{
		response.put("action","context");
		response.put("context_id","talk_to_human");
		replies = Collection();
		if(ticketNumber != null && ticketNumber != "")
		{
			ticket_team_message = ticket_created_for_team_message.getPrefix("{{") + ticketNumber + ticket_created_for_team_message.getSuffix("}}");
			replies.insert(ticket_team_message);
		}
		replies.insert(talk_to_agent_message);
		question = {"name":"connectTo","replies":replies,"input":{"type":"select","options":{"Yes","No"}}};
		response.put("questions",{question});
	}
	//////////////////  Agent - Article  -> False /////////////////////////////////////////		
	else if(!finalActions.contains("KB Article") && !finalActions.contains("Talk to an Agent"))
	{
		if(ticketId != null)
		{
			//////////////////////////////// Attaching chat Transcript on the Ticket Starts //////////////////////////////////////////
			conversation_id = visitor.get("active_conversation_id");
			param = Map();
			param.put("data","messages");
			param.put("format","pdf");
			export_chat = invokeurl
			[
				url :"https://salesiq.zoho.com/api/v2/mediproinc/conversations/" + conversation_id + "/export"
				type :POST
				parameters:param + ""
				connection:"zoho_salesiq"
			];
			info "Exporting Chat = " + export_chat;
			export_chat.setParamName("file");
			header = Map();
			header.put("Content-Type","multipart/form-data");
			////// attach file to ticket ////
			attach = invokeurl
			[
				url :"https://desk.zoho.com/api/v1/tickets/" + ticketId + "/attachments?isPublic=true"
				type :POST
				headers:header
				files:export_chat
				connection:"zoho_desk"
			];
			//////////////////////////////// Attaching chat Transcript on the Ticket Ends //////////////////////////////////////////
		}
		replies = Collection();
		if(finalActions.contains("Closed Ticket"))
		{
			update_map = Map();
			update_map.put("status","Closed");
			updateTicketResp = invokeurl
			[
				url :"https://desk.zoho.com/api/v1/tickets/" + ticketId + ""
				type :PATCH
				parameters:update_map + ""
				connection:"zoho_desk"
			];
			//////////////////////////////////////////////////////////////
			replies.insert(thank_you_for_information_message);
			need_futher_help_ticket_message = need_further_help_message.getPrefix("{{") + ticketNumber + need_further_help_message.getSuffix("}}");
			replies.insert(need_futher_help_ticket_message);
			replies.insert(thank_you_message);
		}
		else
		{
			replies.insert(thank_you_for_information_message);
			ticket_message = ticket_created_for_team_message.getPrefix("{{") + ticketNumber + ticket_created_for_team_message.getSuffix("}}");
			replies.insert(ticket_message);
			replies.insert(thank_you_message);
		}
		response.put("action","end");
		response.put("replies",replies);
	}
}
///////////////////////////////////////////////////////////////////////////////////////////
if(context_id.equals("issue_resolved_with_kb"))
{
	info "IN: Issue Resolved Context";
	if(answers.containsKey("issueResolvedWithKb"))
	{
		ticketId = zoho.salesiq.visitorsession.get("mediproinc","ticketId","zoho_salesiq").get("ticketId");
		ticketNumber = zoho.salesiq.visitorsession.get("mediproinc","ticketNumber","zoho_salesiq").get("ticketNumber");
		finalActions = zoho.salesiq.visitorsession.get("mediproinc","finalActions","zoho_salesiq").get("finalActions");
		info "finalActions: " + finalActions;
		///////////////////////////////////////////////////////////////////////////
		issueResolvedWithKb = answers.get("issueResolvedWithKb").get("text");
		if(issueResolvedWithKb.toString() == "Yes")
		{
			if(ticketId != null)
			{
				//////////////////////////////// Attaching chat Transcript on the Ticket Starts //////////////////////////////////////////
				conversation_id = visitor.get("active_conversation_id");
				param = Map();
				param.put("data","messages");
				param.put("format","pdf");
				export_chat = invokeurl
				[
					url :"https://salesiq.zoho.com/api/v2/mediproinc/conversations/" + conversation_id + "/export"
					type :POST
					parameters:param + ""
					connection:"zoho_salesiq"
				];
				info "Exporting Chat = " + export_chat;
				export_chat.setParamName("file");
				header = Map();
				header.put("Content-Type","multipart/form-data");
				////// attach file to ticket ////
				attach = invokeurl
				[
					url :"https://desk.zoho.com/api/v1/tickets/" + ticketId + "/attachments?isPublic=true"
					type :POST
					headers:header
					files:export_chat
					connection:"zoho_desk"
				];
				//////////////////////////////// Attaching chat Transcript on the Ticket Ends //////////////////////////////////////////
			}
			update_map = Map();
			update_map.put("status","Closed");
			updateTicketResp = invokeurl
			[
				url :"https://desk.zoho.com/api/v1/tickets/" + ticketId + ""
				type :PATCH
				parameters:update_map + ""
				connection:"zoho_desk"
			];
			////////////////////////////////////////////////////////////////////////////////////
			replies = Collection();
			replies.insert(thank_you_for_information_message);
			if(ticketNumber != null && ticketNumber != "")
			{
				referenct_ticket_message = ticket_created_for_reference_message.getPrefix("{{") + ticketNumber + ticket_created_for_reference_message.getSuffix("}}");
				replies.insert(referenct_ticket_message);
			}
			else
			{
				replies.insert(issue_resolved_message);
			}
			replies.insert(thank_you_message);
			response.put("action","end");
			response.put("replies",replies);
		}
		else if(issueResolvedWithKb.toString() == "No" && !finalActions.contains("Talk to an Agent"))
		{
			if(ticketId != null)
			{
				//////////////////////////////// Attaching chat Transcript on the Ticket Starts //////////////////////////////////////////
				conversation_id = visitor.get("active_conversation_id");
				param = Map();
				param.put("data","messages");
				param.put("format","pdf");
				export_chat = invokeurl
				[
					url :"https://salesiq.zoho.com/api/v2/mediproinc/conversations/" + conversation_id + "/export"
					type :POST
					parameters:param + ""
					connection:"zoho_salesiq"
				];
				info "Exporting Chat = " + export_chat;
				export_chat.setParamName("file");
				header = Map();
				header.put("Content-Type","multipart/form-data");
				////// attach file to ticket ////
				attach = invokeurl
				[
					url :"https://desk.zoho.com/api/v1/tickets/" + ticketId + "/attachments?isPublic=true"
					type :POST
					headers:header
					files:export_chat
					connection:"zoho_desk"
				];
				//////////////////////////////// Attaching chat Transcript on the Ticket Ends //////////////////////////////////////////
			}
			replies = Collection();
			replies.insert(thank_you_for_information_message);
			if(ticketNumber != null && ticketNumber != "")
			{
				ticket_message = ticket_created_for_team_message.getPrefix("{{") + ticketNumber + ticket_created_for_team_message.getSuffix("}}");
				replies.insert(ticket_message);
			}
			else
			{
				replies.insert(ticket_not_created_message);
			}
			replies.insert(thank_you_message);
			response.put("action","end");
			response.put("replies",replies);
		}
		else if(issueResolvedWithKb.toString() == "No" && finalActions.contains("Talk to an Agent"))
		{
			response.put("action","context");
			response.put("context_id","talk_to_human");
			replies = Collection();
			if(ticketNumber != null && ticketNumber != "")
			{
				ticket_message = ticket_created_for_team_message.getPrefix("{{") + ticketNumber + ticket_created_for_team_message.getSuffix("}}");
				replies.insert(ticket_message);
			}
			replies.insert(talk_to_agent_message);
			question = {"name":"connectTo","replies":replies,"input":{"type":"select","options":{"Yes","No"}}};
			response.put("questions",{question});
		}
	}
}
///////////////////////////////////////////////////////////////////////////////////////////
if(context_id.equals("talk_to_human"))
{
	ticketId = zoho.salesiq.visitorsession.get("mediproinc","ticketId","zoho_salesiq").get("ticketId");
	if(ticketId != null)
	{
		//////////////////////////////// Attaching chat Transcript on the Ticket Starts //////////////////////////////////////////
		conversation_id = visitor.get("active_conversation_id");
		param = Map();
		param.put("data","messages");
		param.put("format","pdf");
		export_chat = invokeurl
		[
			url :"https://salesiq.zoho.com/api/v2/mediproinc/conversations/" + conversation_id + "/export"
			type :POST
			parameters:param + ""
			connection:"zoho_salesiq"
		];
		info "Exporting Chat = " + export_chat;
		export_chat.setParamName("file");
		header = Map();
		header.put("Content-Type","multipart/form-data");
		////// attach file to ticket ////
		attach = invokeurl
		[
			url :"https://desk.zoho.com/api/v1/tickets/" + ticketId + "/attachments?isPublic=true"
			type :POST
			headers:header
			files:export_chat
			connection:"zoho_desk"
		];
		//////////////////////////////// Attaching chat Transcript on the Ticket Ends //////////////////////////////////////////
	}
	info "IN: talk_to_human Context";
	if(answers.containsKey("connectTo"))
	{
		connectTo = answers.get("connectTo").get("text");
		info "connectTo = " + connectTo;
		if(connectTo.toString() == "Yes")
		{
			info departmentId;
			// Chat Forward
			response.put("action","forward");
			response.put("department",departmentId);
			response.put("replies",{connect_to_agent_message});
		}
		else
		{
			replies = Collection();
			replies.insert(thank_you_for_information_message);
			replies.insert(ticket_not_created_message);
			response.put("action","end");
			response.put("replies",replies);
		}
	}
}
return response;
//////////////////////////////// Fetching dymamic messages Start ///////////////////////////////////////////////////////////
messages = zoho.crm.getRecords("Chatbot_Messages");
// info messages;
for each  dynamic_message in messages
{
	// 	info dynamic_message.get("Type");
	if(dynamic_message.get("Type") == "Welcome")
	{
		welcome_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "HIPAA Disclaimer")
	{
		hippa_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Chat End")
	{
		chat_end_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Departments")
	{
		departments_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Issue")
	{
		issue_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Connect to Agent")
	{
		connect_to_agent_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "User Not Identified")
	{
		user_not_identified_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Other Email")
	{
		other_mail_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Select Product")
	{
		select_product_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "No Support Agreement")
	{
		no_support_agreement_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Category")
	{
		category_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Read Article")
	{
		read_article_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Article Found")
	{
		article_found_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Issue Resolved with Article")
	{
		issue_resolved_with_article_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Tallk to Agent")
	{
		talk_to_agent_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Thank You for Information")
	{
		thank_you_for_information_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Need Further Help")
	{
		need_further_help_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Thank You")
	{
		thank_you_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Ticket Created for Team")
	{
		ticket_created_for_team_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Ticket Created for Reference")
	{
		ticket_created_for_reference_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Issue Resolved")
	{
		issue_resolved_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "What Can I Help You")
	{
		how_can_i_help_you_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Operator Busy")
	{
		operator_busy_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Classification")
	{
		classification_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Ticket Not Created")
	{
		ticket_not_created_message = dynamic_message.get("Message");
	}
}
//////////////////////////////// Fetching dymamic messages Ends ///////////////////////////////////////////////////////////
response = Map();
response.put("action","reply");
response.put("replies",{hippa_message,welcome_message,departments_message});
response.put("input",{"type":"select","options":{"Client Care","Sales"}});
return response;
//////////////////////////////// Fetching dymamic messages Start ///////////////////////////////////////////////////////////
messages = zoho.crm.getRecords("Chatbot_Messages");
info messages;
for each  dynamic_message in messages
{
	if(dynamic_message.get("Type") == "Welcome")
	{
		welcome_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "HIPAA Disclaimer")
	{
		hippa_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Chat End")
	{
		chat_end_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Departments")
	{
		departments_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Issue")
	{
		issue_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Connect to Agent")
	{
		connect_to_agent_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "User Not Identified")
	{
		user_not_identified_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Other Email")
	{
		other_mail_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Select Product")
	{
		select_product_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "No Support Agreement")
	{
		no_support_agreement_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Category")
	{
		category_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Read Article")
	{
		read_article_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Article Found")
	{
		article_found_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Issue Resolved with Article")
	{
		issue_resolved_with_article_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Tallk to Agent")
	{
		talk_to_agent_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Thank You for Information")
	{
		thank_you_for_information_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Need Further Help")
	{
		need_further_help_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Thank You")
	{
		thank_you_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Ticket Created for Team")
	{
		ticket_created_for_team_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Ticket Created for Reference")
	{
		ticket_created_for_reference_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Issue Resolved")
	{
		issue_resolved_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "What Can I Help You")
	{
		how_can_i_help_you_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Operator Busy")
	{
		operator_busy_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Classification")
	{
		classification_message = dynamic_message.get("Message");
	}
	else if(dynamic_message.get("Type") == "Ticket Not Created")
	{
		ticket_not_created_message = dynamic_message.get("Message");
	}
}
//////////////////////////////// Fetching dymamic messages Ends ///////////////////////////////////////////////////////////
response = Map();
msg = message.get("text");
name = visitor.get("name");
email = visitor.get("email");
phone = visitor.get("phone");
// departmentId = visitor.get("department_id");
/////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
if(operation.equals("chat"))
{
	if(!msg.equalsIgnoreCase("Client Care") && !msg.equalsIgnoreCase("Sales"))
	{
		response = Map();
		response.put("action","reply");
		response.put("replies",{hippa_message,welcome_message,departments_message});
		response.put("input",{"type":"select","options":{"Client Care","Sales"}});
		return response;
	}
}
if(msg.equalsIgnoreCase("Sales"))
{
	chatBotActions = invokeurl
	[
		url :"https://www.zohoapis.com/crm/v2/functions/Fetch_Chabot_Sales_Actions/actions/execute?auth_type=apikey&zapikey=1003.54e865e56692ea2154455b76012a7b71.1a7eab6552466d5f0187d84f8f1785b0"
		type :POST
	];
	info "From function = " + chatBotActions;
	issueTypes = chatBotActions.get("details").get("output").get("issueType");
	///////////////////////////////////////////////////
	if(!issueTypes.isEmpty())
	{
		/////////////////////Create Session//////////////////////////////////
		data_mp = Map();
		data_mp.put("department","Sales");
		set_map = Map();
		set_map.put("data_mp",data_mp);
		temp_store = zoho.salesiq.visitorsession.set("mediproinc",set_map,"zoho_salesiq");
		info "Storing data = " + temp_store;
		/////////////////////////////////////////////////////////////////////	
		//info show question
		response.put("action","context");
		response.put("context_id","salesIssueType");
		question = {"name":"issueType","replies":{issue_message},"input":{"type":"select","options":issueTypes}};
		response.put("questions",{question});
	}
	else
	{
		// Chat Forward
		// Sales Department: 810990000000014003
		response.put("action","forward");
		response.put("department","810990000000014003");
		response.put("replies",{connect_to_agent_message});
	}
}
else if(msg.equalsIgnoreCase("Client Care"))
{
	searchContact = invokeurl
	[
		url :"https://www.zohoapis.com/crm/v3/Contacts/search?criteria=(Email:equals:" + email + ")"
		type :GET
		connection:"zohocrm"
	];
	info searchContact;
	info isNull(searchContact);
	if(isNull(searchContact))
	{
		/////////////////////Create Session//////////////////////////////////
		data_mp = Map();
		data_mp.put("department","Client Care");
		set_map = Map();
		set_map.put("data_mp",data_mp);
		temp_store = zoho.salesiq.visitorsession.set("mediproinc",set_map,"zoho_salesiq");
		info "Storing data = " + temp_store;
		/////////////////////////////////////////////////////////////////////		
		/////// User Did not Identified ////////
		response.put("action","context");
		response.put("context_id","userNotIdentified");
		otherEmail = {"name":"otherEmail","replies":{user_not_identified_message,other_mail_message}};
		couldNotIdentify = {"name":"couldNotIdentify","replies":{user_not_identified_message},"input":{"type":"select","options":{"Yes","No"}}};
		response.put("questions",{couldNotIdentify});
	}
	else
	{
		/////////////// User found ///////////////
		info "Record Found";
		contactDetials = searchContact.get("data").get(0);
		accountID = ifnull(contactDetials.get("Account_Name"),{"id":null}).get("id");
		chatBotActions = invokeurl
		[
			url :"https://www.zohoapis.com/crm/v2/functions/erphub_test/actions/execute?auth_type=apikey&zapikey=1003.54e865e56692ea2154455b76012a7b71.1a7eab6552466d5f0187d84f8f1785b0&accountID=" + accountID
			type :POST
		];
		info "From function = " + chatBotActions;
		classifications = chatBotActions.get("details").get("output").get("classifications");
		///////////////////////////////////////////////////
		if(!classifications.isEmpty())
		{
			////////////////////////////////////////////////////////////////////////////////////////
			searchAgreement = invokeurl
			[
				url :"https://www.zohoapis.com/crm/v3/Contracts/search?criteria=((Account:equals:" + accountID + ")and(Status:equals:Active))"
				type :GET
				connection:"zohocrm"
			];
			info "searchAgreement: " + searchAgreement;
			activeAgreement = false;
			if(searchAgreement.size() > 0)
			{
				activeAgreement = true;
			}
			else
			{
				activeAgreement = false;
			}
			/////////////////////////////////////////////////////////////////////
			classification_rep_list = List();
			if(activeAgreement == true)
			{
				// 				classificationText = "Please select a classification";
				classification_rep_list.add(select_product_message);
			}
			else
			{
				classification_rep_list.add(no_support_agreement_message);
				classification_rep_list.add(select_product_message);
			}
			//////////////////////info show question/////////////////////////////
			response.put("action","context");
			response.put("context_id","clientCare");
			question = {"name":"classification","replies":classification_rep_list,"input":{"type":"select","options":classifications}};
			response.put("questions",{question});
			/////////////////////Create Session//////////////////////////////////
			data_mp = Map();
			data_mp.put("accountID",accountID);
			data_mp.put("activeAgreement",activeAgreement);
			data_mp.put("department","Client Care");
			set_map = Map();
			set_map.put("data_mp",data_mp);
			temp_store = zoho.salesiq.visitorsession.set("mediproinc",set_map,"zoho_salesiq");
			info "Storing data = " + temp_store;
			/////////////////////////////////////////////////////////////////////
		}
		else
		{
			// Chat Forward
			// Client Care Department: 810990000000014005
			response.put("action","forward");
			response.put("department","810990000000014005");
			response.put("replies",{connect_to_agent_message});
		}
	}
}
else
{
	response = Map();
	response.put("action","reply");
	response.put("replies",{hippa_message,welcome_message,departments_message});
	response.put("input",{"type":"select","options":{"Client Care","Sales"}});
	return response;
}
return response;
להכניס להתאמה אישית css  

להכניס להתאמה אישית css  

body:not(.elementor-editor-active) .saleIcon{
    display: none;
}

body:not(.elementor-editor-active) 
.product_cat-sale .saleIcon {
    display: block;
}

לפני זה להכניס 
CSS Classes
saleIcon


לפני זה להכניס 
CSS Classes
saleIcon

with age_group as( 
  select 
    a.activity_type,
    a.time_spent,
    ab.age_bucket
  from 
    activities as a  
    left join age_breakdown as ab  
    on a.user_id = ab.user_id
  where 
    a.activity_type in ('send','open')
),

open_send_sums as (
  select 
    age_bucket,
    sum(case when activity_type = 'open' then time_spent else 0 end) as open_sum,
    sum(case when activity_type = 'send' then time_spent else 0 end) as send_sum,
    sum(time_spent) as total_sum
  from 
    age_group
  group by 
    age_bucket
)

select
  age_bucket,
  round((send_sum / total_sum) * 100 , 2) as send_perc,
  round((open_sum / total_sum) * 100 , 2) as open_perc
from open_send_sums;
star

Sun Oct 13 2024 19:26:16 GMT+0000 (Coordinated Universal Time) https://ferdy.com/the-best-code-snippets-for-wordpress/

@Y@sir

star

Sun Oct 13 2024 19:26:07 GMT+0000 (Coordinated Universal Time) https://ferdy.com/the-best-code-snippets-for-wordpress/

@Y@sir

star

Sun Oct 13 2024 19:25:53 GMT+0000 (Coordinated Universal Time) https://ferdy.com/the-best-code-snippets-for-wordpress/

@Y@sir

star

Sun Oct 13 2024 19:25:25 GMT+0000 (Coordinated Universal Time) https://ferdy.com/the-best-code-snippets-for-wordpress/

@Y@sir #convertall images to webp

star

Sun Oct 13 2024 19:24:45 GMT+0000 (Coordinated Universal Time) https://qub-sherlock.readthedocs.io/en/master/install.html

@JD3970

star

Sun Oct 13 2024 19:24:41 GMT+0000 (Coordinated Universal Time) https://qub-sherlock.readthedocs.io/en/master/install.html

@JD3970

star

Sun Oct 13 2024 14:34:58 GMT+0000 (Coordinated Universal Time)

@iliavial #c#

star

Sun Oct 13 2024 14:27:41 GMT+0000 (Coordinated Universal Time)

@iliavial #c#

star

Sun Oct 13 2024 11:17:52 GMT+0000 (Coordinated Universal Time)

@webisko #css

star

Sat Oct 12 2024 09:56:39 GMT+0000 (Coordinated Universal Time) https://www.cron24.com/airbnb-clone

@jackveeranan #airbnbcloneapp #airbnbclonescript #airbnbclone

star

Sat Oct 12 2024 09:54:57 GMT+0000 (Coordinated Universal Time) https://www.cron24.com/blog/what-is-an-airbnb-clone-script

@jackveeranan #airbnbclone #airbnbcloneapp #airbnbclonescript

star

Sat Oct 12 2024 09:01:19 GMT+0000 (Coordinated Universal Time) https://www.scribd.com/document/602427248/DOWNLOADER-CODES-LIST

@Jondar

star

Sat Oct 12 2024 07:17:45 GMT+0000 (Coordinated Universal Time) https://gist.github.com/wpacademy/39d1268583daa1dae84ec571f236f6da#file-mask-css-L1

@Umar

star

Fri Oct 11 2024 20:20:10 GMT+0000 (Coordinated Universal Time)

@ncdiep

star

Fri Oct 11 2024 18:34:49 GMT+0000 (Coordinated Universal Time)

@jrg_300i #undefined

star

Fri Oct 11 2024 12:19:20 GMT+0000 (Coordinated Universal Time)

@adsj

star

Fri Oct 11 2024 12:18:39 GMT+0000 (Coordinated Universal Time)

@adsj

star

Fri Oct 11 2024 08:01:43 GMT+0000 (Coordinated Universal Time)

@rafal_rydz

star

Fri Oct 11 2024 07:58:52 GMT+0000 (Coordinated Universal Time)

@rafal_rydz

star

Fri Oct 11 2024 03:10:33 GMT+0000 (Coordinated Universal Time)

@wayneinvein

star

Fri Oct 11 2024 03:09:13 GMT+0000 (Coordinated Universal Time)

@wayneinvein

star

Fri Oct 11 2024 01:47:09 GMT+0000 (Coordinated Universal Time)

@FOHWellington

star

Fri Oct 11 2024 01:37:08 GMT+0000 (Coordinated Universal Time)

@FOHWellington

star

Fri Oct 11 2024 00:17:19 GMT+0000 (Coordinated Universal Time)

@WXAPAC

star

Thu Oct 10 2024 22:21:06 GMT+0000 (Coordinated Universal Time) https://chatgpt.com/

@johnsoap1

star

Thu Oct 10 2024 18:49:08 GMT+0000 (Coordinated Universal Time) https://help.shodan.io/command-line-interface/0-installation

@edzukation

star

Thu Oct 10 2024 11:58:15 GMT+0000 (Coordinated Universal Time) https://pairbytes.com/rummy-game-development-company/

@johnandrew24 #rummy #game

star

Thu Oct 10 2024 11:56:23 GMT+0000 (Coordinated Universal Time)

@Nandha #apex

star

Thu Oct 10 2024 06:47:02 GMT+0000 (Coordinated Universal Time)

@omnixima #javascript

star

Thu Oct 10 2024 04:31:59 GMT+0000 (Coordinated Universal Time) https://www.programiz.com/cpp-programming/online-compiler/

@LizzyTheCatto

star

Thu Oct 10 2024 04:05:18 GMT+0000 (Coordinated Universal Time)

@kervinandy123 #java

star

Thu Oct 10 2024 03:31:16 GMT+0000 (Coordinated Universal Time)

@kervinandy123 #java

star

Thu Oct 10 2024 02:01:50 GMT+0000 (Coordinated Universal Time)

@FOHWellington

star

Thu Oct 10 2024 00:11:07 GMT+0000 (Coordinated Universal Time)

@deshmukhvishal2 #cpp

star

Wed Oct 09 2024 21:13:13 GMT+0000 (Coordinated Universal Time) https://www.programiz.com/cpp-programming/online-compiler/

@LizzyTheCatto

star

Wed Oct 09 2024 19:26:38 GMT+0000 (Coordinated Universal Time)

@wayneinvein

star

Wed Oct 09 2024 19:23:36 GMT+0000 (Coordinated Universal Time)

@marcopinero #html

star

Wed Oct 09 2024 18:26:01 GMT+0000 (Coordinated Universal Time)

@wayneinvein

star

Wed Oct 09 2024 18:20:43 GMT+0000 (Coordinated Universal Time)

@wayneinvein

star

Wed Oct 09 2024 18:18:22 GMT+0000 (Coordinated Universal Time)

@wayneinvein

star

Wed Oct 09 2024 18:16:10 GMT+0000 (Coordinated Universal Time)

@wayneinvein

star

Wed Oct 09 2024 18:12:41 GMT+0000 (Coordinated Universal Time)

@deshmukhvishal2 #cpp

star

Wed Oct 09 2024 16:35:26 GMT+0000 (Coordinated Universal Time) https://www.programiz.com/cpp-programming/online-compiler/

@LizzyTheCatto

star

Wed Oct 09 2024 15:18:53 GMT+0000 (Coordinated Universal Time)

@usman13

star

Wed Oct 09 2024 15:18:23 GMT+0000 (Coordinated Universal Time)

@usman13

star

Wed Oct 09 2024 15:17:54 GMT+0000 (Coordinated Universal Time)

@usman13

star

Wed Oct 09 2024 15:17:20 GMT+0000 (Coordinated Universal Time)

@usman13

star

Wed Oct 09 2024 12:57:41 GMT+0000 (Coordinated Universal Time)

@odesign

star

Wed Oct 09 2024 11:04:33 GMT+0000 (Coordinated Universal Time) https://datalemur.com/questions/time-spent-snaps

@vhasepta

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension