Skip to main content

Chatbot Plugin

The Chatbot plugin provides conversational flows for job applications and other interactions.

Installation

npm install @inploi/plugin-chatbot

Basic usage

import { initialiseSdk } from '@inploi/sdk';
import { chatbotPlugin } from '@inploi/plugin-chatbot';

const sdk = initialiseSdk({ publishableKey: 'pk_...', env: 'sandbox' });
const chatbot = sdk.register(chatbotPlugin({
  theme: { hue: 260, mode: 'light' },
}));

// Prepare UI eagerly (optional but recommended)
await chatbot.prepare();

// Fetch and open a flow by job ID
const flow = chatbot.fetchFlowByJobId('12345');
chatbot.open(flow);

Configuration

Theme

type ChatbotTheme = {
  hue: number;           // 0-360 color hue
  mode: 'light' | 'dark';
};

Feedback integration

Collect feedback after conversations:
import { feedbackPlugin } from '@inploi/plugin-feedback';

const chatbot = sdk.register(chatbotPlugin({
  feedback: {
    plugin: feedbackPlugin(),
    params: {
      terms: {
        negative_heading: "We're sorry to hear that. What went wrong?",
      },
    },
  },
}));

Custom terms

Override default UI text:
const chatbot = sdk.register(chatbotPlugin({
  terms: {
    send: 'Submit',
    skip: 'Skip this',
    undo: 'Go back',
  },
}));

API

prepare()

Preloads UI assets. Optional but recommended to avoid delays.
await chatbot.prepare();

open(flow)

Opens the chatbot with a flow (or a promise that resolves to a flow).
chatbot.open(flow);

close()

Closes the chatbot.
chatbot.close();

fetchFlowByJobId(jobId)

Fetches a conversation flow for a specific job.
const flow = chatbot.fetchFlowByJobId('12345');

fetchFlowById(flowId)

Fetches a conversation flow by its ID.
const flow = chatbot.fetchFlowById('flow_abc123');