{"id":15685114,"url":"https://github.com/halvardssm/virtual-assistant","last_synced_at":"2025-03-30T11:11:54.899Z","repository":{"id":59667522,"uuid":"538256771","full_name":"halvardssm/virtual-assistant","owner":"halvardssm","description":"Web Virtual Assistant","archived":false,"fork":false,"pushed_at":"2022-10-06T21:35:19.000Z","size":2357,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-05T12:46:16.268Z","etag":null,"topics":["clippy","virtual-assistant"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/halvardssm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-18T22:24:23.000Z","updated_at":"2022-09-19T08:42:16.000Z","dependencies_parsed_at":"2023-01-19T14:32:55.740Z","dependency_job_id":null,"html_url":"https://github.com/halvardssm/virtual-assistant","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halvardssm%2Fvirtual-assistant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halvardssm%2Fvirtual-assistant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halvardssm%2Fvirtual-assistant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halvardssm%2Fvirtual-assistant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/halvardssm","download_url":"https://codeload.github.com/halvardssm/virtual-assistant/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246308051,"owners_count":20756482,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clippy","virtual-assistant"],"created_at":"2024-10-03T17:23:40.816Z","updated_at":"2025-03-30T11:11:54.877Z","avatar_url":"https://github.com/halvardssm.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm (scoped)](https://img.shields.io/npm/v/@halvardm/virtual-assistant?style=for-the-badge)](https://www.npmjs.com/package/@halvardm/virtual-assistant)\n\n# Virtual Assistant\n\nYour very own virtual assistant. Perfect for when you need to create a helper for your website, or simply want to create an interactive companion.\n\nInspired by [Clippy.JS](https://github.com/smore-inc/clippy.js) and completely refactored! \n\nYou can bring your favorite Microsoft helpers to the web, or create your own!\n\n## Installation\n\n```\nyarn add @halvardm/virtual-assistant\n\nnpm i @halvardm/virtual-assistant\n```\n\n## Usage\n\nThis module is framework agnostic, but includes a hook for use with React.\n\n### JS\n\n```js\nconst va = new VirtualAssistant(virtualAssistant, options);\nva.show()\n```\n\n### React\n\n```tsx\nexport function App() {\n  const va = useVirtualAssistant(Clippy)\n\n  return \u003cdiv\u003e\n    Hello World\n    \u003cbutton onClick={() =\u003e va.current.speak('Hello World', true)}\u003eSay Hello\u003c/button\u003e\n  \u003c/div\u003e\n}\n```\n\n## Methods\n\n```ts\n    /**\n     * Checks if the virtual assistant exists in the DOM\n     */\n    existsInDom(): boolean;\n    /**\n     * Adds the virtual assistant to the DOM, if not already present\n     */\n    addToDom(): void;\n    /**\n     * Removes the virtual assistant from the DOM, if present\n     */\n    removeFromDom(): void;\n    /**\n     * Gestures at a given position, if gesture animation exists.\n     * Falls back to look animation if gesture animation does not exist.\n     */\n    gestureAt(x: number, y: number): boolean;\n    /**\n     * Hide the virtual assistant\n     */\n    hide(fast: boolean, callback: VoidFn): void;\n    /**\n     * Move the virtual assistant to a given position\n     */\n    moveTo(x: number, y: number, duration?: number): void;\n    /**\n     * Plays an animation\n     */\n    play(animation: string, timeout?: number, cb?: VoidFn): boolean;\n    /**\n     * Shows the virtual assistant\n     */\n    show(fast?: boolean): boolean;\n    /**\n     * Toggles the message box with the given text\n     */\n    speak(text: string, hold?: Message[\"_hold\"]): void;\n    /**\n     * Close the current message\n     */\n    closeMessage(): void;\n    /**\n     * Adds a delay to the queue\n     */\n    delay(time?: number): void;\n    /**\n     * Stops the current animation\n     */\n    stopCurrent(): void;\n    /**\n     * Stops the current animation and clears the queue\n     */\n    stop(): void;\n    /**\n     * Checks if an animation with the given name exists\n     */\n    hasAnimation(name: string): boolean;\n    /**\n     * Gets a list of animation names\n     */\n    animations(): string[];\n    /**\n     * Plays a random animation\n     */\n    animate(): boolean;\n    /**\n     * Repositions the assistant withing the window, if out of bounds\n     */\n    reposition(): void;\n    /**\n     * Pauses the assistant\n     */\n    pause(): void;\n    /**\n     * Resumes the assistant\n     */\n    resume(): void;\n```\n\n## Types\n\n```ts\nexport declare type VirtualAssistantBranchingType = {\n    /**\n     * The index of the frame to play (within the current animation)\n     */\n    frameIndex: number;\n    /**\n     * Weight of this branch (0-100)\n     */\n    weight: number;\n};\n\nexport declare type VirtualAssistantAnimationFramesType = {\n    /**\n     * The frame duration in milliseconds.\n     */\n    duration: number;\n    /**\n     * The frame images. Used together with overlayCount from the VirtualAssistantType.\n     * @see VirtualAssistantType.overlayCount\n     */\n    images?: Array\u003c[number, number]\u003e;\n    /**\n     * The sound for the frame. Will continue until the sound is over,\n     * even when switching frames.\n     * @see VirtualAssistantAudioType.sounds\n     */\n    sound?: string;\n    /**\n     * The frame index which can be used for a graceful exit of the animation.\n     * Used when you need to cancel a long animation mid sequence.\n     */\n    exitBranch?: number;\n    /**\n     * Possible branches for the animation.\n     */\n    branching?: VirtualAssistantBranchingType[];\n};\n\nexport declare type VirtualAssistantAnimationType = {\n    /**\n     * The animation frames\n     * @see VirtualAssistantAnimationFramesType\n     */\n    frames: VirtualAssistantAnimationFramesType[];\n    /**\n     * Indicates that this animation contains exitBranching\n     * @see VirtualAssistantAnimationFramesType.exitBranch\n     */\n    useExitBranching?: boolean;\n};\n\n/**\n * Web audio mime types\n */\nexport declare type MimeTypeAudio = \"audio/3gpp\" | \"audio/aac\" | \"audio/flac\" | \"audio/mpeg\" | \"audio/mp3\" | \"audio/mp4\" | \"audio/ogg\" | \"audio/wav\" | \"audio/webm\" | string;\n\nexport declare type VirtualAssistantAudioType = {\n    /**\n     * Web audio mime types\n     */\n    mime: MimeTypeAudio;\n    /**\n     * The audio files in key value pairs.\n     * Value can be base64 encoded or a URL.\n     */\n    sounds: Record\u003cstring, URL | string\u003e;\n};\n\nexport declare type VirtualAssistantType = {\n    /**\n     * The amount of overlays to use for the virtual assistant frames, usually 1\n     */\n    overlayCount: number;\n    /**\n     * The size of the virtual frame in the map (in pixels).\n     * This is the size of one frame, not the whole animation.\n     * @see VirtualAssistantType.map\n     */\n    framesize: [number, number];\n    /**\n     * The animation sequences\n     */\n    animations: Record\u003cstring, VirtualAssistantAnimationType\u003e;\n    /**\n     * The audio files\n     */\n    audio: VirtualAssistantAudioType[];\n    /**\n     * The name of the virtual assistant (used for logging)\n     */\n    name: string;\n    /**\n     * The animation map. Each frame has to be the same size as the framesize.\n     * Can be base64 encoded or a URL.\n     * @see VirtualAssistantType.framesize\n     */\n    map: URL | string;\n};\n```\n\n## Creating your own\n\nSee [Clippy](./agents/Clippy) in the [agents](./agents) folder for an example of how to create your own. Start from the `VirtualAssistantType`, and add fields as you go.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalvardssm%2Fvirtual-assistant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhalvardssm%2Fvirtual-assistant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalvardssm%2Fvirtual-assistant/lists"}