Skip to content

Latest commit

 

History

History
124 lines (72 loc) · 2.76 KB

API.md

File metadata and controls

124 lines (72 loc) · 2.76 KB

constructor

Parameters

getBotName

Returns a Promise that resolves with bot name

Parameters

  • hookURL string (optional, default this.configuration.hookURL)
  • apiKey string (optional, default this.configuration.apiKey)

Returns Promise<(Response | never)>

init

  • Initialises the widget
  • Resolves promise on connection success with botName and history
  • Rejects promise if it fails

Returns Promise<object> where object = {botName: string, history: Array[{content: string, made_by: string}]}

onMessage

Set callback for incoming messages

Parameters

  • callback function callback for incoming messages

send

Sends a message if connected, else queues it

Parameters

initiateConversation

  • To get the bot to say the intro message (if exists) without having the user to send a message first
  • Must be called after init

endSession

  • Closes socket connection for good
  • Clears callback references

clearSession

  • Ends session
  • Clears all data & cookie

onConnectionChange

Sets callback for connection change

Parameters

attachToPayload

  • Adds a property to the payload object
  • If the property already exists, its value will be overwritten

Parameters

detachFromPayload

Removes a property from the payload object

Parameters

setConversationLogging

Turn conversation logging on or off

Parameters

isConversationLogging

Check if conversation logging is on or off

Returns boolean

getUserId

Returns a promise that resolves if and when user_id_cookie is available

Returns Promise<string>

setMetadata

  • Adds a property to the metadata object in payload
  • If the property already exists, its value will be overwritten

Parameters