@oryksa/react-native 1.0.0 → 1.1.0
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/CHANGELOG.md +20 -8
- package/README.md +123 -98
- package/package.json +61 -21
- package/src/chat.js +225 -163
- package/src/client.js +233 -114
- package/src/index.d.ts +151 -53
- package/src/index.js +28 -18
- package/src/profanity.js +60 -0
- package/src/vad.js +264 -0
- package/src/voice-screen.js +140 -0
- package/src/voice.js +338 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## 1.
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
* Copy button under each reply of the AI (copies the text, shows a check for a moment), as in the ORYKSA apps and extension. Uses `@react-native-clipboard/clipboard` when installed (optional peer dependency).
|
|
6
|
+
* Voice: a voice screen with the photo of the AI ("I'm listening" / her answer, Mute, Close) opened from the microphone in the chat. The same behaviour as the ORYKSA app: the microphone stays open while she speaks and only a human voice cuts her off (typing, TV, birds and her own echo do not); she stops on the word and the text stays in the chat; the second before the cut is kept; 700 ms of silence closes a sentence (15 s at most); a whisper gets a whispered, shorter answer; her voice is the one chosen in ORYKSA and, if it fails, the text is shown without a robot voice.
|
|
7
|
+
* The voice engine is the ORYKSA app engine (`Vad`), with the same audio tests on real recordings.
|
|
8
|
+
* `appContext`: tell the AI which screen of your app the customer is on (product, cart, booking) so it answers about it.
|
|
9
|
+
* The client gets `tts`, `transcribe` and `voiceStats`; `send` accepts `voice`, `whisper`, `appContext` and returns `speech` (the short spoken version).
|
|
10
|
+
* The agent includes `photo` (the AI photo from Your AI), `voice` and `language`.
|
|
11
|
+
* Bold text (`**`) in the chat bubbles.
|
|
12
|
+
* The SDK serves the customers of the business only: it is never an interface for the owner.
|
|
13
|
+
* Voice uses an audio adapter: by default `react-native-live-audio-stream`, `react-native-sound` and `react-native-fs` (optional peer dependencies); Expo or other stacks can pass their own. Without them the chat works and the microphone is hidden.
|
|
14
|
+
|
|
15
|
+
## 1.0.0
|
|
16
|
+
|
|
17
|
+
* First release.
|
|
18
|
+
* `OryksaClient`: in-app client with short-lived session tokens (agent, send, sendAndWait, messages), refreshes the token when it expires.
|
|
19
|
+
* `OryksaChatButton`, `OryksaChatModal` and `OryksaChat`: ready chat with the look of the ORYKSA website chat, name and photo of the AI from the ORYKSA account, in English, Portuguese (Portugal and Brazil) and Spanish.
|
|
20
|
+
* No native code, works in Expo Go. TypeScript types included.
|
package/README.md
CHANGED
|
@@ -1,98 +1,123 @@
|
|
|
1
|
-
<p align="center"><img src="https://app.oryksa.com/static/oryksa_logo.png" width="300" alt="ORYKSA"></p>
|
|
2
|
-
|
|
3
|
-
# @oryksa/react-native
|
|
4
|
-
|
|
5
|
-
Official React Native SDK for **ORYKSA AI Employees**. Put an AI employee that already knows your business inside your iOS and Android app (React Native or Expo): a ready chat with the same look as the ORYKSA website chat, the name and photo of your AI from your ORYKSA account, in English, Portuguese (Portugal and Brazil) and Spanish.
|
|
6
|
-
|
|
7
|
-
* Docs: https://developer.oryksa.com/en/sdks
|
|
8
|
-
* API: `https://api.oryksa.com/v1`
|
|
9
|
-
* No native code: works in Expo Go.
|
|
10
|
-
|
|
11
|
-
## Install
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npm install @oryksa/react-native
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
##
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
##
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
1
|
+
<p align="center"><img src="https://app.oryksa.com/static/oryksa_logo.png" width="300" alt="ORYKSA"></p>
|
|
2
|
+
|
|
3
|
+
# @oryksa/react-native
|
|
4
|
+
|
|
5
|
+
Official React Native SDK for **ORYKSA AI Employees**. Put an AI employee that already knows your business inside your iOS and Android app (React Native or Expo): a ready chat with the same look as the ORYKSA website chat, the name and photo of your AI from your ORYKSA account, in English, Portuguese (Portugal and Brazil) and Spanish.
|
|
6
|
+
|
|
7
|
+
* Docs: https://developer.oryksa.com/en/sdks
|
|
8
|
+
* API: `https://api.oryksa.com/v1`
|
|
9
|
+
* No native code: works in Expo Go.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @oryksa/react-native
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## What it is for
|
|
18
|
+
|
|
19
|
+
The SDK puts the ORYKSA chat and voice inside your app to serve the **customers of your business**: they ask, buy and book. The AI answers with your Brain, products and services, with the name, photo and voice you chose in *Your AI*, and saves leads, bookings and sales in the Activities of your ORYKSA account. It is **not** an interface for the owner: nobody changes settings, reads Activities or gives orders to ORYKSA through the SDK. More: https://help.oryksa.com/en/a/sdks-what-they-do
|
|
20
|
+
|
|
21
|
+
Swear words the customer types show as asterisks in the chat (the same list as every ORYKSA chat, loaded from `https://app.oryksa.com/widget/profanity.json`, kept 24 hours). The AI's replies already come filtered from the server.
|
|
22
|
+
|
|
23
|
+
## Voice and app context (1.1)
|
|
24
|
+
|
|
25
|
+
The chat shows a microphone when your plan has voice. It opens the voice screen with the same behaviour as the ORYKSA app: the microphone stays open while she speaks and only a human voice cuts her off (typing, TV and her own echo do not); she stops on the word and the text stays in the chat; a whisper gets a whispered answer; if her voice fails, the text is shown (never a robot voice).
|
|
26
|
+
|
|
27
|
+
Voice needs three native libraries (optional peer dependencies) and the microphone permission (Android `RECORD_AUDIO`, iOS `NSMicrophoneUsageDescription`):
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
npm install react-native-live-audio-stream react-native-sound react-native-fs
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Without them the chat works and the microphone is hidden. Expo or another audio stack: pass your own `audio` adapter (`startMic`, `stopMic`, `play`, `stopPlayback`).
|
|
34
|
+
|
|
35
|
+
Each reply of the AI has a copy button under it. It uses `@react-native-clipboard/clipboard` when installed (optional peer dependency: `npm install @react-native-clipboard/clipboard`); older React Native versions use the built-in `Clipboard`.
|
|
36
|
+
|
|
37
|
+
```jsx
|
|
38
|
+
<OryksaChatButton client={client} lang="pt"
|
|
39
|
+
appContext={() => ({ screen: "product", title: "Sky Beginner Snowboard, 489.95" })} />
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## How it works (and why the key stays safe)
|
|
43
|
+
|
|
44
|
+
1. Your **server** keeps the secret API key (`oryk_live_...`, created at developer.oryksa.com) and creates a short-lived **session token** for each signed-in user with `POST /v1/sessions` (with `@oryksa/sdk` on Node: `oryksa.createSession(...)`).
|
|
45
|
+
2. Your **app** receives only that session token (`oryk_cs_...`). The secret key never goes into the app.
|
|
46
|
+
3. Every AI reply counts as one interaction of your ORYKSA plan, the same as on WhatsApp.
|
|
47
|
+
|
|
48
|
+
## In the app
|
|
49
|
+
|
|
50
|
+
```jsx
|
|
51
|
+
import { OryksaClient, OryksaChatButton } from "@oryksa/react-native";
|
|
52
|
+
|
|
53
|
+
const client = new OryksaClient({
|
|
54
|
+
getToken: async () => (await fetch("https://your-server.example/oryksa-token").then((r) => r.json())).token,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export default function App() {
|
|
58
|
+
return (
|
|
59
|
+
<View style={{ flex: 1 }}>
|
|
60
|
+
<MyScreens />
|
|
61
|
+
<OryksaChatButton client={client} lang="en" /> {/* en, pt, br, es */}
|
|
62
|
+
</View>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Other pieces:
|
|
68
|
+
|
|
69
|
+
* `<OryksaChatModal client={client} visible={open} onClose={() => setOpen(false)} />`: open the chat from your own button.
|
|
70
|
+
* `<OryksaChat client={client} />`: the panel inside any screen.
|
|
71
|
+
* `theme={{ accent: "#5B57E0" }}`: colors.
|
|
72
|
+
* Without the UI: `await client.agent()`, `await client.sendAndWait("Are you open on Saturday?")`, `await client.messages()`.
|
|
73
|
+
|
|
74
|
+
## Keep the AI in sync with your app
|
|
75
|
+
|
|
76
|
+
On your server, with `@oryksa/sdk`:
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
await oryksa.learnApp({ name: "FitTrack", description: "...", screens: [...], faq: [...] });
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Errors
|
|
83
|
+
|
|
84
|
+
Failed calls throw `OryksaError` with `status`, `code` (for example `interaction_limit_reached`, `rate_limited`, `plan_required`) and `message`.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Português (Portugal)
|
|
89
|
+
|
|
90
|
+
SDK oficial de React Native da **ORYKSA AI Employees**: põe na tua app iOS e Android um colaborador de IA que já conhece o teu negócio, com um chat pronto igual ao chat do site da ORYKSA, com o nome e a foto da tua IA.
|
|
91
|
+
|
|
92
|
+
1. O teu **servidor** guarda a chave secreta e cria um token de sessão para cada utilizador (`POST /v1/sessions`).
|
|
93
|
+
2. A **app** usa só esse token: `new OryksaClient({ getToken })` e `<OryksaChatButton client={client} lang="pt" />`.
|
|
94
|
+
3. Cada resposta da IA conta como uma interação do teu plano.
|
|
95
|
+
|
|
96
|
+
## Português (Brasil)
|
|
97
|
+
|
|
98
|
+
SDK oficial de React Native da **ORYKSA AI Employees**: coloque no seu app iOS e Android um colaborador de IA que já conhece o seu negócio, com um chat pronto igual ao chat do site da ORYKSA, com o nome e a foto da sua IA.
|
|
99
|
+
|
|
100
|
+
1. Seu **servidor** guarda a chave secreta e cria um token de sessão para cada usuário (`POST /v1/sessions`).
|
|
101
|
+
2. O **app** usa só esse token: `new OryksaClient({ getToken })` e `<OryksaChatButton client={client} lang="br" />`.
|
|
102
|
+
3. Cada resposta da IA conta como uma interação do seu plano.
|
|
103
|
+
|
|
104
|
+
## Español
|
|
105
|
+
|
|
106
|
+
SDK oficial de React Native de **ORYKSA AI Employees**: pon en tu app iOS y Android un empleado de IA que ya conoce tu negocio, con un chat listo igual al chat de la web de ORYKSA, con el nombre y la foto de tu IA.
|
|
107
|
+
|
|
108
|
+
1. Tu **servidor** guarda la clave secreta y crea un token de sesión para cada usuario (`POST /v1/sessions`).
|
|
109
|
+
2. La **app** usa solo ese token: `new OryksaClient({ getToken })` y `<OryksaChatButton client={client} lang="es" />`.
|
|
110
|
+
3. Cada respuesta de la IA cuenta como una interacción de tu plan.
|
|
111
|
+
|
|
112
|
+
## About the author
|
|
113
|
+
|
|
114
|
+
**Weslley Harakawa** - Founder of ORYKSA AI. Based in Lisbon, Portugal. Specialties: artificial intelligence, web and mobile development, blockchain tokenization. Education: University of the People.
|
|
115
|
+
|
|
116
|
+
- Website: https://harakawa.tech
|
|
117
|
+
- LinkedIn: https://www.linkedin.com/in/weslleyharakawa/
|
|
118
|
+
- Instagram: https://www.instagram.com/weslley.harakawa
|
|
119
|
+
- ORYKSA AI Employees: https://oryksa.com (X: https://x.com/oryksa, Instagram: https://www.instagram.com/oryksaai, YouTube: https://www.youtube.com/@ORYKSAAI)
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
MIT License · ORYKSA AI Employees · W8 Atlantic Unipessoal Lda
|
package/package.json
CHANGED
|
@@ -1,21 +1,61 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@oryksa/react-native",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Official React Native SDK for ORYKSA AI Employees: a ready in-app AI chat
|
|
5
|
-
"main": "src/index.js",
|
|
6
|
-
"types": "src/index.d.ts",
|
|
7
|
-
"react-native": "src/index.js",
|
|
8
|
-
"files": [
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@oryksa/react-native",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Official React Native SDK for ORYKSA AI Employees: a ready in-app AI chat and voice (the same as the ORYKSA app), and a client for the ORYKSA API v1.",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"types": "src/index.d.ts",
|
|
7
|
+
"react-native": "src/index.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"src",
|
|
10
|
+
"README.md",
|
|
11
|
+
"LICENSE",
|
|
12
|
+
"CHANGELOG.md"
|
|
13
|
+
],
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"scripts": {
|
|
16
|
+
"test": "node test/client.test.js && node test/vad.test.js && node test/voice.test.js && node test/profanity.test.js"
|
|
17
|
+
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"react": ">=17.0.0",
|
|
20
|
+
"react-native": ">=0.68.0",
|
|
21
|
+
"react-native-live-audio-stream": ">=1.1.0",
|
|
22
|
+
"react-native-sound": ">=0.11.0",
|
|
23
|
+
"react-native-fs": ">=2.18.0",
|
|
24
|
+
"@react-native-clipboard/clipboard": ">=1.11.0"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"oryksa",
|
|
28
|
+
"react-native",
|
|
29
|
+
"ai",
|
|
30
|
+
"chatbot",
|
|
31
|
+
"customer-support",
|
|
32
|
+
"chat",
|
|
33
|
+
"sdk",
|
|
34
|
+
"expo",
|
|
35
|
+
"voice"
|
|
36
|
+
],
|
|
37
|
+
"homepage": "https://developer.oryksa.com/en/sdks",
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "https://github.com/oryksa/oryksa-react-native"
|
|
41
|
+
},
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/oryksa/oryksa-react-native/issues"
|
|
44
|
+
},
|
|
45
|
+
"author": "ORYKSA AI Employees (https://oryksa.com)",
|
|
46
|
+
"license": "MIT",
|
|
47
|
+
"peerDependenciesMeta": {
|
|
48
|
+
"react-native-live-audio-stream": {
|
|
49
|
+
"optional": true
|
|
50
|
+
},
|
|
51
|
+
"react-native-sound": {
|
|
52
|
+
"optional": true
|
|
53
|
+
},
|
|
54
|
+
"react-native-fs": {
|
|
55
|
+
"optional": true
|
|
56
|
+
},
|
|
57
|
+
"@react-native-clipboard/clipboard": {
|
|
58
|
+
"optional": true
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|