@oryksa/sdk 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.es.md +91 -0
- package/README.fr.md +91 -0
- package/README.md +19 -3
- package/README.pt.md +91 -0
- package/package.json +1 -1
- package/src/index.d.ts +92 -92
- package/src/index.js +7 -4
package/README.es.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<p align="center"><img src="https://app.oryksa.com/static/oryksa_logo.png" width="300" alt="ORYKSA"></p>
|
|
2
|
+
|
|
3
|
+
# @oryksa/sdk
|
|
4
|
+
|
|
5
|
+
[](README.md) [](README.pt.md) [](README.es.md) [](README.fr.md)
|
|
6
|
+
|
|
7
|
+
<p align="center"><a href="https://developer.oryksa.com/es/sdks"><img src="https://developer.oryksa.com/assets/img/sdk/oryksa-sdks-es.gif" width="760" alt="SDKs de ORYKSA: el chat y la voz de la IA en iOS, Android, Flutter, React Native y la web"></a></p>
|
|
8
|
+
|
|
9
|
+
SDK oficial de JavaScript y TypeScript de **ORYKSA AI Employees**: pon un empleado de IA que ya conoce el negocio dentro de tu app web, tu backend Node o tu app de escritorio Electron. El mismo cerebro de WhatsApp y del chat del sitio web, en texto y voz.
|
|
10
|
+
|
|
11
|
+
- Documentación: https://developer.oryksa.com
|
|
12
|
+
- API: `https://api.oryksa.com/v1`
|
|
13
|
+
|
|
14
|
+
## Capturas de pantalla
|
|
15
|
+
|
|
16
|
+
<p align="center"><img src="https://raw.githubusercontent.com/oryksa/oryksa-js/main/docs/screenshots/js_chat_en.png" width="420" alt="Chat"> <img src="https://raw.githubusercontent.com/oryksa/oryksa-js/main/docs/screenshots/js_theme_en.png" width="420" alt="Chat with the README theme"></p>
|
|
17
|
+
|
|
18
|
+
Una página de tienda con `mountChat`, capturada por el CI en Chrome con una cuenta de prueba de ORYKSA (`test/shots.html`): colores por defecto a la izquierda y, a la derecha, el código de *Colores y tema*, más abajo.
|
|
19
|
+
|
|
20
|
+
## Instalar
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @oryksa/sdk
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Servidor (clave secreta)
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
import { Oryksa } from "@oryksa/sdk";
|
|
30
|
+
const oryksa = new Oryksa(process.env.ORYKSA_API_KEY); // developer.oryksa.com > Keys
|
|
31
|
+
|
|
32
|
+
const r = await oryksa.chat({ message: "Are you open on Saturday?" });
|
|
33
|
+
console.log(r.reply, r.conversation_id);
|
|
34
|
+
|
|
35
|
+
// Teach the AI employee about your app (e.g. on every release)
|
|
36
|
+
await oryksa.learnApp({
|
|
37
|
+
name: "FitTrack",
|
|
38
|
+
description: "Fitness app to log workouts and follow training plans.",
|
|
39
|
+
screens: [{ title: "Workouts", content: "Tap + to log a workout." }],
|
|
40
|
+
faq: [{ question: "How do I cancel Premium?", answer: "Settings > Subscription > Cancel." }],
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## En la app (token de sesión, nunca la clave secreta)
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
// your server
|
|
48
|
+
app.get("/oryksa-token", requireLogin, async (req, res) => {
|
|
49
|
+
const s = await oryksa.createSession({ conversationId: "user-" + req.user.id, customerName: req.user.firstName });
|
|
50
|
+
res.json({ token: s.client_token });
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// your web app
|
|
54
|
+
import { OryksaClient, mountChat } from "@oryksa/sdk";
|
|
55
|
+
const client = new OryksaClient({ getToken: async () => (await fetch("/oryksa-token").then(r => r.json())).token });
|
|
56
|
+
mountChat({ client, lang: "en" }); // ready-made chat UI
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Colores y tema
|
|
60
|
+
|
|
61
|
+
`mountChat` acepta tres colores como texto CSS: `accent` (botones, burbujas del visitante, enlaces), `ink` (texto principal) y `soft` (burbujas de la IA). Los que falten mantienen el valor por defecto (`#5B57E0`, `#161B3D` y `#EEEBFB`). `position` (`"left"` o `"right"`) elige el lado de la pantalla.
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
mountChat({ client, lang: "en", accent: "#0E8A6B", ink: "#10281F", soft: "#E3F5EE" });
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Webhooks
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
import { verifyWebhook } from "@oryksa/sdk";
|
|
71
|
+
app.post("/oryksa-webhook", express.raw({ type: "application/json" }), async (req, res) => {
|
|
72
|
+
const event = await verifyWebhook(req.body, req.get("ORYKSA-Signature"), process.env.ORYKSA_WEBHOOK_SECRET);
|
|
73
|
+
if (event.type === "booking.created") { /* save it */ }
|
|
74
|
+
res.sendStatus(200);
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Errores
|
|
79
|
+
|
|
80
|
+
Cada llamada que falla lanza `OryksaError` con `status`, `code` (por ejemplo `interaction_limit_reached`, `rate_limited`, `plan_required`) y `message`.
|
|
81
|
+
|
|
82
|
+
## Sobre el autor
|
|
83
|
+
|
|
84
|
+
**Weslley Harakawa** - Fundador de ORYKSA AI. En Lisboa, Portugal. Especialidades: inteligencia artificial, desarrollo web y móvil, tokenización en blockchain. Formación: University of the People.
|
|
85
|
+
|
|
86
|
+
- LinkedIn: https://www.linkedin.com/in/weslleyharakawa/
|
|
87
|
+
- ORYKSA AI Employees: https://oryksa.com (X: https://x.com/oryksa, Instagram: https://www.instagram.com/oryksaai, YouTube: https://www.youtube.com/@ORYKSA)
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
MIT License · ORYKSA AI Employees · W8 Atlantic Unipessoal Lda
|
package/README.fr.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<p align="center"><img src="https://app.oryksa.com/static/oryksa_logo.png" width="300" alt="ORYKSA"></p>
|
|
2
|
+
|
|
3
|
+
# @oryksa/sdk
|
|
4
|
+
|
|
5
|
+
[](README.md) [](README.pt.md) [](README.es.md) [](README.fr.md)
|
|
6
|
+
|
|
7
|
+
<p align="center"><a href="https://developer.oryksa.com/fr/sdks"><img src="https://developer.oryksa.com/assets/img/sdk/oryksa-sdks-fr.gif" width="760" alt="SDK ORYKSA : le chat et la voix de l'IA sur iOS, Android, Flutter, React Native et le web"></a></p>
|
|
8
|
+
|
|
9
|
+
SDK officiel JavaScript et TypeScript d'**ORYKSA AI Employees** : placez un employé IA qui connaît déjà l'entreprise dans votre app web, votre backend Node ou votre app de bureau Electron. Le même cerveau que WhatsApp et le chat du site web, en texte et en voix.
|
|
10
|
+
|
|
11
|
+
- Documentation : https://developer.oryksa.com
|
|
12
|
+
- API : `https://api.oryksa.com/v1`
|
|
13
|
+
|
|
14
|
+
## Captures d'écran
|
|
15
|
+
|
|
16
|
+
<p align="center"><img src="https://raw.githubusercontent.com/oryksa/oryksa-js/main/docs/screenshots/js_chat_en.png" width="420" alt="Chat"> <img src="https://raw.githubusercontent.com/oryksa/oryksa-js/main/docs/screenshots/js_theme_en.png" width="420" alt="Chat with the README theme"></p>
|
|
17
|
+
|
|
18
|
+
Une page de boutique avec `mountChat`, capturée par la CI dans Chrome avec un compte de test ORYKSA (`test/shots.html`) : couleurs par défaut à gauche et, à droite, le code de *Couleurs et thème*, plus bas.
|
|
19
|
+
|
|
20
|
+
## Installer
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @oryksa/sdk
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Serveur (clé secrète)
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
import { Oryksa } from "@oryksa/sdk";
|
|
30
|
+
const oryksa = new Oryksa(process.env.ORYKSA_API_KEY); // developer.oryksa.com > Keys
|
|
31
|
+
|
|
32
|
+
const r = await oryksa.chat({ message: "Are you open on Saturday?" });
|
|
33
|
+
console.log(r.reply, r.conversation_id);
|
|
34
|
+
|
|
35
|
+
// Teach the AI employee about your app (e.g. on every release)
|
|
36
|
+
await oryksa.learnApp({
|
|
37
|
+
name: "FitTrack",
|
|
38
|
+
description: "Fitness app to log workouts and follow training plans.",
|
|
39
|
+
screens: [{ title: "Workouts", content: "Tap + to log a workout." }],
|
|
40
|
+
faq: [{ question: "How do I cancel Premium?", answer: "Settings > Subscription > Cancel." }],
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Dans l'app (jeton de session, jamais la clé secrète)
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
// your server
|
|
48
|
+
app.get("/oryksa-token", requireLogin, async (req, res) => {
|
|
49
|
+
const s = await oryksa.createSession({ conversationId: "user-" + req.user.id, customerName: req.user.firstName });
|
|
50
|
+
res.json({ token: s.client_token });
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// your web app
|
|
54
|
+
import { OryksaClient, mountChat } from "@oryksa/sdk";
|
|
55
|
+
const client = new OryksaClient({ getToken: async () => (await fetch("/oryksa-token").then(r => r.json())).token });
|
|
56
|
+
mountChat({ client, lang: "en" }); // ready-made chat UI
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Couleurs et thème
|
|
60
|
+
|
|
61
|
+
`mountChat` accepte trois couleurs en texte CSS : `accent` (boutons, bulles du visiteur, liens), `ink` (texte principal) et `soft` (bulles de l'IA). Celles qui manquent gardent la valeur par défaut (`#5B57E0`, `#161B3D` et `#EEEBFB`). `position` (`"left"` ou `"right"`) choisit le côté de l'écran.
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
mountChat({ client, lang: "en", accent: "#0E8A6B", ink: "#10281F", soft: "#E3F5EE" });
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Webhooks
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
import { verifyWebhook } from "@oryksa/sdk";
|
|
71
|
+
app.post("/oryksa-webhook", express.raw({ type: "application/json" }), async (req, res) => {
|
|
72
|
+
const event = await verifyWebhook(req.body, req.get("ORYKSA-Signature"), process.env.ORYKSA_WEBHOOK_SECRET);
|
|
73
|
+
if (event.type === "booking.created") { /* save it */ }
|
|
74
|
+
res.sendStatus(200);
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Erreurs
|
|
79
|
+
|
|
80
|
+
Chaque appel qui échoue lève `OryksaError` avec `status`, `code` (par exemple `interaction_limit_reached`, `rate_limited`, `plan_required`) et `message`.
|
|
81
|
+
|
|
82
|
+
## À propos de l'auteur
|
|
83
|
+
|
|
84
|
+
**Weslley Harakawa** - Fondateur d'ORYKSA AI. À Lisbonne, Portugal. Spécialités : intelligence artificielle, développement web et mobile, tokenisation blockchain. Formation : University of the People.
|
|
85
|
+
|
|
86
|
+
- LinkedIn: https://www.linkedin.com/in/weslleyharakawa/
|
|
87
|
+
- ORYKSA AI Employees: https://oryksa.com (X: https://x.com/oryksa, Instagram: https://www.instagram.com/oryksaai, YouTube: https://www.youtube.com/@ORYKSA)
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
MIT License · ORYKSA AI Employees · W8 Atlantic Unipessoal Lda
|
package/README.md
CHANGED
|
@@ -2,11 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
# @oryksa/sdk
|
|
4
4
|
|
|
5
|
+
[](README.md) [](README.pt.md) [](README.es.md) [](README.fr.md)
|
|
6
|
+
|
|
7
|
+
<p align="center"><a href="https://developer.oryksa.com/en/sdks"><img src="https://developer.oryksa.com/assets/img/sdk/oryksa-sdks-en.gif" width="760" alt="ORYKSA SDKs: the AI chat and voice on iOS, Android, Flutter, React Native and the web"></a></p>
|
|
8
|
+
|
|
5
9
|
Official JavaScript and TypeScript SDK for **ORYKSA AI Employees**: put an AI employee that already knows the business inside your web app, Node backend or Electron desktop app. Same brain as WhatsApp and the website chat, text and voice.
|
|
6
10
|
|
|
7
11
|
- Docs: https://developer.oryksa.com
|
|
8
12
|
- API: `https://api.oryksa.com/v1`
|
|
9
13
|
|
|
14
|
+
## Screenshots
|
|
15
|
+
|
|
16
|
+
<p align="center"><img src="https://raw.githubusercontent.com/oryksa/oryksa-js/main/docs/screenshots/js_chat_en.png" width="420" alt="Chat"> <img src="https://raw.githubusercontent.com/oryksa/oryksa-js/main/docs/screenshots/js_theme_en.png" width="420" alt="Chat with the README theme"></p>
|
|
17
|
+
|
|
18
|
+
A store page with `mountChat`, captured by CI in Chrome with an ORYKSA test account (`test/shots.html`): default colors on the left, the code of *Colours and theme* below on the right.
|
|
19
|
+
|
|
10
20
|
## Install
|
|
11
21
|
|
|
12
22
|
```bash
|
|
@@ -46,6 +56,14 @@ const client = new OryksaClient({ getToken: async () => (await fetch("/oryksa-to
|
|
|
46
56
|
mountChat({ client, lang: "en" }); // ready-made chat UI
|
|
47
57
|
```
|
|
48
58
|
|
|
59
|
+
## Colours and theme
|
|
60
|
+
|
|
61
|
+
`mountChat` accepts three colors as CSS strings: `accent` (buttons, visitor bubbles, links), `ink` (main text) and `soft` (AI bubbles). Missing ones keep the default (`#5B57E0`, `#161B3D` and `#EEEBFB`). `position` (`"left"` or `"right"`) picks the side of the screen.
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
mountChat({ client, lang: "en", accent: "#0E8A6B", ink: "#10281F", soft: "#E3F5EE" });
|
|
65
|
+
```
|
|
66
|
+
|
|
49
67
|
## Webhooks
|
|
50
68
|
|
|
51
69
|
```js
|
|
@@ -65,10 +83,8 @@ Every failed call throws `OryksaError` with `status`, `code` (for example `inter
|
|
|
65
83
|
|
|
66
84
|
**Weslley Harakawa** - Founder of ORYKSA AI. Based in Lisbon, Portugal. Specialties: artificial intelligence, web and mobile development, blockchain tokenization. Education: University of the People.
|
|
67
85
|
|
|
68
|
-
- Website: https://harakawa.tech
|
|
69
86
|
- LinkedIn: https://www.linkedin.com/in/weslleyharakawa/
|
|
70
|
-
- Instagram: https://www.instagram.com/
|
|
71
|
-
- ORYKSA AI Employees: https://oryksa.com (X: https://x.com/oryksa, Instagram: https://www.instagram.com/oryksaai, YouTube: https://www.youtube.com/@ORYKSAAI)
|
|
87
|
+
- ORYKSA AI Employees: https://oryksa.com (X: https://x.com/oryksa, Instagram: https://www.instagram.com/oryksaai, YouTube: https://www.youtube.com/@ORYKSA)
|
|
72
88
|
|
|
73
89
|
---
|
|
74
90
|
|
package/README.pt.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<p align="center"><img src="https://app.oryksa.com/static/oryksa_logo.png" width="300" alt="ORYKSA"></p>
|
|
2
|
+
|
|
3
|
+
# @oryksa/sdk
|
|
4
|
+
|
|
5
|
+
[](README.md) [](README.pt.md) [](README.es.md) [](README.fr.md)
|
|
6
|
+
|
|
7
|
+
<p align="center"><a href="https://developer.oryksa.com/pt/sdks"><img src="https://developer.oryksa.com/assets/img/sdk/oryksa-sdks-pt.gif" width="760" alt="SDKs ORYKSA: o chat e a voz da IA no iOS, Android, Flutter, React Native e na web"></a></p>
|
|
8
|
+
|
|
9
|
+
SDK oficial de JavaScript e TypeScript da **ORYKSA AI Employees**: põe um colaborador de IA que já conhece o negócio dentro da tua app web, do teu backend Node ou da tua app de secretária Electron. O mesmo cérebro do WhatsApp e do chat do site, em texto e voz.
|
|
10
|
+
|
|
11
|
+
- Documentação: https://developer.oryksa.com
|
|
12
|
+
- API: `https://api.oryksa.com/v1`
|
|
13
|
+
|
|
14
|
+
## Capturas de ecrã
|
|
15
|
+
|
|
16
|
+
<p align="center"><img src="https://raw.githubusercontent.com/oryksa/oryksa-js/main/docs/screenshots/js_chat_pt.png" width="420" alt="Chat"> <img src="https://raw.githubusercontent.com/oryksa/oryksa-js/main/docs/screenshots/js_theme_pt.png" width="420" alt="Chat com o tema do README"></p>
|
|
17
|
+
|
|
18
|
+
Uma página de loja com `mountChat`, captada pelo CI no Chrome com uma conta de teste da ORYKSA (`test/shots.html`): cores de origem à esquerda e, à direita, o código de *Cores e tema*, mais abaixo.
|
|
19
|
+
|
|
20
|
+
## Instalar
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @oryksa/sdk
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Servidor (chave secreta)
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
import { Oryksa } from "@oryksa/sdk";
|
|
30
|
+
const oryksa = new Oryksa(process.env.ORYKSA_API_KEY); // developer.oryksa.com > Keys
|
|
31
|
+
|
|
32
|
+
const r = await oryksa.chat({ message: "Are you open on Saturday?" });
|
|
33
|
+
console.log(r.reply, r.conversation_id);
|
|
34
|
+
|
|
35
|
+
// Teach the AI employee about your app (e.g. on every release)
|
|
36
|
+
await oryksa.learnApp({
|
|
37
|
+
name: "FitTrack",
|
|
38
|
+
description: "Fitness app to log workouts and follow training plans.",
|
|
39
|
+
screens: [{ title: "Workouts", content: "Tap + to log a workout." }],
|
|
40
|
+
faq: [{ question: "How do I cancel Premium?", answer: "Settings > Subscription > Cancel." }],
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Na app (token de sessão, nunca a chave secreta)
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
// your server
|
|
48
|
+
app.get("/oryksa-token", requireLogin, async (req, res) => {
|
|
49
|
+
const s = await oryksa.createSession({ conversationId: "user-" + req.user.id, customerName: req.user.firstName });
|
|
50
|
+
res.json({ token: s.client_token });
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// your web app
|
|
54
|
+
import { OryksaClient, mountChat } from "@oryksa/sdk";
|
|
55
|
+
const client = new OryksaClient({ getToken: async () => (await fetch("/oryksa-token").then(r => r.json())).token });
|
|
56
|
+
mountChat({ client, lang: "en" }); // ready-made chat UI
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Cores e tema
|
|
60
|
+
|
|
61
|
+
O `mountChat` aceita três cores como texto CSS: `accent` (botões, balões do visitante, ligações), `ink` (texto principal) e `soft` (balões da IA). As que faltarem mantêm o valor por omissão (`#5B57E0`, `#161B3D` e `#EEEBFB`). O `position` (`"left"` ou `"right"`) escolhe o lado do ecrã.
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
mountChat({ client, lang: "en", accent: "#0E8A6B", ink: "#10281F", soft: "#E3F5EE" });
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Webhooks
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
import { verifyWebhook } from "@oryksa/sdk";
|
|
71
|
+
app.post("/oryksa-webhook", express.raw({ type: "application/json" }), async (req, res) => {
|
|
72
|
+
const event = await verifyWebhook(req.body, req.get("ORYKSA-Signature"), process.env.ORYKSA_WEBHOOK_SECRET);
|
|
73
|
+
if (event.type === "booking.created") { /* save it */ }
|
|
74
|
+
res.sendStatus(200);
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Erros
|
|
79
|
+
|
|
80
|
+
Cada chamada falhada lança `OryksaError` com `status`, `code` (por exemplo `interaction_limit_reached`, `rate_limited`, `plan_required`) e `message`.
|
|
81
|
+
|
|
82
|
+
## Sobre o autor
|
|
83
|
+
|
|
84
|
+
**Weslley Harakawa** - Fundador da ORYKSA AI. Em Lisboa, Portugal. Especialidades: inteligência artificial, desenvolvimento web e mobile, tokenização em blockchain. Formação: University of the People.
|
|
85
|
+
|
|
86
|
+
- LinkedIn: https://www.linkedin.com/in/weslleyharakawa/
|
|
87
|
+
- ORYKSA AI Employees: https://oryksa.com (X: https://x.com/oryksa, Instagram: https://www.instagram.com/oryksaai, YouTube: https://www.youtube.com/@ORYKSA)
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
MIT License · ORYKSA AI Employees · W8 Atlantic Unipessoal Lda
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
export declare const VERSION: string;
|
|
2
|
-
|
|
3
|
-
export declare class OryksaError extends Error {
|
|
4
|
-
status: number;
|
|
5
|
-
code: string;
|
|
6
|
-
upgrade_url?: string;
|
|
7
|
-
retry_after?: number;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface ChatReply {
|
|
11
|
-
object: "chat_reply";
|
|
12
|
-
conversation_id: string;
|
|
13
|
-
status: "replied" | "pending";
|
|
14
|
-
reply: string | null;
|
|
15
|
-
hint?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface Message { role: "user" | "assistant"; content: string }
|
|
19
|
-
|
|
20
|
-
export interface ServerOptions {
|
|
21
|
-
baseUrl?: string;
|
|
22
|
-
fetch?: typeof fetch;
|
|
23
|
-
timeoutMs?: number;
|
|
24
|
-
/** Only for local tools. The secret key must never reach end users. */
|
|
25
|
-
dangerouslyAllowBrowser?: boolean;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface AppDescription {
|
|
29
|
-
name: string;
|
|
30
|
-
description?: string;
|
|
31
|
-
url?: string;
|
|
32
|
-
agentName?: string;
|
|
33
|
-
languages?: string[];
|
|
34
|
-
services?: string[];
|
|
35
|
-
screens?: { title: string; content: string; url?: string }[];
|
|
36
|
-
faq?: { question: string; answer: string }[];
|
|
37
|
-
settings?: Record<string, unknown>;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type WebhookEvent = "message.replied" | "booking.created" | "limit.reached" | "knowledge.updated" | "*";
|
|
41
|
-
|
|
42
|
-
export declare class Oryksa {
|
|
43
|
-
constructor(apiKey: string, opts?: ServerOptions);
|
|
44
|
-
account(): Promise<any>;
|
|
45
|
-
chat(p: { message: string; conversationId?: string; customerName?: string }): Promise<ChatReply>;
|
|
46
|
-
conversations(p?: { limit?: number }): Promise<{ object: "list"; data: any[] }>;
|
|
47
|
-
conversation(id: string): Promise<{ object: "conversation"; id: string; messages: Message[] }>;
|
|
48
|
-
readonly agent: {
|
|
49
|
-
update(fields: Record<string, unknown>): Promise<{ object: "agent"; updated: string[] }>;
|
|
50
|
-
appearance(fields: Record<string, unknown>): Promise<{ object: "agent_appearance"; updated: string[] }>;
|
|
51
|
-
};
|
|
52
|
-
readonly knowledge: {
|
|
53
|
-
get(): Promise<any>;
|
|
54
|
-
setPages(p: { pages: { title?: string; url?: string; content: string }[]; businessSummary?: string; siteUrl?: string }): Promise<any>;
|
|
55
|
-
crawl(p: { url: string; maxPages?: number }): Promise<any>;
|
|
56
|
-
addFaq(items: { question: string; answer: string }[]): Promise<{ added: number; updated: number }>;
|
|
57
|
-
};
|
|
58
|
-
readonly widget: {
|
|
59
|
-
snippet(p?: { framework?: string; lang?: string; position?: "left" | "right" }): Promise<any>;
|
|
60
|
-
setDomains(domains: string[]): Promise<any>;
|
|
61
|
-
};
|
|
62
|
-
readonly webhooks: {
|
|
63
|
-
list(): Promise<any>;
|
|
64
|
-
create(p: { url: string; events?: WebhookEvent[] }): Promise<any>;
|
|
65
|
-
delete(id: string): Promise<any>;
|
|
66
|
-
test(id: string): Promise<{ status: number; delivered: boolean }>;
|
|
67
|
-
};
|
|
68
|
-
createSession(p?: { conversationId?: string; customerName?: string; ttlMinutes?: number }): Promise<{ client_token: string; conversation_id: string; expires_at: string }>;
|
|
69
|
-
learnApp(app: AppDescription): Promise<any>;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export declare function verifyWebhook(rawBody: string | Uint8Array, signatureHeader: string, secret: string, opts?: { toleranceSeconds?: number }): Promise<{ id: string; type: string; created_at: string; data: any }>;
|
|
73
|
-
|
|
74
|
-
export interface AgentInfo {
|
|
75
|
-
name: string; business: string | null; gender: "female" | "male"; avatar: string;
|
|
76
|
-
greeting: Record<string, string>; suggestions: Record<string, string[]>; subtitle: Record<string, string>;
|
|
77
|
-
voice_replies: boolean; conversation_id: string;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export declare class OryksaClient {
|
|
81
|
-
constructor(opts: { token?: string; getToken?: () => Promise<string>; baseUrl?: string; fetch?: typeof fetch; timeoutMs?: number });
|
|
82
|
-
agent(): Promise<AgentInfo>;
|
|
83
|
-
send(message: string): Promise<ChatReply>;
|
|
84
|
-
messages(): Promise<{ id: string; messages: Message[] }>;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export declare function mountChat(opts: {
|
|
88
|
-
client: OryksaClient; lang?: "en" | "pt" | "br" | "es"; position?: "left" | "right";
|
|
89
|
-
accent?: string; ink?: string; soft?: string; open?: boolean;
|
|
90
|
-
}): { open(): void; close(): void; send(text: string): Promise<void>; destroy(): void };
|
|
91
|
-
|
|
92
|
-
export default Oryksa;
|
|
1
|
+
export declare const VERSION: string;
|
|
2
|
+
|
|
3
|
+
export declare class OryksaError extends Error {
|
|
4
|
+
status: number;
|
|
5
|
+
code: string;
|
|
6
|
+
upgrade_url?: string;
|
|
7
|
+
retry_after?: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ChatReply {
|
|
11
|
+
object: "chat_reply";
|
|
12
|
+
conversation_id: string;
|
|
13
|
+
status: "replied" | "pending";
|
|
14
|
+
reply: string | null;
|
|
15
|
+
hint?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface Message { role: "user" | "assistant"; content: string }
|
|
19
|
+
|
|
20
|
+
export interface ServerOptions {
|
|
21
|
+
baseUrl?: string;
|
|
22
|
+
fetch?: typeof fetch;
|
|
23
|
+
timeoutMs?: number;
|
|
24
|
+
/** Only for local tools. The secret key must never reach end users. */
|
|
25
|
+
dangerouslyAllowBrowser?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface AppDescription {
|
|
29
|
+
name: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
url?: string;
|
|
32
|
+
agentName?: string;
|
|
33
|
+
languages?: string[];
|
|
34
|
+
services?: string[];
|
|
35
|
+
screens?: { title: string; content: string; url?: string }[];
|
|
36
|
+
faq?: { question: string; answer: string }[];
|
|
37
|
+
settings?: Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type WebhookEvent = "message.replied" | "booking.created" | "limit.reached" | "knowledge.updated" | "*";
|
|
41
|
+
|
|
42
|
+
export declare class Oryksa {
|
|
43
|
+
constructor(apiKey: string, opts?: ServerOptions);
|
|
44
|
+
account(): Promise<any>;
|
|
45
|
+
chat(p: { message: string; conversationId?: string; customerName?: string }): Promise<ChatReply>;
|
|
46
|
+
conversations(p?: { limit?: number }): Promise<{ object: "list"; data: any[] }>;
|
|
47
|
+
conversation(id: string): Promise<{ object: "conversation"; id: string; messages: Message[] }>;
|
|
48
|
+
readonly agent: {
|
|
49
|
+
update(fields: Record<string, unknown>): Promise<{ object: "agent"; updated: string[] }>;
|
|
50
|
+
appearance(fields: Record<string, unknown>): Promise<{ object: "agent_appearance"; updated: string[] }>;
|
|
51
|
+
};
|
|
52
|
+
readonly knowledge: {
|
|
53
|
+
get(): Promise<any>;
|
|
54
|
+
setPages(p: { pages: { title?: string; url?: string; content: string }[]; businessSummary?: string; siteUrl?: string }): Promise<any>;
|
|
55
|
+
crawl(p: { url: string; maxPages?: number }): Promise<any>;
|
|
56
|
+
addFaq(items: { question: string; answer: string }[]): Promise<{ added: number; updated: number }>;
|
|
57
|
+
};
|
|
58
|
+
readonly widget: {
|
|
59
|
+
snippet(p?: { framework?: string; lang?: string; position?: "left" | "right" }): Promise<any>;
|
|
60
|
+
setDomains(domains: string[]): Promise<any>;
|
|
61
|
+
};
|
|
62
|
+
readonly webhooks: {
|
|
63
|
+
list(): Promise<any>;
|
|
64
|
+
create(p: { url: string; events?: WebhookEvent[] }): Promise<any>;
|
|
65
|
+
delete(id: string): Promise<any>;
|
|
66
|
+
test(id: string): Promise<{ status: number; delivered: boolean }>;
|
|
67
|
+
};
|
|
68
|
+
createSession(p?: { conversationId?: string; customerName?: string; customerEmail?: string; customerPhone?: string; ttlMinutes?: number }): Promise<{ client_token: string; conversation_id: string; expires_at: string }>;
|
|
69
|
+
learnApp(app: AppDescription): Promise<any>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export declare function verifyWebhook(rawBody: string | Uint8Array, signatureHeader: string, secret: string, opts?: { toleranceSeconds?: number }): Promise<{ id: string; type: string; created_at: string; data: any }>;
|
|
73
|
+
|
|
74
|
+
export interface AgentInfo {
|
|
75
|
+
name: string; business: string | null; gender: "female" | "male"; avatar: string;
|
|
76
|
+
greeting: Record<string, string>; suggestions: Record<string, string[]>; subtitle: Record<string, string>;
|
|
77
|
+
voice_replies: boolean; conversation_id: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export declare class OryksaClient {
|
|
81
|
+
constructor(opts: { token?: string; getToken?: () => Promise<string>; baseUrl?: string; fetch?: typeof fetch; timeoutMs?: number });
|
|
82
|
+
agent(): Promise<AgentInfo>;
|
|
83
|
+
send(message: string): Promise<ChatReply>;
|
|
84
|
+
messages(): Promise<{ id: string; messages: Message[] }>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export declare function mountChat(opts: {
|
|
88
|
+
client: OryksaClient; lang?: "en" | "pt" | "br" | "es"; position?: "left" | "right";
|
|
89
|
+
accent?: string; ink?: string; soft?: string; open?: boolean;
|
|
90
|
+
}): { open(): void; close(): void; send(text: string): Promise<void>; destroy(): void };
|
|
91
|
+
|
|
92
|
+
export default Oryksa;
|
package/src/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
const DEFAULT_BASE = "https://api.oryksa.com/v1";
|
|
9
|
-
export const VERSION = "0.1.
|
|
9
|
+
export const VERSION = "0.1.4";
|
|
10
10
|
|
|
11
11
|
export class OryksaError extends Error {
|
|
12
12
|
constructor(status, code, message, extra = {}) {
|
|
@@ -113,9 +113,12 @@ export class Oryksa {
|
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
/** Short-lived token for an app user. Send only this token to the app.
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
/** Short-lived token for an app user. Send only this token to the app.
|
|
117
|
+
* For a user signed in to your app, pass customerEmail and/or customerPhone (with the country code):
|
|
118
|
+
* the AI then asks for no contact details and knows the customer is signed in. */
|
|
119
|
+
createSession({ conversationId, customerName, customerEmail, customerPhone, ttlMinutes = 60 } = {}) {
|
|
120
|
+
return this._req("POST", "/sessions", { conversation_id: conversationId, customer_name: customerName,
|
|
121
|
+
customer_email: customerEmail, customer_phone: customerPhone, ttl_minutes: ttlMinutes });
|
|
119
122
|
}
|
|
120
123
|
|
|
121
124
|
/**
|