{"id":18753129,"url":"https://github.com/bottenderjs/bottender-form","last_synced_at":"2025-11-28T04:30:21.911Z","repository":{"id":119418203,"uuid":"119412185","full_name":"bottenderjs/bottender-form","owner":"bottenderjs","description":"An experimental package for handling conversational form with Bottender.","archived":false,"fork":false,"pushed_at":"2018-02-05T06:00:14.000Z","size":64,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-20T12:11:52.175Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bottenderjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2018-01-29T16:55:34.000Z","updated_at":"2018-04-19T21:11:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"e2d32ddf-791f-47bf-8ecf-e900cf4ff48d","html_url":"https://github.com/bottenderjs/bottender-form","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/bottenderjs/bottender-form","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bottenderjs%2Fbottender-form","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bottenderjs%2Fbottender-form/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bottenderjs%2Fbottender-form/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bottenderjs%2Fbottender-form/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bottenderjs","download_url":"https://codeload.github.com/bottenderjs/bottender-form/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bottenderjs%2Fbottender-form/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27295753,"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-11-28T02:00:06.623Z","response_time":58,"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":[],"created_at":"2024-11-07T17:24:26.453Z","updated_at":"2025-11-28T04:30:21.884Z","avatar_url":"https://github.com/bottenderjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bottender-form\n\n[![npm](https://img.shields.io/npm/v/bottender-form.svg?style=flat-square)](https://www.npmjs.com/package/bottender-form)\n[![Build Status](https://travis-ci.org/bottenderjs/bottender-form.svg?branch=master)](https://travis-ci.org/bottenderjs/bottender-form)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\n\u003e An experimental package for handling conversational form with [Bottender](https://github.com/Yoctol/bottender).\n\n## Installation\n\n```sh\nnpm install bottender-form\n```\n\n## Usage\n\n```js\nconst { middleware } = require('bottender');\nconst form = require('bottender-form');\n\nconst handleForm = form({\n  name: 'user',\n  shouldStart: context =\u003e context.event.text === '/form',\n  steps: [\n    {\n      question: \"What's your name?\",\n      stateKey: 'user.name',\n    },\n    {\n      question: 'How old are you?',\n      validation: text =\u003e /\\d+/.test(text),\n      map: numstr =\u003e +numstr,\n      stateKey: 'user.age',\n    },\n  ],\n});\n\nbot.onEvent(\n  middleware([\n    handleForm,\n    async context =\u003e {\n      if (context.event.isMessage) {\n        await context.sendText(`user: ${JSON.stringify(context.state.user)}`);\n      }\n    },\n  ])\n);\n```\n\n## Options\n\n### name\n\n`text`\n\n### shouldStart\n\nDefault: `() =\u003e false`.\n\n### shouldStop\n\nDefault: `() =\u003e false`.\n\n### retryMessage\n\nDefault: `Validation failed. Please try again.`.\n\n### retryTimes\n\nDefault: `3`.\n\n### didFinish\n\nDefault: `() =\u003e {}`.\n\n### Step\n\n#### question\n\n`text | async context =\u003e void`\n\n#### stateKey\n\n`text`\n\n#### validation\n\n`text =\u003e boolean | async text =\u003e boolean`\n\n#### map\n\n`text =\u003e any`\n\n## License\n\nMIT © [Yoctol](https://github.com/bottenderjs/bottender-form)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbottenderjs%2Fbottender-form","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbottenderjs%2Fbottender-form","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbottenderjs%2Fbottender-form/lists"}