@oryksa/react-native 1.1.2 → 1.1.3
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 +37 -29
- package/README.es.md +161 -119
- package/README.fr.md +161 -119
- package/README.md +161 -119
- package/README.pt.md +161 -119
- package/package.json +69 -61
- package/src/attach.js +133 -0
- package/src/chat.js +102 -21
- package/src/client.js +267 -233
- package/src/index.d.ts +86 -0
- package/src/index.js +12 -0
- package/src/link-card.js +74 -0
- package/src/links.js +115 -0
- package/src/voice-screen.js +15 -8
- package/src/voice.js +9 -2
package/README.fr.md
CHANGED
|
@@ -1,119 +1,161 @@
|
|
|
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
|
-
[](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 React Native officiel d'**ORYKSA AI Employees**. Mettez dans votre app iOS et Android (React Native ou Expo) un employé IA qui connaît déjà votre entreprise : un chat prêt à l'emploi identique au chat du site ORYKSA, le nom et la photo de votre IA issus de votre compte ORYKSA, en anglais, portugais et espagnol.
|
|
10
|
-
|
|
11
|
-
* Documentation : https://developer.oryksa.com/fr/sdks
|
|
12
|
-
* API : `https://api.oryksa.com/v1`
|
|
13
|
-
* Aucun code natif : fonctionne dans Expo Go.
|
|
14
|
-
|
|
15
|
-
## Captures d'écran
|
|
16
|
-
|
|
17
|
-
<p align="center"><img src="https://raw.githubusercontent.com/oryksa/oryksa-react-native/main/docs/screenshots/rn_product_en.png" width="230" alt="Product page with the chat button"> <img src="https://raw.githubusercontent.com/oryksa/oryksa-react-native/main/docs/screenshots/rn_chat_en.png" width="230" alt="Chat"> <img src="https://raw.githubusercontent.com/oryksa/oryksa-react-native/main/docs/screenshots/rn_theme_en.png" width="230" alt="Chat with the README theme"></p>
|
|
18
|
-
|
|
19
|
-
Les composants du SDK eux-mêmes, affichés par la CI dans Chrome au format téléphone avec React Native for Web et un compte de test ORYKSA (`test/web/`). Sur un téléphone, le chat affiche aussi le micro, qui nécessite les bibliothèques audio natives. Le chat vert utilise le code de *Couleurs et thème*, plus bas.
|
|
20
|
-
|
|
21
|
-
## Installer
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
npm install @oryksa/react-native
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## À quoi il sert
|
|
28
|
-
|
|
29
|
-
Le SDK met le chat et la voix ORYKSA dans votre app pour servir les **clients de votre entreprise** : ils posent des questions, achètent et réservent. L'IA répond avec votre Brain, vos produits et vos services, avec le nom, la photo et la voix que vous avez choisis dans *Votre IA*, et enregistre les leads, réservations et ventes dans les Activités de votre compte ORYKSA. Ce n'est **pas** une interface pour le propriétaire : via le SDK, personne ne modifie les paramètres, ne lit les Activités ni ne donne d'ordres à ORYKSA. En savoir plus : https://help.oryksa.com/fr/a/sdks-what-they-do
|
|
30
|
-
|
|
31
|
-
Les gros mots que le client tape apparaissent sous forme d'astérisques dans le chat (la même liste que tous les chats ORYKSA, chargée depuis `https://app.oryksa.com/widget/profanity.json`, conservée 24 heures). Les réponses de l'IA arrivent déjà filtrées par le serveur.
|
|
32
|
-
|
|
33
|
-
## Voix et contexte de l'app (1.1)
|
|
34
|
-
|
|
35
|
-
Le chat affiche un micro quand votre forfait inclut la voix. Il ouvre l'écran vocal avec le même comportement que l'app ORYKSA : le micro reste ouvert pendant qu'elle parle et seule une voix humaine l'interrompt (la frappe au clavier, la télévision et son propre écho ne l'interrompent pas) ; elle s'arrête sur le mot et le texte reste dans le chat ; à un chuchotement, elle répond en chuchotant ; si sa voix échoue, le texte est affiché (jamais une voix robotique).
|
|
36
|
-
|
|
37
|
-
La voix nécessite trois bibliothèques natives (dépendances peer optionnelles) et l'autorisation du micro (Android `RECORD_AUDIO`, iOS `NSMicrophoneUsageDescription`) :
|
|
38
|
-
|
|
39
|
-
```sh
|
|
40
|
-
npm install react-native-live-audio-stream react-native-sound react-native-fs
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Sans elles, le chat fonctionne et le micro est masqué. Avec Expo ou une autre pile audio : passez votre propre adaptateur `audio` (`startMic`, `stopMic`, `play`, `stopPlayback`).
|
|
44
|
-
|
|
45
|
-
Chaque réponse de l'IA a un bouton copier en dessous. Il utilise `@react-native-clipboard/clipboard` s'il est installé (dépendance peer optionnelle : `npm install @react-native-clipboard/clipboard`) ; les versions plus anciennes de React Native utilisent le `Clipboard` intégré.
|
|
46
|
-
|
|
47
|
-
```jsx
|
|
48
|
-
<OryksaChatButton client={client} lang="pt"
|
|
49
|
-
appContext={() => ({ screen: "product", title: "Sky Beginner Snowboard, 489.95" })} />
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
+
[](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 React Native officiel d'**ORYKSA AI Employees**. Mettez dans votre app iOS et Android (React Native ou Expo) un employé IA qui connaît déjà votre entreprise : un chat prêt à l'emploi identique au chat du site ORYKSA, le nom et la photo de votre IA issus de votre compte ORYKSA, en anglais, portugais et espagnol.
|
|
10
|
+
|
|
11
|
+
* Documentation : https://developer.oryksa.com/fr/sdks
|
|
12
|
+
* API : `https://api.oryksa.com/v1`
|
|
13
|
+
* Aucun code natif : fonctionne dans Expo Go.
|
|
14
|
+
|
|
15
|
+
## Captures d'écran
|
|
16
|
+
|
|
17
|
+
<p align="center"><img src="https://raw.githubusercontent.com/oryksa/oryksa-react-native/main/docs/screenshots/rn_product_en.png" width="230" alt="Product page with the chat button"> <img src="https://raw.githubusercontent.com/oryksa/oryksa-react-native/main/docs/screenshots/rn_chat_en.png" width="230" alt="Chat"> <img src="https://raw.githubusercontent.com/oryksa/oryksa-react-native/main/docs/screenshots/rn_theme_en.png" width="230" alt="Chat with the README theme"></p>
|
|
18
|
+
|
|
19
|
+
Les composants du SDK eux-mêmes, affichés par la CI dans Chrome au format téléphone avec React Native for Web et un compte de test ORYKSA (`test/web/`). Sur un téléphone, le chat affiche aussi le micro, qui nécessite les bibliothèques audio natives. Le chat vert utilise le code de *Couleurs et thème*, plus bas.
|
|
20
|
+
|
|
21
|
+
## Installer
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @oryksa/react-native
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## À quoi il sert
|
|
28
|
+
|
|
29
|
+
Le SDK met le chat et la voix ORYKSA dans votre app pour servir les **clients de votre entreprise** : ils posent des questions, achètent et réservent. L'IA répond avec votre Brain, vos produits et vos services, avec le nom, la photo et la voix que vous avez choisis dans *Votre IA*, et enregistre les leads, réservations et ventes dans les Activités de votre compte ORYKSA. Ce n'est **pas** une interface pour le propriétaire : via le SDK, personne ne modifie les paramètres, ne lit les Activités ni ne donne d'ordres à ORYKSA. En savoir plus : https://help.oryksa.com/fr/a/sdks-what-they-do
|
|
30
|
+
|
|
31
|
+
Les gros mots que le client tape apparaissent sous forme d'astérisques dans le chat (la même liste que tous les chats ORYKSA, chargée depuis `https://app.oryksa.com/widget/profanity.json`, conservée 24 heures). Les réponses de l'IA arrivent déjà filtrées par le serveur.
|
|
32
|
+
|
|
33
|
+
## Voix et contexte de l'app (1.1)
|
|
34
|
+
|
|
35
|
+
Le chat affiche un micro quand votre forfait inclut la voix. Il ouvre l'écran vocal avec le même comportement que l'app ORYKSA : le micro reste ouvert pendant qu'elle parle et seule une voix humaine l'interrompt (la frappe au clavier, la télévision et son propre écho ne l'interrompent pas) ; elle s'arrête sur le mot et le texte reste dans le chat ; à un chuchotement, elle répond en chuchotant ; si sa voix échoue, le texte est affiché (jamais une voix robotique).
|
|
36
|
+
|
|
37
|
+
La voix nécessite trois bibliothèques natives (dépendances peer optionnelles) et l'autorisation du micro (Android `RECORD_AUDIO`, iOS `NSMicrophoneUsageDescription`) :
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npm install react-native-live-audio-stream react-native-sound react-native-fs
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Sans elles, le chat fonctionne et le micro est masqué. Avec Expo ou une autre pile audio : passez votre propre adaptateur `audio` (`startMic`, `stopMic`, `play`, `stopPlayback`).
|
|
44
|
+
|
|
45
|
+
Chaque réponse de l'IA a un bouton copier en dessous. Il utilise `@react-native-clipboard/clipboard` s'il est installé (dépendance peer optionnelle : `npm install @react-native-clipboard/clipboard`) ; les versions plus anciennes de React Native utilisent le `Clipboard` intégré.
|
|
46
|
+
|
|
47
|
+
```jsx
|
|
48
|
+
<OryksaChatButton client={client} lang="pt"
|
|
49
|
+
appContext={() => ({ screen: "product", title: "Sky Beginner Snowboard, 489.95" })} />
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Liens avec un bouton pour les ouvrir (1.1.3)
|
|
53
|
+
|
|
54
|
+
Les liens que donne l'IA se touchent dans le chat (adresses web et e-mails), et chaque lien web a une carte sous sa réponse avec la photo et le titre de la page et un bouton pour l'ouvrir (les pages de votre propre site, les domaines de votre chat web ; les autres sites montrent l'adresse). L'écran vocal montre ce qu'elle dit sans les adresses, avec les mêmes cartes ; toucher le bouton ferme l'écran vocal. Passez `onLink` pour ouvrir vos propres écrans, par exemple la page du produit : renvoyez true quand votre app l'a ouvert, false pour laisser le système l'ouvrir (`Linking.openURL`).
|
|
55
|
+
|
|
56
|
+
```jsx
|
|
57
|
+
<OryksaChatButton client={client} lang="en"
|
|
58
|
+
onLink={(url) => {
|
|
59
|
+
const id = myProductIdOf(url); // vos routes
|
|
60
|
+
if (!id) return false;
|
|
61
|
+
navigation.navigate("Product", { id });
|
|
62
|
+
return true;
|
|
63
|
+
}} />
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`onLink` existe aussi sur `OryksaChat`, `OryksaChatModal` et `OryksaVoiceScreen`.
|
|
67
|
+
|
|
68
|
+
## Joindre une photo ou un document (1.1.3)
|
|
69
|
+
|
|
70
|
+
Le chat a un bouton pour joindre (un trombone, activé par défaut) : une photo de la galerie, une photo de l'appareil photo ou un document (PDF, Word, texte, CSV, jusqu'à 8 Mo). L'IA regarde la photo (réduite à 1600 pixels, JPEG 80 %, jusqu'à 2 Mo) et lit le document ; la bulle du client montre la photo, ou l'icône du document et son nom. `attachments={false}` masque le bouton.
|
|
71
|
+
|
|
72
|
+
React Native n'a pas de sélecteur propre, donc le SDK utilise deux bibliothèques optionnelles que votre app installe (dépendances peer optionnelles, comme celles de la voix). Chaque option n'apparaît que lorsque sa bibliothèque est là ; sans les deux, le bouton est masqué :
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
npm install react-native-image-picker @react-native-documents/picker
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
* `react-native-image-picker` : galerie et appareil photo. Info.plist iOS : `NSPhotoLibraryUsageDescription` et `NSCameraUsageDescription`. Android : aucune autorisation pour la galerie ; pour l'appareil photo, `CAMERA` n'est nécessaire que si votre app la déclare dans son propre manifest (accordez-la alors avant d'ouvrir l'appareil photo).
|
|
79
|
+
* `@react-native-documents/picker` : documents, dans le sélecteur de documents du système (sans autorisation). Les documents sont lus avec `react-native-fs` quand il est installé, sinon avec `fetch`.
|
|
80
|
+
|
|
81
|
+
```jsx
|
|
82
|
+
<OryksaChatButton client={client} lang="en" attachments={false} /> {/* sans bouton pour joindre */}
|
|
83
|
+
|
|
84
|
+
// Expo ou une autre stack : vos propres sélecteurs (s'il en manque un, ce choix est masqué)
|
|
85
|
+
const picker = {
|
|
86
|
+
pickPhoto: () => myPhotoPicker(), // { base64, mime } réduite (1600 px, JPEG 80 %), ou null
|
|
87
|
+
pickDocument: () => myDocumentPicker(), // { base64, name, mime }, ou null
|
|
88
|
+
};
|
|
89
|
+
<OryksaChat client={client} picker={picker} />
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Sans l'interface : `client.send("Voici le devis", { file: { base64, name: "devis.pdf", mime: "application/pdf" } })` (photos : `{ image: { base64, mime } }`).
|
|
93
|
+
|
|
94
|
+
## Comment ça marche (et pourquoi la clé reste en sécurité)
|
|
95
|
+
|
|
96
|
+
1. Votre **serveur** garde la clé API secrète (`oryk_live_...`, créée sur developer.oryksa.com) et crée un **jeton de session** de courte durée pour chaque utilisateur connecté avec `POST /v1/sessions` (avec `@oryksa/sdk` sur Node : `oryksa.createSession(...)`).
|
|
97
|
+
2. Votre **app** ne reçoit que ce jeton de session (`oryk_cs_...`). La clé secrète n'entre jamais dans l'app.
|
|
98
|
+
3. Chaque réponse de l'IA compte comme une interaction de votre forfait ORYKSA, comme sur WhatsApp.
|
|
99
|
+
|
|
100
|
+
## Dans l'app
|
|
101
|
+
|
|
102
|
+
```jsx
|
|
103
|
+
import { OryksaClient, OryksaChatButton } from "@oryksa/react-native";
|
|
104
|
+
|
|
105
|
+
const client = new OryksaClient({
|
|
106
|
+
getToken: async () => (await fetch("https://your-server.example/oryksa-token").then((r) => r.json())).token,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
export default function App() {
|
|
110
|
+
return (
|
|
111
|
+
<View style={{ flex: 1 }}>
|
|
112
|
+
<MyScreens />
|
|
113
|
+
<OryksaChatButton client={client} lang="en" /> {/* en, pt, br, es */}
|
|
114
|
+
</View>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Autres éléments :
|
|
120
|
+
|
|
121
|
+
* `<OryksaChatModal client={client} visible={open} onClose={() => setOpen(false)} />` : ouvrir le chat depuis votre propre bouton.
|
|
122
|
+
* `<OryksaChat client={client} />` : le panneau dans n'importe quel écran.
|
|
123
|
+
* `theme={{ accent: "#5B57E0" }}` : couleurs.
|
|
124
|
+
* Sans l'interface : `await client.agent()`, `await client.sendAndWait("Are you open on Saturday?")`, `await client.messages()`.
|
|
125
|
+
|
|
126
|
+
## Garder l'IA synchronisée avec votre app
|
|
127
|
+
|
|
128
|
+
Sur votre serveur, avec `@oryksa/sdk` :
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
await oryksa.learnApp({ name: "FitTrack", description: "...", screens: [...], faq: [...] });
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Erreurs
|
|
135
|
+
|
|
136
|
+
Les appels qui échouent lèvent `OryksaError` avec `status`, `code` (par exemple `interaction_limit_reached`, `rate_limited`, `plan_required`) et `message`.
|
|
137
|
+
|
|
138
|
+
## Couleurs et thème
|
|
139
|
+
|
|
140
|
+
La prop `theme` prend un objet avec jusqu'à cinq couleurs en texte hexadécimal : `accent` (boutons, bulles du visiteur, liens), `ink` (texte principal), `soft` (bulles de l'IA), `background` (panneau) et `muted` (texte secondaire). Les clés absentes gardent la valeur par défaut, donc `{ accent: "#0E8A6B" }` suffit. Cela fonctionne sur `OryksaChatButton`, `OryksaChatModal` et `OryksaChat`, et les valeurs par défaut sont exportées sous `DEFAULT_THEME`.
|
|
141
|
+
|
|
142
|
+
```jsx
|
|
143
|
+
const theme = { accent: "#0E8A6B" };
|
|
144
|
+
|
|
145
|
+
<OryksaChatButton client={client} lang="en" theme={theme} />
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Il n'y a pas de thème sombre automatique : pour le mode sombre, passez vos propres couleurs sombres.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## À propos de l'auteur
|
|
153
|
+
|
|
154
|
+
**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.
|
|
155
|
+
|
|
156
|
+
- LinkedIn: https://www.linkedin.com/in/weslleyharakawa/
|
|
157
|
+
- ORYKSA AI Employees: https://oryksa.com (X: https://x.com/oryksa, Instagram: https://www.instagram.com/oryksaai, YouTube: https://www.youtube.com/@ORYKSA)
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
MIT License · ORYKSA AI Employees · W8 Atlantic Unipessoal Lda
|
package/README.md
CHANGED
|
@@ -1,119 +1,161 @@
|
|
|
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
|
-
[](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
|
-
|
|
9
|
-
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 and Spanish.
|
|
10
|
-
|
|
11
|
-
* Docs: https://developer.oryksa.com/en/sdks
|
|
12
|
-
* API: `https://api.oryksa.com/v1`
|
|
13
|
-
* No native code: works in Expo Go.
|
|
14
|
-
|
|
15
|
-
## Screenshots
|
|
16
|
-
|
|
17
|
-
<p align="center"><img src="https://raw.githubusercontent.com/oryksa/oryksa-react-native/main/docs/screenshots/rn_product_en.png" width="230" alt="Product page with the chat button"> <img src="https://raw.githubusercontent.com/oryksa/oryksa-react-native/main/docs/screenshots/rn_chat_en.png" width="230" alt="Chat"> <img src="https://raw.githubusercontent.com/oryksa/oryksa-react-native/main/docs/screenshots/rn_theme_en.png" width="230" alt="Chat with the README theme"></p>
|
|
18
|
-
|
|
19
|
-
The SDK components themselves, rendered by CI in Chrome at phone size with React Native for Web and an ORYKSA test account (`test/web/`). On a phone the chat also shows the microphone, which needs the native audio libraries. The green chat uses the code of *Colours and theme* below.
|
|
20
|
-
|
|
21
|
-
## Install
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
npm install @oryksa/react-native
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## What it is for
|
|
28
|
-
|
|
29
|
-
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
|
|
30
|
-
|
|
31
|
-
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.
|
|
32
|
-
|
|
33
|
-
## Voice and app context (1.1)
|
|
34
|
-
|
|
35
|
-
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).
|
|
36
|
-
|
|
37
|
-
Voice needs three native libraries (optional peer dependencies) and the microphone permission (Android `RECORD_AUDIO`, iOS `NSMicrophoneUsageDescription`):
|
|
38
|
-
|
|
39
|
-
```sh
|
|
40
|
-
npm install react-native-live-audio-stream react-native-sound react-native-fs
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Without them the chat works and the microphone is hidden. Expo or another audio stack: pass your own `audio` adapter (`startMic`, `stopMic`, `play`, `stopPlayback`).
|
|
44
|
-
|
|
45
|
-
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`.
|
|
46
|
-
|
|
47
|
-
```jsx
|
|
48
|
-
<OryksaChatButton client={client} lang="pt"
|
|
49
|
-
appContext={() => ({ screen: "product", title: "Sky Beginner Snowboard, 489.95" })} />
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
+
[](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
|
+
|
|
9
|
+
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 and Spanish.
|
|
10
|
+
|
|
11
|
+
* Docs: https://developer.oryksa.com/en/sdks
|
|
12
|
+
* API: `https://api.oryksa.com/v1`
|
|
13
|
+
* No native code: works in Expo Go.
|
|
14
|
+
|
|
15
|
+
## Screenshots
|
|
16
|
+
|
|
17
|
+
<p align="center"><img src="https://raw.githubusercontent.com/oryksa/oryksa-react-native/main/docs/screenshots/rn_product_en.png" width="230" alt="Product page with the chat button"> <img src="https://raw.githubusercontent.com/oryksa/oryksa-react-native/main/docs/screenshots/rn_chat_en.png" width="230" alt="Chat"> <img src="https://raw.githubusercontent.com/oryksa/oryksa-react-native/main/docs/screenshots/rn_theme_en.png" width="230" alt="Chat with the README theme"></p>
|
|
18
|
+
|
|
19
|
+
The SDK components themselves, rendered by CI in Chrome at phone size with React Native for Web and an ORYKSA test account (`test/web/`). On a phone the chat also shows the microphone, which needs the native audio libraries. The green chat uses the code of *Colours and theme* below.
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @oryksa/react-native
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## What it is for
|
|
28
|
+
|
|
29
|
+
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
|
|
30
|
+
|
|
31
|
+
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.
|
|
32
|
+
|
|
33
|
+
## Voice and app context (1.1)
|
|
34
|
+
|
|
35
|
+
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).
|
|
36
|
+
|
|
37
|
+
Voice needs three native libraries (optional peer dependencies) and the microphone permission (Android `RECORD_AUDIO`, iOS `NSMicrophoneUsageDescription`):
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npm install react-native-live-audio-stream react-native-sound react-native-fs
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Without them the chat works and the microphone is hidden. Expo or another audio stack: pass your own `audio` adapter (`startMic`, `stopMic`, `play`, `stopPlayback`).
|
|
44
|
+
|
|
45
|
+
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`.
|
|
46
|
+
|
|
47
|
+
```jsx
|
|
48
|
+
<OryksaChatButton client={client} lang="pt"
|
|
49
|
+
appContext={() => ({ screen: "product", title: "Sky Beginner Snowboard, 489.95" })} />
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Links with an Open button (1.1.3)
|
|
53
|
+
|
|
54
|
+
The links the AI gives can be tapped in the chat (web addresses and e-mails), and each web link gets a card under her reply with the picture and title of the page and an **Open** button (the pages of your own site, the domains of your website chat; other sites show the address). The voice screen shows what she says without the addresses, with the same cards; tapping Open closes the voice screen. Pass `onLink` to open your own screens, for example your product page: return true when your app opened it, false to let the system open it (`Linking.openURL`).
|
|
55
|
+
|
|
56
|
+
```jsx
|
|
57
|
+
<OryksaChatButton client={client} lang="en"
|
|
58
|
+
onLink={(url) => {
|
|
59
|
+
const id = myProductIdOf(url); // your routes
|
|
60
|
+
if (!id) return false;
|
|
61
|
+
navigation.navigate("Product", { id });
|
|
62
|
+
return true;
|
|
63
|
+
}} />
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`onLink` is also on `OryksaChat`, `OryksaChatModal` and `OryksaVoiceScreen`.
|
|
67
|
+
|
|
68
|
+
## Attach a photo or a document (1.1.3)
|
|
69
|
+
|
|
70
|
+
The chat has an attach button (a paperclip, on by default): a photo from the library, a photo from the camera, or a document (PDF, Word, text, CSV, up to 8 MB). The AI looks at the photo (made smaller to 1600 pixels, JPEG 80%, up to 2 MB) and reads the document; the customer's bubble shows the photo, or the document icon and its name. `attachments={false}` hides the button.
|
|
71
|
+
|
|
72
|
+
React Native has no picker of its own, so the SDK uses two optional libraries your app installs (optional peer dependencies, like the voice libraries). Each choice shows only when its library is there; without both, the button is hidden:
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
npm install react-native-image-picker @react-native-documents/picker
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
* `react-native-image-picker`: photo library and camera. iOS Info.plist: `NSPhotoLibraryUsageDescription` and `NSCameraUsageDescription`. Android: no permission for the photo library; for the camera, `CAMERA` is needed only if your app declares it in its own manifest (then grant it before the camera opens).
|
|
79
|
+
* `@react-native-documents/picker`: documents, in the system document picker (no permission). Documents are read with `react-native-fs` when installed, else with `fetch`.
|
|
80
|
+
|
|
81
|
+
```jsx
|
|
82
|
+
<OryksaChatButton client={client} lang="en" attachments={false} /> {/* no attach button */}
|
|
83
|
+
|
|
84
|
+
// Expo or another stack: your own pickers (a missing one hides that choice)
|
|
85
|
+
const picker = {
|
|
86
|
+
pickPhoto: () => myPhotoPicker(), // { base64, mime } made smaller (1600 px, JPEG 80%), or null
|
|
87
|
+
pickDocument: () => myDocumentPicker(), // { base64, name, mime }, or null
|
|
88
|
+
};
|
|
89
|
+
<OryksaChat client={client} picker={picker} />
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Without the UI: `client.send("Here is the quote", { file: { base64, name: "quote.pdf", mime: "application/pdf" } })` (photos: `{ image: { base64, mime } }`).
|
|
93
|
+
|
|
94
|
+
## How it works (and why the key stays safe)
|
|
95
|
+
|
|
96
|
+
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(...)`).
|
|
97
|
+
2. Your **app** receives only that session token (`oryk_cs_...`). The secret key never goes into the app.
|
|
98
|
+
3. Every AI reply counts as one interaction of your ORYKSA plan, the same as on WhatsApp.
|
|
99
|
+
|
|
100
|
+
## In the app
|
|
101
|
+
|
|
102
|
+
```jsx
|
|
103
|
+
import { OryksaClient, OryksaChatButton } from "@oryksa/react-native";
|
|
104
|
+
|
|
105
|
+
const client = new OryksaClient({
|
|
106
|
+
getToken: async () => (await fetch("https://your-server.example/oryksa-token").then((r) => r.json())).token,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
export default function App() {
|
|
110
|
+
return (
|
|
111
|
+
<View style={{ flex: 1 }}>
|
|
112
|
+
<MyScreens />
|
|
113
|
+
<OryksaChatButton client={client} lang="en" /> {/* en, pt, br, es */}
|
|
114
|
+
</View>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Other pieces:
|
|
120
|
+
|
|
121
|
+
* `<OryksaChatModal client={client} visible={open} onClose={() => setOpen(false)} />`: open the chat from your own button.
|
|
122
|
+
* `<OryksaChat client={client} />`: the panel inside any screen.
|
|
123
|
+
* `theme={{ accent: "#5B57E0" }}`: colors.
|
|
124
|
+
* Without the UI: `await client.agent()`, `await client.sendAndWait("Are you open on Saturday?")`, `await client.messages()`.
|
|
125
|
+
|
|
126
|
+
## Keep the AI in sync with your app
|
|
127
|
+
|
|
128
|
+
On your server, with `@oryksa/sdk`:
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
await oryksa.learnApp({ name: "FitTrack", description: "...", screens: [...], faq: [...] });
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Errors
|
|
135
|
+
|
|
136
|
+
Failed calls throw `OryksaError` with `status`, `code` (for example `interaction_limit_reached`, `rate_limited`, `plan_required`) and `message`.
|
|
137
|
+
|
|
138
|
+
## Colours and theme
|
|
139
|
+
|
|
140
|
+
The `theme` prop takes an object with up to five colors as hex strings: `accent` (buttons, visitor bubbles, links), `ink` (main text), `soft` (AI bubbles), `background` (panel) and `muted` (secondary text). Missing keys keep the default, so `{ accent: "#0E8A6B" }` is enough. It works on `OryksaChatButton`, `OryksaChatModal` and `OryksaChat`, and the defaults are exported as `DEFAULT_THEME`.
|
|
141
|
+
|
|
142
|
+
```jsx
|
|
143
|
+
const theme = { accent: "#0E8A6B" };
|
|
144
|
+
|
|
145
|
+
<OryksaChatButton client={client} lang="en" theme={theme} />
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
There is no automatic dark theme: for dark mode, pass your own dark colors.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## About the author
|
|
153
|
+
|
|
154
|
+
**Weslley Harakawa** - Founder of ORYKSA AI. Based in Lisbon, Portugal. Specialties: artificial intelligence, web and mobile development, blockchain tokenization. Education: University of the People.
|
|
155
|
+
|
|
156
|
+
- LinkedIn: https://www.linkedin.com/in/weslleyharakawa/
|
|
157
|
+
- ORYKSA AI Employees: https://oryksa.com (X: https://x.com/oryksa, Instagram: https://www.instagram.com/oryksaai, YouTube: https://www.youtube.com/@ORYKSA)
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
MIT License · ORYKSA AI Employees · W8 Atlantic Unipessoal Lda
|