1.3.11 • Published 4 years ago

@turnio/integration v1.3.11

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Turn.IO Integrations

A javascript helper library to make it easier to write integrations for Turn.io.

These can be run as google cloud functions.

Here's a sample integration

const app = new TurnIntegration(process.env.SECRET_KEY)
  .context("Language", "table", (message) => ({
    Language: "English",
    Confidence: "Very high",
  }))
  .context("A list of things", "ordered-list", (message) => [
    "first item",
    "second item",
    "third item",
  ])
  .suggest((message) => [
    {
      type: "TEXT",
      title: "Password reset",
      body: "To reset your password click the link on the login page.",
      confidence: 0.4,
    },
  ])
  .action((message) => [
    {
      description: "Change Language",
      payload: {
        really: "yes",
      },
      options: {
        afr_ZA: "Afrikaans",
        eng_ZA: "English",
        zul_ZA: "Zulu",
      },
      callback: ({ message, option, payload: { really } }) => {
        console.log({ message, option, really });
      },
    },
  ])
  .webhook("my-webhook", (req, resp, next) => {
    // expose /webhook/my-webhook as a webhook handler
    // for custom webhooks behaviour
    resp.send({ ok: "cool" });
  })
  .serve();

module.exports = app;

If you want to run this as an expressjs app then:

const server = require("./server");

const port = process.env.PORT || 3000;

server.listen(port, () =>
  console.log(`Example app listening on port ${port}!`)
);

Run it with:

PORT=3000 DEBUG=turn SECRET="<your integrations secret>" yarn start
1.3.11

4 years ago

1.3.10

4 years ago

1.3.9

4 years ago

1.3.7

4 years ago

1.3.8

4 years ago

1.3.6

4 years ago

1.3.5

4 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.2.4

4 years ago

1.2.0

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago