npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@artisol/teneo-interaction-engine-sdk

v0.2.1

Published

This module provides a way of communicating with a Teneo Engine instance either on the server as a NodeJS module or in a browser loaded through a script node.

Downloads

4

Readme

Teneo Interaction Engine Javascript API

This module provides a way of communicating with a Teneo Engine instance either on the server as a NodeJS module or in a browser loaded through a script node.

Usage

Node.js

Example usage

const TIE = require('@artisol/teneo-interaction-engine-sdk');

const teneoEngineUrl = 'https://some.teneo/engine-instance';
const logResponse = (response) => {
  console.log(response.output);
  return response;
}

TIE.sendInput(teneoEngineUrl, null, { text: 'Hello there' })
  .then(logResponse)
  .then(({ sessionId }) => TIE.sendInput(teneoEngineUrl, sessionId, { text: 'How are you doing?' }))
  .then(logResponse)
  .then(({ sessionId }) => TIE.close(teneoEngineUrl, sessionId));

Note that when used as a Node.js module, you need to manually handle the session by passing the session ID to the API functions.

Browser

When using the API in the browser, you need to first have a bundled version of the API that you can load on the page. You can generate a bundled version of the API by executing the npm run build script (see section on local development). The bundled file will be placed in the dist/ directory.

Example usage

const teneoEngineUrl = 'https://some.teneo/engine-instance';
const logResponse = (response) => {
  console.log(response.output);
  return response;
}

TIE.sendInput(teneoEngineUrl, null, { text: 'Hello there' })
  .then(logResponse)
  .then(() => TIE.sendInput(teneoEngineUrl, null, { text: 'How are you doing?' }))
  .then(logResponse)
  .then(() => TIE.close(teneoEngineUrl));

Note that in the browser the session is maintained via cookies and the API cannot manually override the browser's handling of the session. That means that you never need (nor should) pass the session ID when using the API in the browser.

API Documentation

TIE.sendInput

Sends inputData to the url. Returns a Promise if no callback is provided.

Signature
TIE.sendInput(url: string, sessionId: string, inputData: object, [callback: function])
Parameters

url: URL to a running Teneo Engine instance.

sessionId: Session id to be passed to the Teneo Engine instance. Pass null if unknown.

inputData: An object taking the shape:

{
  text: "Some input text",
  someParam: "foo",
  anotherParam: "bar"
}

All properties except text will be sent to the Teneo Engine instance as extra parameters.

callback(error: Error, response: teneoEngineResponse) [Optional]: Callback for handling the response from the Teneo Engine instance.

TIE.close

Closes the running (or specified session). Returns a Promise if no callback is provided.

Signture
TIE.close(url: string, sessionId: string, [callback: function])
Parameters

url: URL to a running Teneo Engine instance.

sessionId: Session id to be passed to the Teneo Engine instance. Pass null if unknown.

callback(error: Error, response: TeneoEngineResponse) [Optional]: Callback for handling the response from the Teneo Engine instance.

TIE.init

Returns a version of the Teneo Interaction Engine API with the Teneo Engine url prefilled.

> const teneoApi = TIE.init('http://some.teneo/engine-instance');
> teneoApi.sendInput(null, { text: 'Sending some text to the prefilled url' })
    .then(response =>
      console.log(response);
      return teneoApi.close(response.sessionId);
    });
Signature
TIE.init(url: string)
Parameters

url: URL to a running Teneo Engine instance.

TeneoEngineResponse

Response from the Teneo Interaction Engine API.

Normal response:

{
  "status": 0,
  "input": {
	  "text": "input text",
	  "parameters": {}
	 },
   "output": {
	   "text": "output text",
	   "emotion":"",
	   "link":"",
	   "parameters": {}
	 },
   "sessionId": "current session id"
}

Error response:

{
  "status": -1,
  "input": {
    "text": "input text",
    "parameters": {}
  },
  "message": "ERROR MESSAGE"
}

Setting up the project for local development

  1. Ensure you have supported versions of Node and NPM installed (see the engines property in package.json)
  2. Run npm install
  3. Run npm test