{"id":28322670,"url":"https://github.com/takenet/blip-sdk-js","last_synced_at":"2025-06-23T21:31:37.858Z","repository":{"id":26327343,"uuid":"104934333","full_name":"takenet/blip-sdk-js","owner":"takenet","description":"The Javascript SDK for BLiP","archived":false,"fork":false,"pushed_at":"2025-05-09T13:21:05.000Z","size":730,"stargazers_count":33,"open_issues_count":24,"forks_count":12,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-06-01T22:45:18.866Z","etag":null,"topics":["blip","blip-sdk","chatbot"],"latest_commit_sha":null,"homepage":"https://blip.ai","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/takenet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2017-09-26T20:27:15.000Z","updated_at":"2025-05-05T12:31:39.000Z","dependencies_parsed_at":"2025-05-09T19:15:53.630Z","dependency_job_id":null,"html_url":"https://github.com/takenet/blip-sdk-js","commit_stats":{"total_commits":149,"total_committers":23,"mean_commits":6.478260869565218,"dds":0.7651006711409396,"last_synced_commit":"c26ec84942e732657aeee716926c69a23d9ec75d"},"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"purl":"pkg:github/takenet/blip-sdk-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takenet%2Fblip-sdk-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takenet%2Fblip-sdk-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takenet%2Fblip-sdk-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takenet%2Fblip-sdk-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/takenet","download_url":"https://codeload.github.com/takenet/blip-sdk-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takenet%2Fblip-sdk-js/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261558822,"owners_count":23177097,"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":["blip","blip-sdk","chatbot"],"created_at":"2025-05-25T14:10:48.595Z","updated_at":"2025-06-23T21:31:37.850Z","avatar_url":"https://github.com/takenet.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# blip-sdk-js\n\u003e Simple BLiP SDK for JavaScript\n\n**This is a work in progress**\n\n[![npm version](https://img.shields.io/npm/v/blip-sdk.svg?style=flat-square)](https://www.npmjs.com/package/blip-sdk)\n[![npm downloads](https://img.shields.io/npm/dm/blip-sdk.svg?style=flat-square)](https://www.npmjs.com/package/blip-sdk) [![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg?style=flat-square)](https://gitter.im/takenet/blip-sdk-js)\n[![Travis branch](https://img.shields.io/travis/rust-lang/rust/master.svg?style=flat-square)](https://travis-ci.org/takenet/blip-sdk-js)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)](http://commitizen.github.io/cz-cli/)\n\n--------\n\nRead more about BLiP [here](http://blip.ai/)\n\n### Installing\n\n#### Node.js\n\nIf you are using `node.js` (or `webpack`), you should install the `blip-sdk` package (via npm) to access the BLiP server:\n\n    npm install --save blip-sdk lime-transport-websocket\n\n#### Browser\n\nIf you are developing a web application (for browsers) with \"pure\" JavaScript, it's possible to import the package from `node_modules` using the `\u003cscript\u003e` tag. In this case, other than the `blip-sdk` package, it's also necessary to include the dependencies `lime-js` and `lime-transport-websocket`:\n\n```html\n\u003cscript src=\"./node_modules/lime-js/dist/lime.js\" type=\"text/javascript\"\u003e\u003c/script\u003e\n\u003cscript src=\"./node_modules/lime-transport-websocket/dist/WebSocketTransport.js\" type=\"text/javascript\"\u003e\u003c/script\u003e\n\u003cscript src=\"./node_modules/blip-sdk/dist/blip-sdk.js\" type=\"text/javascript\"\u003e\u003c/script\u003e\n```\n\nYou can also use [unpkg](https://unpkg.com) to fetch the packages if you are not using `npm` in development:\n```html\n\u003cscript src=\"https://unpkg.com/lime-js\" type=\"text/javascript\"\u003e\u003c/script\u003e\n\u003cscript src=\"https://unpkg.com/lime-transport-websocket\" type=\"text/javascript\"\u003e\u003c/script\u003e\n\u003cscript src=\"https://unpkg.com/blip-sdk\" type=\"text/javascript\"\u003e\u003c/script\u003e\n```\n\n### Instantiate the BlipSdk Client\n\nYou will need an `identifier` and an `access key` to connect a chatbot to **BLiP**. To get them:\n- Go to [Painel BLiP](http://portal.blip.ai/) and login;\n- Click **Create chatbot**;\n- Choose the `Create from scratch` model option;\n- Go to **Settings** and click in **Connection Information**;\n- Get your bot's `identifier` and `access key`.\n\nIn order to instantiate the client use the `ClientBuilder` class informing the `identifier` and `access key`:\n\n```javascript\nimport * as BlipSdk from 'blip-sdk';\nimport WebSocketTransport from 'lime-transport-websocket'\n\n// Create a client instance passing the identifier and access key of your chatbot\nlet client = new BlipSdk.ClientBuilder()\n    .withIdentifier(IDENTIFIER)\n    .withAccessKey(ACCESS_KEY)\n    .withTransportFactory(() =\u003e new WebSocketTransport())\n    .build();\n\n// Connect with the server asynchronously\n// Connection will occurr via websocket on the 8081 port\nclient.connect() // This method returns a 'promise'\n    .then(function(session) {\n        // Connection success. Now it's possible to send and receive envelopes from the server\n        })\n    .catch(function(err) { /* Connection failed */ });\n```\n\nEach `client` instance represents a server connection and can be reused. To close a connection:\n\n```javascript\nclient.close()\n    .then(function() { /* Disconnection success */ })\n    .catch(function(err) { /* Disconnection failed */ });\n```\n\n### Receiving\n\nAll messages sent to the chatbot are redirected to registered `receivers` of messages and notifications. You can define filters to specify which envelopes will be handled by each receiver.\nThe following example shows how to add a simple message receiver:\n\n```javascript\nclient.addMessageReceiver(true, function(message) {\n  // Process received message\n});\n```\nThe next sample shows how to add a notification receiver with a filter for the `received` event type:\n\n```javascript\nclient.addNotificationReceiver(\"received\", function(notification) {\n  // Process received notifications\n});\n```\n\nIt's also possible to use a custom function as a filter:\n\nExample of a message receiver filtering by the originator:\n\n```javascript\nclient.addMessageReceiver(message =\u003e message.from === \"553199990000@0mn.io\", function(message) {\n  // Process received message\n});\n```\n\nEach registration of a receiver returns a `handler` that can be used to cancel the registration:\n\n```javascript\nvar removeJsonReceiver = client.addMessageReceiver(\"application/json\", handleJson);\n// ...\nremoveJsonReceiver();\n```\n\n### Sending\n\nIt's possible to send notifications and messages only after the session has been stablished.\n\nThe following sample shows how to send a message after the connection has been stablished:\n\n```javascript\nclient.connect()\n    .then(function(session) {\n      // Once connected it's possible to send messages\n      var msg = { type: \"text/plain\", content: \"Hello, world\", to: \"553199990000@0mn.io\" };\n      client.sendMessage(msg);\n    });\n```\n\nThe following sample shows how to send a notification after the connection has been stablished:\n\n```javascript\nclient.connect()\n    .then(function(session) {\n      // Sending a \"received\" notification\n      var notification = { id: \"ef16284d-09b2-4d91-8220-74008f3a5788\", to: \"553199990000@0mn.io\", event: Lime.NotificationEvent.RECEIVED };\n      client.sendNotification(notification);\n    });\n```\n\n## Contributing\n\nFor information on how to contribute to this package, please refer to our [Contribution guidelines](https://github.com/takenet/blip-sdk-js/blob/master/CONTRIBUTING.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakenet%2Fblip-sdk-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftakenet%2Fblip-sdk-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakenet%2Fblip-sdk-js/lists"}