@negotiate-gpt/chat
v0.3.4
Published
Chat Logic handler for Negotiate-GPT
Downloads
11
Readme
@negotiate-gpt/chat
This package handles conversations with the Negotiate-GPT platform.
Installation
npm install negotiate-gpt@chat
or
yarn add negotiate-gpt@chat
Usage
RegisteredChat
This class handles conversations with deployed chatbots and pre-existing surveys.
No authentication is needed for a registered chat.
Import the class
import { RegisteredChat } from 'negotiate-gpt@chat'
Create a new chat
const chat = new RegisteredChat([endpoint], [botID],[surveyID],[responseID],[onStartTyping],[onMessage],[onEndTyping],[onDone])
Send a message
chat.message([message])
to catch errors,
chat.message([message]).catch((err) => { console.log(err) })
Only one message can be sent at a time
To wait for a message to finish sending
await chat.message([message])
UnregisteredChat
This class handles conversations with chatbots that are not in the database.
Authentication is needed for an unregistered chat.
Import the class
import { UnregisteredChat } from 'negotiate-gpt@chat'
Create a new chat
const chat = new UnregisteredChat([endpoint],[botConfig],[firebase credential],[surveyID],[onStartTyping],[onMessage],[onEndTyping],[onDone])
The Survey ID must start with [user's UID]-
Send a message
chat.message([message])
to catch errors,
chat.message([message]).catch((err) => { console.log(err) })
Only one message can be sent at a time
To wait for a message to finish sending
await chat.message([message])