1.3.11 • Published 5 years ago
@turnio/integration v1.3.11
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
5 years ago
1.3.10
5 years ago
1.3.9
5 years ago
1.3.7
5 years ago
1.3.8
5 years ago
1.3.6
5 years ago
1.3.5
5 years ago
1.3.4
5 years ago
1.3.3
5 years ago
1.3.2
5 years ago
1.3.1
5 years ago
1.2.4
5 years ago
1.2.0
5 years ago
1.2.3
5 years ago
1.2.2
5 years ago
1.2.1
5 years ago
1.1.2
5 years ago
1.1.1
5 years ago
1.1.0
5 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago