Skip to content

Commit

Permalink
Merge pull request #880 from william-monroy/docs/idle
Browse files Browse the repository at this point in the history
docs: (鉁忥笍) added documentation for idle feature
  • Loading branch information
leifermendez committed Oct 9, 2023
2 parents f42f8ec + bf23558 commit 6677522
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 10 deletions.
1 change: 1 addition & 0 deletions packages/docs/src/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default component$(() => {
{ name: 'fallBack', link: '/docs/fall-back' },
{ name: 'endFlow', link: '/docs/end-flow' },
{ name: 'gotoFlow', link: '/docs/goto-flow' },
{ name: 'idle', link: '/docs/idle' },
{ name: 'blacklist', link: '/docs/blacklist' },
],
},
Expand Down
45 changes: 45 additions & 0 deletions packages/docs/src/routes/docs/idle/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import Navigation from '../../../components/widgets/Navigation'

# idle

Esta funcionalidad te permite dada una cantidad de tiempo de inactividad en el chat, ejecutar una acci贸n.

## Ejemplo

En el siguiente ejemplo, si el usuario no responde en 2 segundos, se ejecutar谩 la acci贸n de cancelar el flujo.

```js
const { addKeyword } = require('@bot-whatsapp/bot')

const flujoFinal = addKeyword(EVENTS.ACTION).addAnswer('Se cancel贸 por inactividad')

const flujoPrincipal = addKeyword(['hola'])
.addAnswer(
'Debes de responder antes de que transcurran 2 segundos',
{ capture: true, idle: 2000 }, // idle: 2000 = 2 segundos
async (ctx, { gotoFlow, inRef }) => {
if (ctx?.idleFallBack) {
return gotoFlow(flujoFinal)
}
}
)
.addAnswer('gracias!')

```
## API
### Propiedades
- **idle** - Tiempo de inactividad en milisegundos
- **idleFallBack** - Si se ejecut贸 la acci贸n por inactividad
---
<Navigation
pages={[
{ name: 'Instalaci贸n', link: '/docs/install' },
{ name: 'Conceptos', link: '/docs/essential' },
]}
/>
15 changes: 5 additions & 10 deletions packages/docs/src/services/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,13 @@ export const fetchGithub = async (token: string) => {
Authorization: `Bearer ${token}`,
},
})
const listUsers = await data.json()
try {
const listUsers = await data.json()
return listUsers.map((u: any) => ({
...u,
avatar_url: `${u.avatar_url}&s=80`,
}))
// try {
// const listUsers = await data.json()
// return listUsers.map((u: any) => ({
// ...u,
// avatar_url: `${u.avatar_url}&s=80`,
// }))
// } catch (error) {
// return []
// }
} catch (error) {
return []
}
}

0 comments on commit 6677522

Please sign in to comment.