chatbot-api-service
v1.0.37
Published
It is to call chatbot service from API
Readme
Chatbot Service
Chatbot Service is a service which help you to interact with Amazon Lex Bot via Amazon Apigateway.
Installation
npm i chatbot-api-serviceUsage
import { ChatbotService } from "chatbot-api-service";
const chatservice = new ChatbotService();
const apikey = 'xxxxxxx';
const apikeyLiveAgent = 'xxxxx';
const apiURL = 'xxxxxxxx';
const apiUrlLiveAgent = 'xxxxxxxxxxx'
const chatbotId = 'xxxxxxxx';
const sessionId = 'xxxxxxxx';
chatservice.setAttribute(apiURL, apikey, chatbotId, sessionId);
chatservice.sendMessageToBot(
"Test Message", typeof sessionDetails === 'object' && Object.keys(sessionDetails).length > 0 ? sessionDetails : '', typeof seesionAtribb === 'object' && Object.keys(seesionAtribb).length > 0 ? seesionAtribb : '', typeof userInfo === 'object' && Object.keys(userInfo).length > 0 ? userInfo : ''
).then((data) => {
console.log(data); // data from bot
}).catch((err) => {
console.log(error); // error from bot
});Props
| Prop name | Description | Type | Default value |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------- |
| setChatbotAttributes | To set chat bot attributes (apiURL: string, chatbotId: string, sessionId: string, apikey?: string) | function | none |
| setLiveAgentAttributes | To set live agent attributes (apiUrlLiveAgent: string, apikeyliveAgent?: string) | function | none |
| sendMessageToBot | To send message to bot (message: string, sessionDetails: any = null, sessionAttributes: any = null, userInfo: any = null) | function | none |
| liveAgentMessage | To fetch live agent messages (sfKeys: any, recievedFirstCard: boolean) | function | none |
