npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@predictivehire/phchatbot

v2.22.1

Published

PredictiveHire AI chatbot. You can contact PredictiveHire for more information. https://www.predictivehire.com

Downloads

119

Readme

Information

PredictiveHire AI chatbot. You can contact PredictiveHire for more information. https://www.predictivehire.com

Usage

  1. Preparation
  2. use React
  3. use Vue(SPA mode)
  4. use Vue(SSR mode)

0. prepare

In order to initiate the request correctly when developing locally, you need to add the host of app.localhost.com

Note: If you use vue-cli to create a new project, you might meet a Invalid Host/Origin header error when you open the page with app.localhost.com. This is because the new version of webpack-dev-server adds security verification. The hostname is checked by default. If the hostname is not in the configuration, the access will be interrupted.

Solution: Create the file vue.config.js in the root directory, and then fill in the following content:

module.exports = {
  devServer: {
    disableHostCheck: true,
  }
}

1. use React

create TestPage component

|-- TestPage

|---- TestPage.tsx

|---- style.css

// ----------------------------------- TestPage.tsx ----------------------------
import "./style.css"

import * as React from "react"
import { PHChatBot } from "@predictivehire/phchatbot"

export const TestPage = () => {
  // for assessmentId you can contact PredictiveHire for more information, so do appId and region
  const appId = "appId"
  const assessmentId = "assessmentId"
  const region = "region" // need to confirm with PredictiveHire
  const env = "qa" // this one is used to decide which domain name to use to initiate an api request

  const chatbotATS = new PHChatBot({
    appId: appId,
    region: region,
    env: env,
    assessmentId: assessmentId
  })

  // developers can add the event callback they want
  chatbotATS.addCallbackHandler({
    FI_ASSESSMENT_STARTED: payload => {
      console.info(payload)
    },
    FI_ASSESSMENT_ANSWER_SAVED: payload => {
      console.info(payload)
    },
    FI_ASSESSMENT_ENDED: assessmentId => {
      console.info(assessmentId)
    }
  })
  chatbotATS.setTheme({
    theme: {
      question: {
        backgroundColor: "#ef8200",
        fontColor: "#fff"
      }
    }
  })
  chatbotATS.attachTo({ selector: "#rootATS" })

  return (
    <div className="main">
      <div className="chat-bot-box" id="rootATS" />
    </div>
  )
}

//-------------------------------------- style.css ----------------------------
.main {
  position: relative;
  text-align: center;
  width: 500px;
  height: 90vh;
  margin: 5vh auto;
  background-color: #fff;
}

.chat-bot-box {
  position: relative;
  z-index: 10;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  background-color: #fff;
}

@media screen and (max-width: 980px) {
  .chat-bot-box {
    position: fixed;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    transform: none;
  }
}

2. use Vue(SPA mode)

<template>
  <div class="main">
    <div class="chat-bot-box" id="rootATS" />
  </div>
</template>

<script>
import {PHChatBot} from "@predictivehire/phchatbot"
export default {
  name: 'HelloWorld',
  mounted: () => {
    // for assessmentId you can contact PredictiveHire for more information, so do appId and region
    const appId = "appId"
    const assessmentId = "assessmentId"
    const region = "region" // need to confirm with PredictiveHire
    const env = "qa" // this one is used to decide which domain name to use to initiate an api request

    const chatbotATS = new PHChatBot({
      appId: appId,
      region: region, // need to confirm with PredictiveHire
      env: env, // this one is used to decide which domain name to use to initiate an api request
      assessmentId: assessmentId
    })

    // developers can add the event callback they want
    chatbotATS.addCallbackHandler({
      FI_ASSESSMENT_STARTED: payload => {
        console.info(payload)
      },
      FI_ASSESSMENT_ANSWER_SAVED: payload => {
        console.info(payload)
      },
      FI_ASSESSMENT_ENDED: assessmentId => {
        console.info(assessmentId)
      }
    })
    chatbotATS.setTheme({
      theme: {
        question: {
          backgroundColor: "#ef8200",
          fontColor: "#fff"
        }
      }
    })
    chatbotATS.attachTo({ selector: "#rootATS" })
  }
}
</script>

<style scoped>
.main {
  position: relative;
  text-align: center;
  width: 500px;
  height: 90vh;
  margin: 5vh auto;
  background-color: #fff;
}

.chat-bot-box {
  position: relative;
  z-index: 10;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  background-color: #fff;
}

@media screen and (max-width: 980px) {
  .chat-bot-box {
    position: fixed;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    transform: none;
  }
}
</style>

3. use Vue(SSR mode)

<template>
  <div class="main">
    <div class="chat-bot-box" id="rootATS" />
  </div>
</template>

<script>
let PHChatBot
if (typeof window !== 'undefined') {
  // Ensure that the window object has been defined. Otherwise you will encounter window is not defined error
  PHChatBot = require('@predictivehire/phchatbot')
}
export default {
  name: 'HelloWorld',
  mounted: () => {
    // for assessmentId you can contact PredictiveHire for more information, so do appId and region
    const appId = "appId"
    const assessmentId = "assessmentId"
    const region = "region" // need to confirm with PredictiveHire
    const env = "qa" // this one is used to decide which domain name to use to initiate an api request

    const chatbotATS = new PHChatBot.PHChatBot({
      appId: appId,
      region: region, // need to confirm with PredictiveHire
      env: env, // this one is used to decide which domain name to use to initiate an api request
      assessmentId: assessmentId
    })

    // developers can add the event callback they want
    chatbotATS.addCallbackHandler({
      FI_ASSESSMENT_STARTED: payload => {
        console.info(payload)
      },
      FI_ASSESSMENT_ANSWER_SAVED: payload => {
        console.info(payload)
      },
      FI_ASSESSMENT_ENDED: assessmentId => {
        console.info(assessmentId)
      }
    })
    chatbotATS.setTheme({
      theme: {
        question: {
          backgroundColor: "#ef8200",
          fontColor: "#fff"
        }
      }
    })
    chatbotATS.attachTo({ selector: "#rootATS" })
  }
}
</script>

<style scoped>
.main {
  position: relative;
  text-align: center;
  width: 500px;
  height: 90vh;
  margin: 5vh auto;
  background-color: #fff;
}

.chat-bot-box {
  position: relative;
  z-index: 10;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  background-color: #fff;
}

@media screen and (max-width: 980px) {
  .chat-bot-box {
    position: fixed;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    transform: none;
  }
}
</style>

Params

| param | desc | | ---- | ---- | | env | enum(local, qa, sandbox, product) For third-party developers, qa or sandbox will be good for development, and use product for online environments, different value of env will be call the apis with different domain | | appId | string, used to retrieve cross-domain whitelist. Pls contact PredictiveHire for more information(https://www.predictivehire.com/) | | region | string, PredictiveHire will provide API endpoint with different regions for different customers. Pls contact PredictiveHire for more information(https://www.predictivehire.com/) | | assessmentId | This one is generate by PredictiveHire. Pls contact PredictiveHire for more information(https://www.predictivehire.com/) |

API

| API | definition | desc | | ---- | ---- | ---- | | attachTo | ({ selector, index }: { selector: string; index?: number; }) => void | This selector must be a valid CSS selector string. the default value of index is 0, which means when multiple qualified doms are matched, the index element in the domList should be selected | | addCallbackHandler | (callbacks: PHChatBotCallback): => void | Developers can add the event callback they want. The callBack functions will be called in corresponding stage. You can check the PHChatBotCallback below | | setTheme | ({ theme }: { theme: Theme; }) => void | You can use this api to customized theme color, the complete data structure is as follows |

Params Type

Theme

{
  hint: {
    backgroundColor: string
    fontColor: string
  },
  question: {
    backgroundColor: string
    fontColor: string
  },
  response: {
    backgroundColor: string
    fontColor: string
  },
  listItem: {
    backgroundColor: string
    fontColor: string
  },
  selectedItem: {
    backgroundColor: string
    fontColor: string
  },
  button: {
    backgroundColor: string
    fontColor: string
  }
}

PHChatBotCallback

{
  FI_ASSESSMENT_STARTED: (payload: {
    assessmentId
    chatLogs
    branding
  }) => void;
  FI_ASSESSMENT_ANSWER_SAVED: (payload: {
    assessmentId: string
    question: string
    answer: string
    types: string[]
  }) => void;
  FI_ASSESSMENT_ENDED: (payload: { assessmentId: string }) => void;
}