{"id":22031548,"url":"https://github.com/flow-ai/flowai-js","last_synced_at":"2025-06-21T12:36:42.463Z","repository":{"id":19608610,"uuid":"74519170","full_name":"flow-ai/flowai-js","owner":"flow-ai","description":"Flow.ai JavaScript SDK","archived":false,"fork":false,"pushed_at":"2025-01-06T07:59:48.000Z","size":1889,"stargazers_count":17,"open_issues_count":27,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-11T21:11:33.994Z","etag":null,"topics":["api-client","chatbot","flowai","nodejs","sdk","socket"],"latest_commit_sha":null,"homepage":"https://flow.ai","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flow-ai.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-22T22:33:01.000Z","updated_at":"2025-02-24T08:27:50.000Z","dependencies_parsed_at":"2022-07-23T13:02:26.050Z","dependency_job_id":"ab58edcf-3371-4761-8d2a-ca065961d23b","html_url":"https://github.com/flow-ai/flowai-js","commit_stats":{"total_commits":108,"total_committers":9,"mean_commits":12.0,"dds":"0.40740740740740744","last_synced_commit":"82d24b3db2ec0f443c4b844790e2f2fcec1c8a36"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/flow-ai/flowai-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flow-ai%2Fflowai-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flow-ai%2Fflowai-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flow-ai%2Fflowai-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flow-ai%2Fflowai-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flow-ai","download_url":"https://codeload.github.com/flow-ai/flowai-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flow-ai%2Fflowai-js/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261125731,"owners_count":23113279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","chatbot","flowai","nodejs","sdk","socket"],"created_at":"2024-11-30T08:19:09.982Z","updated_at":"2025-06-21T12:36:37.445Z","avatar_url":"https://github.com/flow-ai.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The flow.ai Javascript SDK\nAccess the [flow.ai](https://flow.ai) platform from your Node.js or javascript app. This library lets you build on the flow.ai Webclient API.\n\n## What can you do?\n\n*\tA simple way to connect with [flow.ai](https://flow.ai)\n* Auto reconnect and event binding\n*\tSend and receive messages\n*\tTrigger actions and interact with AI bots\n\n## Usage\n\n### Installation\nRun `npm install --save flowai-js`\n\n### Simple Node.js example\n\n```js\nconst {\n  LiveClient,\n  Message,\n  Originator\n} = require(\"flowai-js\")\n\n// Create a new live client\nconst client = new LiveClient({\n  clientId: 'YOUR CLIENT ID HERE',\n  origin: 'https://my.site'\n})\n\n// Fired whenever the client connects\nclient.on(LiveClient.CONNECTED, () =\u003e {\n\n  console.log('--\u003e Connected')\n\n  // Create the originator of the message\n  const originator = new Originator({\n    name: \"Boss\"\n  })\n\n  // Create a Message\n  const message = new Message({\n    // Thread Id limits the message just to John\n    threadId: 'john',\n    // The text to send\n    speech: \"Behold, I'm pure awesomeness!\",\n    // Person or system sending the message\n    originator\n  })\n\n  // Send\n  client.send(message)\n})\n\n// Start the connection\nclient.start()\n```\n\n### Advanced Node.js example\nIn this example you'll notice all events that are available\n\n```js\nconst {\n  LiveClient,\n  Message,\n  Originator\n} = require(\"flowai-js\")\n\n// Create a new live client\nconst client = new LiveClient({\n  // Unique clientId copy \u0026 paste from Flow.ai dashboard\n  clientId: 'YOUR CLIENT ID HERE',\n\n  // When limiting to whitelisted domains, specify this\n  origin: 'https://my.site'\n})\n\nclient.on(LiveClient.CONNECTED, () =\u003e {\n  const originator = new Originator({\n    name: \"Boss\"\n  })\n\n  const message = new Message({\n    // Thread Id limits the message just to John\n    threadId: 'john',\n    // Use the traceId to identify message\n    // being marked as delivered\n    traceId: 1,\n    speech: \"Behold, I'm pure awesomeness!\",\n    originator\n  })\n\n  client.send(message)\n})\n\nclient.on(LiveClient.MESSAGE_DELIVERED, message =\u003e {\n  // The message we have send has been delivered\n  // check the traceId to see what message has been\n  // delivered since it's an async method\n})\n\nclient.on(LiveClient.REPLY_RECEIVED, message =\u003e {\n  // Called when a bot or human operator\n  // sends a message or reply\n  if(message.threadId === 'john') {\n    // Incoming message for John\n  } else {\n    // Incoming message for another user\n  }\n})\n\nclient.on(LiveClient.ERROR, err =\u003e {\n  // This handler will be fired whenever an error\n  // occurs during the connection\n  console.error('Something bad happened', err)\n})\n\nclient.on(LiveClient.DISCONNECTED, () =\u003e {\n  // The client has been disconnected\n})\n\nclient.on(LiveClient.MESSAGE_SEND, message =\u003e {\n  // Called whenever the client sends a message\n})\n\nclient.on(LiveClient.RECONNECTING, () =\u003e {\n  // Called when the client tries to reconnect\n})\n\nclient.start()\n```\n\n### Simple browser example\nUsing the library within the browser is pretty much the same as the Node.js examples.\n\nThere is one notable difference, all classes live inside a `Flowai` object.\n\n#### Include the script\n```html\n\u003cscript src=\"flowai-js.min.js\"\u003e\u003c/script\u003e\n```\n\n#### Usage\n\n```js\nvar client = new Flowai.LiveClient('YOUR CLIENT ID HERE');\nclient.on(LiveClient.CONNECTED, function(){\n  var originator = new Flowai.Originator({ fullName: \"John Doo\" });\n\n  var message = new Flowai.Message({\n    threadId: 'john',\n    traceId: 1,\n    speech: \"Behold, I'm pure awesomeness!\",\n    originator\n  });\n\n  client.send(message);\n})\n\nclient.start();\n```\n\n### Notes on using with webpack\nThe library can be easily used with webpack. You'll probably receive an error though involving `fs`.\n\nAdd the following to your webpack config file:\n```\nnode: {\n  fs: 'empty'\n},\n```\n\n## Identifying messages\nThe SDK is pretty flexible with regard to how messages are delivered and grouped. To do this we use two unique keys: sessionId and threadId.\n\n![ThreadId](/media/unique-threadid.png)\n\n### threadId\nA threadId is a unique key representing a channel, room, or user. If you have a single connection running for multiple clients, all using the same threadId, they will all receive the same messages.\n\n![Unique sessionIds](/media/unique-sessionid.png)\n\n### sessionId\nThe sessionId is used to identify connections from different devices like browsers or Node.js servers. Each connection is partly identified on our end using this key.\n\n![Unique sessions and threadids](/media/unique-sessionid-threadid.png)\n\n# Full API Reference\n## Classes\n\n\u003cdl\u003e\n\u003cdt\u003e\u003ca href=\"#EventAttachment\"\u003eEventAttachment\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eTrigger events\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#Exception\"\u003eException\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eException\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#FileAttachment\"\u003eFileAttachment\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eSend a file as attachment\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#FlowAttachment\"\u003eFlowAttachment\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eTrigger flows\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#LiveClient\"\u003eLiveClient\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eLive streaming websocket client extends EventEmitter\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#Message\"\u003eMessage\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eMessage you send to Flow.ai\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#Metadata\"\u003eMetadata\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eAdditional Message data\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#OpeningAttachment\"\u003eOpeningAttachment\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eTrigger opening events\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#OpeningFlowAttachment\"\u003eOpeningFlowAttachment\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eTrigger flow as opening events\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#Originator\"\u003eOriginator\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eOriginator of a Message\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#Reply\"\u003eReply\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eReply you receive from Flow.ai\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#StepAttachment\"\u003eStepAttachment\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eTrigger steps\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\n## Functions\n\n\u003cdl\u003e\n\u003cdt\u003e\u003ca href=\"#_setCookie\"\u003e_setCookie(name, value)\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#_getCookie\"\u003e_getCookie(name)\u003c/a\u003e ⇒ \u003ccode\u003estring\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003c/dd\u003e\n\u003c/dl\u003e\n\n\u003ca name=\"EventAttachment\"\u003e\u003c/a\u003e\n\n## EventAttachment\nTrigger events\n\n\u003ca name=\"new_EventAttachment_new\"\u003e\u003c/a\u003e\n\n### new EventAttachment(name, [label])\n\n| Param | Type | Description |\n| --- | --- | --- |\n| name | \u003ccode\u003estring\u003c/code\u003e | Name of the event to trigger |\n| [label] | \u003ccode\u003estring\u003c/code\u003e | Optional human readable label for the triggered event |\n\nConstructor\n\n**Example**  \n```js\n// Event without any label\nconst message = new Message({\n  attachment: new EventAttachment('BUY')\n})\n```\n**Example**  \n```js\n// Event with label to display user\nconst message = new Message({\n  attachment: new EventAttachment('BUY', 'Buy dress')\n})\n```\n\u003ca name=\"Exception\"\u003e\u003c/a\u003e\n\n## Exception\n**Properties**\n\n| Name | Type | Description |\n| --- | --- | --- |\n| message | \u003ccode\u003estring\u003c/code\u003e | Human friendly message |\n| type | \u003ccode\u003estring\u003c/code\u003e | Kind of error |\n| innerException | [\u003ccode\u003eException\u003c/code\u003e](#Exception) | Inner exception |\n| isFinal | \u003ccode\u003eboolean\u003c/code\u003e | Prevent further execution |\n\nException\n\n\u003ca name=\"new_Exception_new\"\u003e\u003c/a\u003e\n\n### new Exception(message, type, innerException, isFinal)\n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| message | \u003ccode\u003estring\u003c/code\u003e |  | message - Human friendly message |\n| type | \u003ccode\u003estring\u003c/code\u003e |  | Kind of error |\n| innerException | [\u003ccode\u003eException\u003c/code\u003e](#Exception) |  | Optional inner exception |\n| isFinal | \u003ccode\u003eboolean\u003c/code\u003e | \u003ccode\u003efalse\u003c/code\u003e | Indicates if this exception prevents further execution |\n\nConstructor\n\n\u003ca name=\"FileAttachment\"\u003e\u003c/a\u003e\n\n## FileAttachment\nSend a file as attachment\n\n\u003ca name=\"new_FileAttachment_new\"\u003e\u003c/a\u003e\n\n### new FileAttachment(data)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| data | \u003ccode\u003eFile\u003c/code\u003e \\| \u003ccode\u003eReadStream\u003c/code\u003e | File or Blob in the browser, ReadStream in Nodejs |\n\nConstructor\n\n**Example**  \n```js\n// Web example\n\nvar originator = new Originator({\n  name: 'Jane'\n})\n\nvar file = fileInputElement.files[0]\n\nconst message = new Message({\n  attachment: new FileAttachment(file)\n})\n\nclient.send(message)\n```\n**Example**  \n```js\n// Nodejs example\nimport { createReadStream } from 'fs'\n\nconst originator = new Originator({\n  name: 'Jane'\n})\n\n// Load ReadStream from file on disk\nconst data = fs.createReadStream('/foo/bar.jpg')\n\nconst message = new Message({\n  attachment: new FileAttachment(data)\n})\n\nclient.send(message)\n```\n\u003ca name=\"FlowAttachment\"\u003e\u003c/a\u003e\n\n## FlowAttachment\nTrigger flows\n\n\u003ca name=\"new_FlowAttachment_new\"\u003e\u003c/a\u003e\n\n### new FlowAttachment(flowImmutableId)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| flowImmutableId | \u003ccode\u003estring\u003c/code\u003e | Immutable flowId of the flow to trigger |\n\nConstructor\n\n**Example**  \n```js\nconst message = new Message({\n  attachment: new FlowAttachment(flowImmutableId)\n})\n```\n\u003ca name=\"LiveClient\"\u003e\u003c/a\u003e\n\n## LiveClient\nLive streaming websocket client extends EventEmitter\n\n\n* [LiveClient](#LiveClient)\n\n    * [new LiveClient(opts)](#new_LiveClient_new)\n\n    * _instance_\n        * [.sessionId](#LiveClient+sessionId)\n\n        * [.threadId](#LiveClient+threadId)\n\n        * [.threadId](#LiveClient+threadId)\n\n        * [.secret](#LiveClient+secret)\n\n        * [.secret](#LiveClient+secret)\n\n        * [.isConnected](#LiveClient+isConnected)\n\n        * [.sessionId()](#LiveClient+sessionId)\n\n        * [.start(threadId, sessionId)](#LiveClient+start)\n\n        * [.stop()](#LiveClient+stop)\n\n        * [.destroy()](#LiveClient+destroy)\n\n        * [.send(message)](#LiveClient+send)\n\n        * [.merger(mergerKey, threadId, sessionId)](#LiveClient+merger)\n\n        * [.history(threadId)](#LiveClient+history)\n\n        * [.noticed(threadId, instantly)](#LiveClient+noticed)\n\n        * [.checkUnnoticed(threadId)](#LiveClient+checkUnnoticed)\n\n        * [.log(text)](#LiveClient+log)\n\n    * _static_\n        * [.ERROR](#LiveClient.ERROR)\n\n        * [.CONNECTED](#LiveClient.CONNECTED)\n\n        * [.RECONNECTING](#LiveClient.RECONNECTING)\n\n        * [.DISCONNECTED](#LiveClient.DISCONNECTED)\n\n        * [.REPLY_RECEIVED](#LiveClient.REPLY_RECEIVED)\n\n        * [.AGENT_TYPING_RECEIVED](#LiveClient.AGENT_TYPING_RECEIVED)\n\n        * [.MESSAGE_SEND](#LiveClient.MESSAGE_SEND)\n\n        * [.MESSAGE_DELIVERED](#LiveClient.MESSAGE_DELIVERED)\n\n        * [.REQUESTING_HISTORY](#LiveClient.REQUESTING_HISTORY)\n\n        * [.NO_HISTORY](#LiveClient.NO_HISTORY)\n\n        * [.RECEIVED_HISTORY](#LiveClient.RECEIVED_HISTORY)\n\n        * [.CHECKED_UNNOTICED_MESSAGES](#LiveClient.CHECKED_UNNOTICED_MESSAGES)\n\n        * [.INTERRUPTION_OCCURRED](#LiveClient.INTERRUPTION_OCCURRED)\n\n\n\u003ca name=\"new_LiveClient_new\"\u003e\u003c/a\u003e\n\n### new LiveClient(opts)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| opts | \u003ccode\u003eobject\u003c/code\u003e \\| \u003ccode\u003estring\u003c/code\u003e | Configuration options or shorthand for just clientId |\n| opts.clientId | \u003ccode\u003estring\u003c/code\u003e | Mandatory Client token |\n| opts.storage | \u003ccode\u003estring\u003c/code\u003e | Optional, 'session' for using sessionStorage, 'local' for localStorage or `memory` for a simple memory store |\n| opts.endpoint | \u003ccode\u003estring\u003c/code\u003e | Optional, only for testing purposes |\n| opts.origin | \u003ccode\u003estring\u003c/code\u003e | When running on Nodejs you MUST set the origin |\n| opts.silent | \u003ccode\u003eboolean\u003c/code\u003e | Optional, console.errors will not be shown |\n| opts.ott | \u003ccode\u003estring\u003c/code\u003e | Optional, console.errors will not be shown |\n\nConstructor\n\n**Example**  \n```js\n// Node.js\nconst client = new LiveClient({\n  clientId: 'MY CLIENT ID',\n  origin: 'https://my.website'\n})\n\n// Web\nconst client = new LiveClient({\n  clientId: 'MY CLIENT ID',\n  storage: 'session'\n})\n\n// Lambda function\nconst client = new LiveClient({\n  clientId: 'MY CLIENT ID',\n  storage: 'memory'\n})\n```\n\u003ca name=\"LiveClient+sessionId\"\u003e\u003c/a\u003e\n\n### *liveClient*.sessionId\n\n| Param | Type | Description |\n| --- | --- | --- |\n| value | \u003ccode\u003estring\u003c/code\u003e | Change the session ID |\n\nSession Id of the connection\n\n\u003ca name=\"LiveClient+threadId\"\u003e\u003c/a\u003e\n\n### *liveClient*.threadId\nDefault Thread Id to be used for any messages being send\n\n**Returns**: \u003ccode\u003estring\u003c/code\u003e - Null if no connection is active  \n\u003ca name=\"LiveClient+threadId\"\u003e\u003c/a\u003e\n\n### *liveClient*.threadId\n\n| Param | Type | Description |\n| --- | --- | --- |\n| value | \u003ccode\u003estring\u003c/code\u003e | Change the thread ID |\n\nSession Id of the connection\n\n\u003ca name=\"LiveClient+secret\"\u003e\u003c/a\u003e\n\n### *liveClient*.secret\nSecret\n\n\u003ca name=\"LiveClient+secret\"\u003e\u003c/a\u003e\n\n### *liveClient*.secret\n\n| Param | Type | Description |\n| --- | --- | --- |\n| value | \u003ccode\u003estring\u003c/code\u003e | Change the Secret |\n\nSecret\n\n\u003ca name=\"LiveClient+isConnected\"\u003e\u003c/a\u003e\n\n### *liveClient*.isConnected\nCheck if the connection is active\n\n**Returns**: \u003ccode\u003eboolean\u003c/code\u003e - True if the connection is active  \n**Example**  \n```js\nif(client.isConnected) {\n  // Do something awesome\n}\n```\n\u003ca name=\"LiveClient+sessionId\"\u003e\u003c/a\u003e\n\n### *liveClient*.sessionId()\nSession Id of the connection\n\n**Returns**: \u003ccode\u003estring\u003c/code\u003e - Null if no connection is active  \n\u003ca name=\"LiveClient+start\"\u003e\u003c/a\u003e\n\n### *liveClient*.start(threadId, sessionId)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| threadId | \u003ccode\u003estring\u003c/code\u003e | Optional. When assigned, this is the default threadId for all messages that are send |\n| sessionId | \u003ccode\u003estring\u003c/code\u003e | Optional. Must be unique for every connection |\n\nStart the client\n\n**Example**  \n```js\n// Start, will generate thread and sessionId\nclient.start()\n```\n**Example**  \n```js\n// Start with your own custom threadId\nclient.start('UNIQUE THREADID FOR USER')\n```\n\u003ca name=\"LiveClient+stop\"\u003e\u003c/a\u003e\n\n### *liveClient*.stop()\nUse this method to temp disconnect a client\n\n**Example**  \n```js\n// Close the connection\nclient.stop()\n```\n\u003ca name=\"LiveClient+destroy\"\u003e\u003c/a\u003e\n\n### *liveClient*.destroy()\nClose the connection and completely reset the client\n\n**Example**  \n```js\n// Close the connection and reset the client\nclient.destroy()\n```\n\u003ca name=\"LiveClient+send\"\u003e\u003c/a\u003e\n\n### *liveClient*.send(message)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| message | \u003ccode\u003eobject\u003c/code\u003e | Message you want to send |\n\nThis method triggers a `LiveClient.MESSAGE_SEND` event\n\n**Returns**: \u003ccode\u003eobject\u003c/code\u003e - Message that was send  \n**Example**  \n```js\nconst originator = new Originator({\n  name: \"Jane\"\n})\n\nconst message = new Message({\n speech: \"Hi!\",\n originator\n})\n\nclient.send(message)\n```\n\u003ca name=\"LiveClient+merger\"\u003e\u003c/a\u003e\n\n### *liveClient*.merger(mergerKey, threadId, sessionId)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| mergerKey | \u003ccode\u003estring\u003c/code\u003e | Unique token representing merge Request |\n| threadId | \u003ccode\u003estring\u003c/code\u003e | Optional. The threadId to merge |\n| sessionId | \u003ccode\u003estring\u003c/code\u003e | Optional. The sessionId to assign to the thread |\n\nMerge two threads from different channels.\nThis methods is not yet publicy supported since we don't have a way yet to provide a mergerKey.\n\n\u003ca name=\"LiveClient+history\"\u003e\u003c/a\u003e\n\n### *liveClient*.history(threadId)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| threadId | \u003ccode\u003estring\u003c/code\u003e | Optional. Specify the threadId to retreive historic messages |\n\nRequest historic messages\n\n**Example**  \n```js\n// Load any messages if there is a threadId\n// usefull when using with JS in the browser\nclient.history()\n\n// Load messages using a custom threadId\nclient.history('MY CUSTOM THREAD ID')\n```\n\u003ca name=\"LiveClient+noticed\"\u003e\u003c/a\u003e\n\n### *liveClient*.noticed(threadId, instantly)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| threadId | \u003ccode\u003estring\u003c/code\u003e | Optional. Specify the thread that is noticed |\n| instantly | \u003ccode\u003eboolean\u003c/code\u003e | Optional. Instantly send notice. Default is false |\n\nCall to mark a thread as noticed.\nThe library automatically throttles the number of calls\n\n**Example**  \n```js\n// Call that the client has seen all messages for the auto clientId\nclient.noticed()\n\n// Mark messages based on a custom threadId\nclient.noticed('MY CUSTOM THREAD ID')\n```\n\u003ca name=\"LiveClient+checkUnnoticed\"\u003e\u003c/a\u003e\n\n### *liveClient*.checkUnnoticed(threadId)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| threadId | \u003ccode\u003estring\u003c/code\u003e | Optional. Specify the thread to check unnoticed messags for |\n\nDid we miss any messages?\n\n\u003ca name=\"LiveClient+log\"\u003e\u003c/a\u003e\n\n### *liveClient*.log(text)\n\n| Param | Type |\n| --- | --- |\n| text | \u003ccode\u003estring\u003c/code\u003e | \n\n\u003ca name=\"LiveClient.ERROR\"\u003e\u003c/a\u003e\n\n### *LiveClient*.ERROR\nEvent that triggers when an error is received from the flow.ai platform\n\n\u003ca name=\"LiveClient.CONNECTED\"\u003e\u003c/a\u003e\n\n### *LiveClient*.CONNECTED\nEvent that triggers when client is connected with platform\n\n\u003ca name=\"LiveClient.RECONNECTING\"\u003e\u003c/a\u003e\n\n### *LiveClient*.RECONNECTING\nEvent that triggers when client tries to reconnect\n\n\u003ca name=\"LiveClient.DISCONNECTED\"\u003e\u003c/a\u003e\n\n### *LiveClient*.DISCONNECTED\nEvent that triggers when the client gets disconnected\n\n\u003ca name=\"LiveClient.REPLY_RECEIVED\"\u003e\u003c/a\u003e\n\n### *LiveClient*.REPLY_RECEIVED\nEvent that triggers when a new message is received from the platform\n\n\u003ca name=\"LiveClient.AGENT_TYPING_RECEIVED\"\u003e\u003c/a\u003e\n\n### *LiveClient*.AGENT_TYPING_RECEIVED\nEvent that triggers when start busy typing received from the platform\n\n\u003ca name=\"LiveClient.MESSAGE_SEND\"\u003e\u003c/a\u003e\n\n### *LiveClient*.MESSAGE_SEND\nEvent that triggers when the client is sending a message to the platform\n\n\u003ca name=\"LiveClient.MESSAGE_DELIVERED\"\u003e\u003c/a\u003e\n\n### *LiveClient*.MESSAGE_DELIVERED\nEvent that triggers when the send message has been received by the platform\n\n\u003ca name=\"LiveClient.REQUESTING_HISTORY\"\u003e\u003c/a\u003e\n\n### *LiveClient*.REQUESTING_HISTORY\nEvent that triggers when a request is made to load historic messages\n\n\u003ca name=\"LiveClient.NO_HISTORY\"\u003e\u003c/a\u003e\n\n### *LiveClient*.NO_HISTORY\nEvent that triggers when a request is made to load historic messages\n\n\u003ca name=\"LiveClient.RECEIVED_HISTORY\"\u003e\u003c/a\u003e\n\n### *LiveClient*.RECEIVED_HISTORY\nEvent that triggers when historic messages are received\n\n\u003ca name=\"LiveClient.CHECKED_UNNOTICED_MESSAGES\"\u003e\u003c/a\u003e\n\n### *LiveClient*.CHECKED_UNNOTICED_MESSAGES\nEvent that triggers when there are unnoticed messages\n\n\u003ca name=\"LiveClient.INTERRUPTION_OCCURRED\"\u003e\u003c/a\u003e\n\n### *LiveClient*.INTERRUPTION_OCCURRED\nEvent that triggers when there are unnoticed messages\n\n\u003ca name=\"Message\"\u003e\u003c/a\u003e\n\n## Message\n**Properties**\n\n| Name | Type | Description |\n| --- | --- | --- |\n| speech | \u003ccode\u003estring\u003c/code\u003e | Text representing the Message |\n| originator | [\u003ccode\u003eOriginator\u003c/code\u003e](#Originator) | Originator |\n| meta | [\u003ccode\u003eMetadata\u003c/code\u003e](#Metadata) | Meta data |\n| attachment | [\u003ccode\u003eAttachment\u003c/code\u003e](#new_Attachment_new) | Optional attachment |\n\nMessage you send to Flow.ai\n\n\n* [Message](#Message)\n\n    * [new Message(opts)](#new_Message_new)\n\n    * [.build(opts)](#Message.build)\n\n\n\u003ca name=\"new_Message_new\"\u003e\u003c/a\u003e\n\n### new Message(opts)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| opts | \u003ccode\u003eObject\u003c/code\u003e |  |\n| opts.traceId | \u003ccode\u003enumber\u003c/code\u003e | Optional unique integer you can match messages with |\n| opts.threadId | \u003ccode\u003estring\u003c/code\u003e | Optional unique id specific to this chat |\n| opts.speech | \u003ccode\u003estring\u003c/code\u003e | Text representing the Message |\n| opts.originator | [\u003ccode\u003eOriginator\u003c/code\u003e](#Originator) | Originator |\n| opts.metadata | [\u003ccode\u003eMetadata\u003c/code\u003e](#Metadata) | Meta data |\n| opts.attachment | [\u003ccode\u003eAttachment\u003c/code\u003e](#new_Attachment_new) | Attachment (optional) |\n\nConstructor\n\n\u003ca name=\"Message.build\"\u003e\u003c/a\u003e\n\n### *Message*.build(opts)\n\n| Param | Type |\n| --- | --- |\n| opts | \u003ccode\u003eobject\u003c/code\u003e | \n| opts.threadId | \u003ccode\u003estring\u003c/code\u003e | \n| opts.traceId | \u003ccode\u003estring\u003c/code\u003e | \n| opts.speech | \u003ccode\u003estring\u003c/code\u003e | \n| opts.originator | \u003ccode\u003eobject\u003c/code\u003e | \n| opts.metadata | \u003ccode\u003eobject\u003c/code\u003e | \n| opts.attachment | \u003ccode\u003eobject\u003c/code\u003e | \n\nFactory method\n\n\u003ca name=\"Metadata\"\u003e\u003c/a\u003e\n\n## Metadata\n**Properties**\n\n| Name | Type | Description |\n| --- | --- | --- |\n| language | \u003ccode\u003estring\u003c/code\u003e | Language the message is ib |\n| timezone | \u003ccode\u003enumber\u003c/code\u003e | UTC time offset in hours |\n| params | \u003ccode\u003eObject\u003c/code\u003e | Parameters to send with the message |\n| domain | \u003ccode\u003eObject\u003c/code\u003e | Browser or server environment variables like origin |\n\nAdditional Message data\n\n\n* [Metadata](#Metadata)\n\n    * [new Metadata(language, timezone, params)](#new_Metadata_new)\n\n    * _instance_\n        * ~~[.addContext()](#Metadata+addContext)\n~~\n    * _static_\n        * [.build(metadata)](#Metadata.build)\n\n\n\u003ca name=\"new_Metadata_new\"\u003e\u003c/a\u003e\n\n### new Metadata(language, timezone, params)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| language | \u003ccode\u003estring\u003c/code\u003e | Specify the language of the message |\n| timezone | \u003ccode\u003enumber\u003c/code\u003e | Specify the timezone of the message |\n| params | \u003ccode\u003eObject\u003c/code\u003e | Additional data to be send |\n\nConstructor\n\n\u003ca name=\"Metadata+addContext\"\u003e\u003c/a\u003e\n\n### ~~*metadata*.addContext()~~\n***Deprecated***\n\n\u003ca name=\"Metadata.build\"\u003e\u003c/a\u003e\n\n### *Metadata*.build(metadata)\n\n| Param | Type |\n| --- | --- |\n| metadata | \u003ccode\u003eObject\u003c/code\u003e | \n\nCreate a Metadata object from raw data\n\n\u003ca name=\"OpeningAttachment\"\u003e\u003c/a\u003e\n\n## OpeningAttachment\nTrigger opening events\n\n\u003ca name=\"new_OpeningAttachment_new\"\u003e\u003c/a\u003e\n\n### new OpeningAttachment(name, [label])\n\n| Param | Type | Description |\n| --- | --- | --- |\n| name | \u003ccode\u003estring\u003c/code\u003e | Name of the event to trigger |\n| [label] | \u003ccode\u003estring\u003c/code\u003e | Optional human readable label for the triggered event |\n\nConstructor\n\n**Example**  \n```js\n// Opening event without any label\nconst message = new Message({\n  attachment: new OpeningAttachment('BUY')\n})\n```\n**Example**  \n```js\n// Opening event with label to display user\nconst message = new Message({\n  attachment: new OpeningAttachment('BUY', 'Buy dress')\n})\n```\n\u003ca name=\"OpeningFlowAttachment\"\u003e\u003c/a\u003e\n\n## OpeningFlowAttachment\nTrigger flow as opening events\n\n\u003ca name=\"new_OpeningFlowAttachment_new\"\u003e\u003c/a\u003e\n\n### new OpeningFlowAttachment(flowImmutableId, [label])\n\n| Param | Type | Description |\n| --- | --- | --- |\n| flowImmutableId | \u003ccode\u003estring\u003c/code\u003e | FlowImmutableId of the flow to trigger |\n| [label] | \u003ccode\u003estring\u003c/code\u003e | Optional human readable label for the triggered event |\n\nConstructor\n\n**Example**  \n```js\n// Opening event without any label\nconst message = new Message({\n  attachment: new OpeningFlowAttachment(flowImmutableId)\n})\n```\n\u003ca name=\"Originator\"\u003e\u003c/a\u003e\n\n## Originator\n**Properties**\n\n| Name | Type | Description |\n| --- | --- | --- |\n| name | \u003ccode\u003estring\u003c/code\u003e | Name of a person or system originating the Message, default is Anonymous |\n| role | \u003ccode\u003estring\u003c/code\u003e | The role of the person. You cannot set this, default is external |\n| profile | \u003ccode\u003eObject\u003c/code\u003e | Contains profile info |\n| profile.fullName | \u003ccode\u003estring\u003c/code\u003e | First and surname combined |\n| profile.firstName | \u003ccode\u003estring\u003c/code\u003e | First name of the person |\n| profile.lastName | \u003ccode\u003estring\u003c/code\u003e | Last name of the person |\n| profile.email | \u003ccode\u003estring\u003c/code\u003e | E-mail address |\n| profile.description | \u003ccode\u003estring\u003c/code\u003e | Description of this user |\n| profile.picture | \u003ccode\u003estring\u003c/code\u003e | Profile picture (url) |\n| profile.locale | \u003ccode\u003estring\u003c/code\u003e | ISO code describing language and country (en-US) |\n| profile.timezone | \u003ccode\u003enumber\u003c/code\u003e | Hours from GMT |\n| profile.location | \u003ccode\u003estring\u003c/code\u003e | Location of the user |\n| profile.gender | \u003ccode\u003estring\u003c/code\u003e | M for male, F for female or U for unknown / other |\n| metadata | \u003ccode\u003eobject\u003c/code\u003e | Optional object with custom metadata |\n\nOriginator of a Message\n\n\u003ca name=\"new_Originator_new\"\u003e\u003c/a\u003e\n\n### new Originator(opts)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| opts | \u003ccode\u003eObject\u003c/code\u003e |  |\n| opts.name | \u003ccode\u003estring\u003c/code\u003e | Name of a person or system originating the Message, default is Anonymous |\n| opts.role | \u003ccode\u003estring\u003c/code\u003e | The role of the person. You cannot set this, default is external |\n| opts.profile | \u003ccode\u003eObject\u003c/code\u003e | Contains profile info |\n| opts.profile.fullName | \u003ccode\u003estring\u003c/code\u003e | First and surname combined |\n| opts.profile.firstName | \u003ccode\u003estring\u003c/code\u003e | First name of the person |\n| opts.profile.lastName | \u003ccode\u003estring\u003c/code\u003e | Last name of the person |\n| opts.profile.email | \u003ccode\u003estring\u003c/code\u003e | E-mail address |\n| opts.profile.description | \u003ccode\u003estring\u003c/code\u003e | Description of this user |\n| opts.profile.picture | \u003ccode\u003estring\u003c/code\u003e | Profile picture (url) |\n| opts.profile.locale | \u003ccode\u003estring\u003c/code\u003e | ISO code describing language and country (en-US) |\n| opts.profile.timezone | \u003ccode\u003enumber\u003c/code\u003e | Hours from GMT |\n| opts.profile.location | \u003ccode\u003estring\u003c/code\u003e | Location of the user |\n| opts.profile.gender | \u003ccode\u003estring\u003c/code\u003e | M for male, F for female or U for unknown / other |\n| opts.metadata | \u003ccode\u003eobject\u003c/code\u003e | Optional object with custom metadata |\n\n\u003ca name=\"Reply\"\u003e\u003c/a\u003e\n\n## Reply\n**Properties**\n\n| Name | Type | Description |\n| --- | --- | --- |\n| threadId | \u003ccode\u003estring\u003c/code\u003e | Unique id specific to this chat |\n| originator | [\u003ccode\u003eOriginator\u003c/code\u003e](#Originator) | Originator |\n| messages | \u003ccode\u003e[ \u0026#x27;Array\u0026#x27; ].\u0026lt;ReplyMessage\u0026gt;\u003c/code\u003e | List of messages |\n| messages[].fallback | \u003ccode\u003estring\u003c/code\u003e | Textual representation of any responses |\n| messages[].replyTo | \u003ccode\u003estring\u003c/code\u003e | Optional replying to query |\n| messages[].contexts | \u003ccode\u003earray\u003c/code\u003e | Optional List of context names |\n| messages[].params | \u003ccode\u003earray\u003c/code\u003e | Optional key value pair of parameters |\n| messages[].intents | \u003ccode\u003earray\u003c/code\u003e | Optional list of intent names determined |\n| messages[].responses | \u003ccode\u003e[ \u0026#x27;Array\u0026#x27; ].\u0026lt;Response\u0026gt;\u003c/code\u003e | List of response templates |\n| messages[].responses[].type | \u003ccode\u003estring\u003c/code\u003e | Template type |\n| messages[].responses[].payload | \u003ccode\u003eObject\u003c/code\u003e | Template payload |\n| messages[].responses[].delay | \u003ccode\u003eNumber\u003c/code\u003e | Number of seconds the response is delayed |\n\nReply you receive from Flow.ai\n\n\u003ca name=\"new_Reply_new\"\u003e\u003c/a\u003e\n\n### new Reply()\nConstructor\n\n\u003ca name=\"StepAttachment\"\u003e\u003c/a\u003e\n\n## StepAttachment\nTrigger steps\n\n\u003ca name=\"new_StepAttachment_new\"\u003e\u003c/a\u003e\n\n### new StepAttachment(stepId)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| stepId | \u003ccode\u003estring\u003c/code\u003e | Immutable stepId of the step to trigger |\n\nConstructor\n\n**Example**  \n```js\nconst message = new Message({\n  attachment: new StepAttachment(stepId)\n})\n```\n\u003ca name=\"_setCookie\"\u003e\u003c/a\u003e\n\n## _setCookie(name, value)\n\n| Param | Type |\n| --- | --- |\n| name | \u003ccode\u003estring\u003c/code\u003e | \n| value | \u003ccode\u003estring\u003c/code\u003e | \n\n\u003ca name=\"_getCookie\"\u003e\u003c/a\u003e\n\n## _getCookie(name)\n\n| Param | Type |\n| --- | --- |\n| name | \u003ccode\u003estring\u003c/code\u003e | \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflow-ai%2Fflowai-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflow-ai%2Fflowai-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflow-ai%2Fflowai-js/lists"}