{"id":28445067,"url":"https://github.com/wechaty/actor","last_synced_at":"2025-08-01T23:33:48.615Z","repository":{"id":57690344,"uuid":"489971636","full_name":"wechaty/actor","owner":"wechaty","description":"Wechaty Actor Model, Powered by XState, Mailbox, and CQRS","archived":false,"fork":false,"pushed_at":"2024-05-02T16:16:45.000Z","size":102,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-08T01:46:53.325Z","etag":null,"topics":["actor","fsm","mailbox","wechaty","xstate"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/wechaty-actor","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wechaty.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-05-08T14:48:24.000Z","updated_at":"2024-05-02T16:16:48.000Z","dependencies_parsed_at":"2025-07-08T01:20:57.559Z","dependency_job_id":"b3541d02-5a69-4d3d-8ad2-87d13f3ebc57","html_url":"https://github.com/wechaty/actor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wechaty/actor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechaty%2Factor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechaty%2Factor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechaty%2Factor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechaty%2Factor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wechaty","download_url":"https://codeload.github.com/wechaty/actor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechaty%2Factor/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268311283,"owners_count":24230325,"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","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["actor","fsm","mailbox","wechaty","xstate"],"created_at":"2025-06-06T10:11:14.251Z","updated_at":"2025-08-01T23:33:48.572Z","avatar_url":"https://github.com/wechaty.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wechaty Actor\n\nWechaty Actor Model, Powered by XState, Mailbox, and CQRS\n\n[![NPM Version](https://img.shields.io/npm/v/wechaty-actor?color=brightgreen)](https://www.npmjs.com/package/wechaty-actor)\n[![NPM](https://github.com/wechaty/actor/workflows/NPM/badge.svg)](https://github.com/wechaty/actor/actions?query=workflow%3ANPM)\n[![Mailbox.Duckula Specification](https://img.shields.io/badge/Specification-Mailbox.Duckula-blueviolet)](https://github.com/huan/mailbox#duckula-specification)\n[![ES Modules](https://img.shields.io/badge/ES-Modules-brightgreen)](https://github.com/Chatie/tsconfig/issues/16)\n\n![Wechaty Actor](docs/images/wechaty-acotr.webp)\n\n\u003e Image source: [RoPA](https://ropa.umb.edu/coordinating-logistics)\n\nWechaty Actor is an wrapper for Wechaty\nthat applies the Actor Model with XState and CQRS.\n\n## Actor Model\n\n![Actors](docs/images/actor.webp)\n\n\u003e The Actor Model is a computational model for designing concurrent,\n  distributed systems around the principal of self-contained Actors\n  which operate on sending and receiving messages.  \n\u003e \u0026mdash; [Introduction to the Actor Model...](https://medium.com/xandr-tech/introduction-to-the-actor-model-for-concurrent-computation-56c0391f8f92)\n\n## Features\n\n1. Working with [wechaty-cqrs](https://github.com/wechaty/cqrs) by receiving\n  the CQRS Commands and Queries, and responding Responses.\n2. Implemented with [XState](https://xstate.js.org/) and [Mailbox](https://github.com/huan/mailbox)\n3. Native designed for Domain Driven Design (DDD)\n\n## Usage\n\n### Install\n\n```sh\nnpm install wechaty-actor wechaty-cqrs wechaty\n```\n\n### Quick start\n\nHere's the Actor version of the Wechaty bot usage:\n\n```ts\nimport * as ACTOR   from 'wechaty-actor'\nimport * as CQRS    from 'wechaty-cqrs'\nimport * as WECHATY from 'wechaty'\n\nconst wechaty = WechatyBuilder.build()\nawait wechaty.init()\n\nconst actor = ACTOR.from(wechaty)\n\nconst BOT_ID = 'BotMachine'\nconst botMachine = createMachine({\n  id: BOT_ID,\n  on: {\n    '*': {\n      actions: Mailbox.actions.proxy(BOT_ID)(actor),\n    },\n  },\n})\n\nconst interpreter = interpret(botMachine)\n  .onEvent(e =\u003e console.info(e))\n  .start()\n\nconst startCommand = CQRS.commands.StartCommand(wechaty.puppet.id)\ninterpreter.send(startCommand)\n\nconst dingCommand  = CQRS.commands.DingCommand(wechaty.puppet.id)\ninterpreter.send(dingCommand)\n\nawait firstValueFrom(from(actor).pipe(\n  // filter(CQRS.is(CQRS.events.DongReceivedEvent)),\n  filter(CQRS.is(CQRS.responses.DingCommandResponse)),\n  take(1),\n))\n```\n\nLearn how to build a Ding Dong BOT with Actor from our [examples/ding-dong-bot.ts](https://github.com/wechaty/actor/blob/main/examples/ding-dong-bot.ts)\n\n## Getting Started\n\nHere's a video introduction for CQRS Wechaty with live demo, presented by Huan:\n\nTo-be-recorded\n\nThe getting started [ding-dong-bot.ts](https://github.com/wechaty/getting-started/blob/main/examples/actor/ding-dong-bot.ts)\nin the video: \u003chttps://github.com/wechaty/getting-started/blob/main/examples/actor/ding-dong-bot.ts\u003e\n\n## API Reference\n\nRead Wechaty Actor API Reference at: \u003chttps://paka.dev/npm/wechaty-actor\u003e\n\n## Blogs\n\n- [Refactoring Friday BOT with NestJS, Domain-driven Design (DDD), and CQRS, @huan, Feb 27, 2022](https://wechaty.js.org/2022/02/27/refactoring-friday-bot-with-nestjs-ddd-cqrs/)\n\n## Resources\n\n- [The actor model in 10 minutes](https://www.brianstorti.com/the-actor-model/)\n- [Node.js actor framework](https://github.com/untu/comedy)\n- [Beautiful State Machines](https://xstate-catalogue.com/) - XState Catalogue is\n  a collection of professionally designed state machines you can drop into your projects.\n  Get started by browsing the catalogue, interacting with the machines,\n  and copying the code.\n- [XState: Should this be an action or a service?](https://dev.to/mpocock1/xstate-should-this-be-an-action-or-a-service-2cp0)\n- [Introduction to the Actor Model for Concurrent Computation, John Murray, Sep 29, 2015, Tech Talks @ AppNexus](https://www.youtube.com/watch?v=lPTqcecwkJg)\n- [Kotlin Concurrency with Actors, Jag Saund, Jun 14, 2018](https://medium.com/@jagsaund/kotlin-concurrency-with-actors-34bd12531182)\n- [Pure UI using Xstate and ReactJS](https://dev.to/cris_o/pure-ui-using-xstate-and-reactjs-5em7)\n\n## History\n\n### main\n\n## v0.0.1 (May 8, 2022)\n\n- v0.0.1 (Mar 6, 2022): Init README \u0026 Draft design from [bot5-assistant#1](https://github.com/wechaty/bot5-assistant/pull/1)\n\n## Author\n\n[Huan LI](http://linkedin.com/in/zixia) is a serial entrepreneur,\nactive angel investor with strong technology background.\nHuan is a widely recognized technical leader on conversational AI\nand open source cloud architectures.\nHe co-authored guide books \"Chatbot 0 to 1\" and \"Concise Handbook of TensorFlow 2\"\nand has been recognized both by Microsoft and Google as MVP/GDE.\nHuan is a Chatbot Architect and speaks regularly\nat technical conferences around the world.\nFind out more about his work at \u003chttps://github.com/huan\u003e\n\n## Copyright \u0026 License\n\n- Code \u0026 Docs © 2022 Huan (李卓桓) \\\u003czixia@zixia.net\\\u003e\n- Code released under the Apache-2.0 License\n- Docs released under Creative Commons\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwechaty%2Factor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwechaty%2Factor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwechaty%2Factor/lists"}