@foisit/angular-wrapper 1.2.0 β 2.0.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/README.md +44 -162
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,88 +1,42 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @foisit/angular-wrapper
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Power your Angular apps with an AI-driven text assistant.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
- π§© **Dynamic Commands**: Add or remove commands on the fly.
|
|
8
|
-
- π¨ **Visual Feedback**: Show visual cues when the assistant is active.
|
|
9
|
-
- π **Effortless Integration**: Set up voice commands in minutes with minimal code.
|
|
10
|
-
- π£οΈ **Voice Feedback**: Interactive voice responses make the assistant engaging.
|
|
11
|
-
- π **Double Activation**: Activate or put the assistant to sleep with a double-tap.
|
|
12
|
-
|
|
13
|
-
### π **Live Demo**
|
|
14
|
-
|
|
15
|
-
π [Test the Angular Assistant here!](https://ng-foisit-demo.netlify.app/)
|
|
5
|
+
> [!NOTE]
|
|
6
|
+
> ποΈ **Coming Soon**: Voice recognition and responses are planned for a future release. Current support is focused on text-based interactions and AI intent matching.
|
|
16
7
|
|
|
17
8
|
---
|
|
18
9
|
|
|
19
10
|
## π Installation
|
|
20
11
|
|
|
21
|
-
Get started by installing the library:
|
|
22
|
-
|
|
23
12
|
```bash
|
|
24
13
|
npm install @foisit/angular-wrapper
|
|
25
14
|
```
|
|
26
15
|
|
|
27
|
-
or
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
yarn add @foisit/angular-wrapper
|
|
31
|
-
```
|
|
32
|
-
|
|
33
16
|
---
|
|
34
17
|
|
|
35
|
-
## π§ Setup
|
|
36
|
-
|
|
37
|
-
Here's how you can integrate the Foisit Assistant into your Angular app in just a few steps:
|
|
38
|
-
|
|
39
|
-
### Step 1: Import the `AssistantModule`
|
|
40
|
-
|
|
41
|
-
#### Using `forRoot` in `app.module.ts`
|
|
18
|
+
## π§ Basic Setup
|
|
42
19
|
|
|
43
|
-
|
|
44
|
-
import { NgModule } from '@angular/core';
|
|
45
|
-
import { BrowserModule } from '@angular/platform-browser';
|
|
46
|
-
import { AppComponent } from './app.component';
|
|
47
|
-
import { AssistantModule } from '@foisit/angular-wrapper';
|
|
20
|
+
### 1. Import `AssistantModule`
|
|
48
21
|
|
|
49
|
-
|
|
50
|
-
declarations: [AppComponent],
|
|
51
|
-
imports: [
|
|
52
|
-
BrowserModule,
|
|
53
|
-
AssistantModule.forRoot({
|
|
54
|
-
activationCommand: 'John',
|
|
55
|
-
fallbackResponse: 'Sorry, I didnβt understand that.',
|
|
56
|
-
commands: [
|
|
57
|
-
{ command: 'show profile', action: () => console.log('Showing profile...') },
|
|
58
|
-
{ command: 'log out', action: () => console.log('Logging out...') },
|
|
59
|
-
],
|
|
60
|
-
}),
|
|
61
|
-
],
|
|
62
|
-
bootstrap: [AppComponent],
|
|
63
|
-
})
|
|
64
|
-
export class AppModule {}
|
|
65
|
-
```
|
|
22
|
+
Add `AssistantModule.forRoot()` to your `app.config.ts` (for Standalone) or `app.module.ts`.
|
|
66
23
|
|
|
67
|
-
####
|
|
24
|
+
#### `app.config.ts` (Standalone)
|
|
68
25
|
|
|
69
26
|
```typescript
|
|
70
|
-
import { ApplicationConfig, provideZoneChangeDetection, importProvidersFrom } from '@angular/core';
|
|
71
|
-
import { provideRouter } from '@angular/router';
|
|
72
|
-
import { appRoutes } from './app.routes';
|
|
73
27
|
import { AssistantModule } from '@foisit/angular-wrapper';
|
|
74
28
|
|
|
75
29
|
export const appConfig: ApplicationConfig = {
|
|
76
30
|
providers: [
|
|
77
|
-
provideZoneChangeDetection({ eventCoalescing: true }),
|
|
78
|
-
provideRouter(appRoutes),
|
|
79
31
|
importProvidersFrom(
|
|
80
32
|
AssistantModule.forRoot({
|
|
81
|
-
|
|
82
|
-
|
|
33
|
+
enableSmartIntent: true,
|
|
34
|
+
introMessage: 'Welcome! How can I help?',
|
|
83
35
|
commands: [
|
|
84
|
-
{
|
|
85
|
-
|
|
36
|
+
{
|
|
37
|
+
command: 'profile',
|
|
38
|
+
action: () => router.navigate(['/profile']),
|
|
39
|
+
},
|
|
86
40
|
],
|
|
87
41
|
})
|
|
88
42
|
),
|
|
@@ -92,125 +46,53 @@ export const appConfig: ApplicationConfig = {
|
|
|
92
46
|
|
|
93
47
|
---
|
|
94
48
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
Define and remove voice commands and inject the `AssistantService` into your components, start the party by calling `startListening()`.
|
|
49
|
+
## π‘οΈ Critical Actions
|
|
98
50
|
|
|
99
|
-
|
|
51
|
+
Commands marked as `critical` will automatically trigger a confirmation flow in the UI.
|
|
100
52
|
|
|
101
53
|
```typescript
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
color = signal('transparent'); // Reactive color signal
|
|
113
|
-
|
|
114
|
-
constructor(private assistantService: AssistantService) {
|
|
115
|
-
// Define voice commands
|
|
116
|
-
this.assistantService.addCommand('background red', () => {
|
|
117
|
-
this.color.set('red');
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
this.assistantService.addCommand('remove background', () => {
|
|
121
|
-
this.color.set('transparent');
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
this.assistantService.addCommand('sleep', () => {
|
|
125
|
-
this.assistantService.stopListening();
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
// Start listening immediately
|
|
129
|
-
this.assistantService.startListening();
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
---
|
|
135
|
-
|
|
136
|
-
### Step 3: Craft the UI π¨
|
|
137
|
-
|
|
138
|
-
Create a clean UI to showcase your assistant's magic.
|
|
139
|
-
|
|
140
|
-
#### `app.component.html`
|
|
141
|
-
|
|
142
|
-
```html
|
|
143
|
-
<div
|
|
144
|
-
class="content-container"
|
|
145
|
-
[ngStyle]="{
|
|
146
|
-
'background-color': color(),
|
|
147
|
-
'padding': '20px'
|
|
148
|
-
}"
|
|
149
|
-
>
|
|
150
|
-
<h1>π§ββοΈ Angular Assistant Demo</h1>
|
|
151
|
-
<p>Say the magic words to see the assistant in action:</p>
|
|
152
|
-
<ul>
|
|
153
|
-
<li>π₯ Say <strong>"background red"</strong> to make the background red.</li>
|
|
154
|
-
<li>π Say <strong>"remove background"</strong> to reset the background.</li>
|
|
155
|
-
<li>π΄ Say <strong>"sleep"</strong> to put the assistant to rest.</li>
|
|
156
|
-
</ul>
|
|
157
|
-
<p>π¨ Current Background: <strong>{{ color() }}</strong></p>
|
|
158
|
-
</div>
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
---
|
|
162
|
-
|
|
163
|
-
### Step 4: Run the App π
|
|
164
|
-
|
|
165
|
-
Start your Angular app and watch the magic happen! β¨
|
|
166
|
-
|
|
167
|
-
```bash
|
|
168
|
-
ng serve
|
|
54
|
+
const config = {
|
|
55
|
+
commands: [
|
|
56
|
+
{
|
|
57
|
+
command: 'delete post',
|
|
58
|
+
critical: true,
|
|
59
|
+
description: 'permanently delete this post',
|
|
60
|
+
action: () => this.postService.delete(),
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
};
|
|
169
64
|
```
|
|
170
65
|
|
|
171
66
|
---
|
|
172
67
|
|
|
173
|
-
##
|
|
68
|
+
## π§ AI Intent Matching
|
|
174
69
|
|
|
175
|
-
|
|
70
|
+
Enable `enableSmartIntent: true` to allow the assistant to understand natural language.
|
|
176
71
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
| Property | Type | Description |
|
|
180
|
-
| ------------------- | -------- | ------------------------------------------------- |
|
|
181
|
-
| `activationCommand` | `string` | The keyword to wake the assistant. |
|
|
182
|
-
| `fallbackResponse` | `string` | The message when a command isnβt recognized. |
|
|
183
|
-
| `commands` | `Array` | A list of `{ command: string, action: Function }` |
|
|
184
|
-
|
|
185
|
-
---
|
|
186
|
-
|
|
187
|
-
### π Service Methods
|
|
188
|
-
|
|
189
|
-
| Method | Description |
|
|
190
|
-
| ---------------- | --------------------------------------- |
|
|
191
|
-
| `addCommand` | Dynamically add a new command. |
|
|
192
|
-
| `removeCommand` | Remove an existing command dynamically. |
|
|
193
|
-
| `startListening` | Start listening for voice commands. |
|
|
194
|
-
| `stopListening` | Stop listening for voice commands. |
|
|
72
|
+
**User says:** _"Go to my profile"_
|
|
73
|
+
**Matched Command:** `{ command: 'profile', keywords: ['account', 'user settings'], ... }`
|
|
195
74
|
|
|
196
75
|
---
|
|
197
76
|
|
|
198
|
-
##
|
|
77
|
+
## π οΈ Service Usage: `AssistantService`
|
|
199
78
|
|
|
200
|
-
|
|
201
|
-
- π¨ **Visual Feedback**: Show visual cues when the assistant is active.
|
|
202
|
-
- π **Easy Integration**: Integrate the assistant with just a few lines of code.
|
|
203
|
-
- π£οΈ **Voice Feedback**: The assistant can respond with voice feedback.
|
|
204
|
-
- π **Double Activation**: The assistant can be activated with a double-click and also put to sleep with a double-click when active.
|
|
79
|
+
Interact with the assistant dynamically from your components.
|
|
205
80
|
|
|
206
|
-
|
|
81
|
+
```typescript
|
|
82
|
+
import { AssistantService } from '@foisit/angular-wrapper';
|
|
207
83
|
|
|
208
|
-
|
|
84
|
+
@Component({...})
|
|
85
|
+
export class MyComponent {
|
|
86
|
+
constructor(private assistant: AssistantService) {}
|
|
209
87
|
|
|
210
|
-
|
|
88
|
+
addCommand() {
|
|
89
|
+
this.assistant.addCommand('clear', () => this.clearAll());
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
211
93
|
|
|
212
94
|
---
|
|
213
95
|
|
|
214
|
-
##
|
|
96
|
+
## π Gesture Activation
|
|
215
97
|
|
|
216
|
-
|
|
98
|
+
Once integrated, a subtle **"Powered by Foisit"** watermark appears. **Double-click** it to open the chat overlay.
|