ultron-ai-sdk 1.0.4 β†’ 1.0.6

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.
Files changed (4) hide show
  1. package/README.md +125 -4
  2. package/dist/index.cjs +2 -45241
  3. package/dist/index.mjs +1 -45235
  4. package/package.json +54 -53
package/README.md CHANGED
@@ -7,6 +7,8 @@
7
7
 
8
8
  ## Installation
9
9
 
10
+ ### Via npm
11
+
10
12
  ```bash
11
13
  npm install ultron-ai-sdk
12
14
 
@@ -26,7 +28,6 @@ npm install ultron-ai-sdk
26
28
  const initializationSetting= {
27
29
  avatarId: "AVATAR_ID", // AvatarId and Request Id are same
28
30
  config:{
29
- accessToken: 'YOUR_CURRENT_AUTH_TOKEN', // Can be accessed from your app.ultronai.me localstorage data
30
31
  apiKey: "YOUR_ULTRON_API_KEY"
31
32
  },
32
33
  options:{
@@ -41,6 +42,56 @@ npm install ultron-ai-sdk
41
42
 
42
43
  ```
43
44
 
45
+ ### In HTML Via CDN like [jsDelivr](https://www.jsdelivr.com/).
46
+
47
+
48
+ ```html
49
+
50
+ <script type="importmap">
51
+ {
52
+ "imports": {
53
+ "ultron-ai-sdk": "https://cdn.jsdelivr.net/npm/ultron-ai-sdk@1.0.4/dist/index.mjs?module"
54
+ }
55
+ }
56
+ </script>
57
+
58
+ <script type="module">
59
+ import {SceneCanvas, Character} from 'ultron-ai-sdk';
60
+
61
+ let sceneCanvas
62
+ let character
63
+
64
+ const init = async() => {
65
+ sceneCanvas = new SceneCanvas('target-html-element')
66
+ const initializationSetting= {
67
+ avatarId: "AVATAR_ID", // AvatarId and Request Id are same
68
+ config:{
69
+ apiKey: "YOUR_ULTRON_API_KEY" // Not required if you can create and access "sessionId"
70
+ // sessionId: "SESSION_ID_FOR_CURRENT_USER" // Recomended method for secure access
71
+ },
72
+ options:{
73
+ hideClickMessage: true //remove default "Click message" on the avatar
74
+ alwaysListen: false // For Push to talk conversation
75
+ }
76
+ }
77
+ await sceneCanvas.init(initializationSetting)
78
+ character = sceneCanvas.character
79
+
80
+ // Use "character" object to call various methods like .chat() or .say()
81
+
82
+ // character.say("Hello world")
83
+ // character.chat("Please introduce yourself")
84
+
85
+ //IMPORTANT --->
86
+ // User interaction like click is necessory for the talking of the Avatar to work due to inbuilt security in variuos browser
87
+
88
+ }
89
+ init() // You can also call this on user interaction like clicking on support/chat icon.
90
+
91
+ </script>
92
+
93
+ ```
94
+
44
95
  #### Quick Demo
45
96
 
46
97
  Check out our website for demo at: [πŸ”—Talk to Avatar in metabrix website](https://dev-website.ultronai.me)
@@ -62,8 +113,10 @@ Check out our website for demo at: [πŸ”—Talk to Avatar in metabrix website](http
62
113
  ### Initialization
63
114
 
64
115
  ```javascript
116
+
65
117
  const sceneCanvas = new SceneCanvas('target-html-element')
66
- sceneCanvas.init(config)
118
+ sceneCanvas.init({sessionId: "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxx"})
119
+
67
120
  ```
68
121
 
69
122
  ---
@@ -72,7 +125,6 @@ sceneCanvas.init(config)
72
125
 
73
126
  | Option | Description |
74
127
  |-------------|--------------|
75
- | `accessToken` (optional) | accessToken current logged in Account |
76
128
  | `sessionId` (optional) | Session Id obtained using API key |
77
129
  | `apiKey` | You ultron key which can be found in your profile in Ultron App |
78
130
 
@@ -92,9 +144,78 @@ To get API key of your ultron account follow the steps below
92
144
 
93
145
  ![Avatar ID step 1](https://media.ultronai.me/Images/website/apishe3.png)
94
146
 
147
+ #### Session Id (sessionId)
148
+
149
+ ## πŸ”‘ Create Session API
150
+
151
+ This API allows you to create a new session.
152
+
153
+ ### πŸ“Œ Endpoint
154
+ **POST** `/session/create`
155
+
156
+ ### πŸ”§ Headers:
157
+ | Key | Value |
158
+ |-----------|-----------------|
159
+ | `x-api-key` | your_api_key |
160
+ | `Content-Type` | application/json |
161
+
162
+ ### πŸ“€ Request Body:
163
+ ```json
164
+ {
165
+ "expiresIn": "100",
166
+ "requestID": "xxxxx"
167
+ }
168
+ ```
169
+ ### Response:
170
+ ```json
171
+
172
+ {
173
+ "sessionId": "string",
174
+ "status": "string"
175
+ }
176
+
177
+ ```
178
+
179
+ ```javascript
180
+ async function createSession(apiKey, requestID, expiresIn) {
181
+ const response = await fetch('https://api.ultronai.me/session/create', {
182
+ method: 'POST',
183
+ headers: {
184
+ 'x-api-key': apiKey,
185
+ 'Content-Type': 'application/json'
186
+ },
187
+ body: JSON.stringify({ requestID, expiresIn })
188
+ });
189
+
190
+ const data = await response.json();
191
+ console.log('Session Created:', data);
192
+ }
193
+
194
+ createSession('your_api_key', '123', 10);
195
+
196
+ // Use this sessionId in the SDK in your Web App
197
+ // Call this method on your server side for security and avoid exposing your API key
198
+
199
+ ```
200
+ Note: Please use the method above to get session id on your server side for a secure workflow
95
201
 
96
202
  ---
97
203
 
204
+ ## Options
205
+
206
+ ## Always listen
207
+
208
+ Makes the character listen all the time once click for continous conversation (voice to voice)
209
+
210
+ - `alwaysListen`: **Boolean** - The unique identifier for the avatar
211
+
212
+ ## Hide default click message
213
+
214
+ Hides the default text message on the avatar to prompt user to click as an initial click is required for any audio to play in any browser
215
+
216
+ - `hideClickMessage`: **Boolean** - The unique identifier for the avatar
217
+
218
+
98
219
  ## Core Methods
99
220
 
100
221
  ### loadAvatar(avatarId)
@@ -185,7 +306,7 @@ ultronSDK.setAudioInputDevice(myDevice.deviceId)
185
306
  const initializationSetting= {
186
307
  avatarId: "AVATAR_ID/REQUEST_ID",
187
308
  config:{
188
- apiKey: "YOUR_ULTRON_API_KEY"
309
+ sessionId: "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxx"
189
310
  },
190
311
  options:{
191
312
  alwaysListen: false // For Push to talk conversation