> For the complete documentation index, see [llms.txt](https://degreetpro.gitbook.io/degreet-telegram/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://degreetpro.gitbook.io/degreet-telegram/basics/one-handler-for-different-events.md).

# One handler for different events

{% tabs %}
{% tab title="TypeScript" %}

```typescript
import { IContext } from 'degreet-telegram/src/types'

bot.listen(
  ['Hello, world', 'Hello!'],
  async (ctx: IContext): Promise<void> => {
    try {
      await ctx.answer.send(ctx.msg.text)
    } catch (e: any) {
      console.error(e)
    }
  }
)
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
bot.listen(
  ['Hello, world', 'Hello!'],
  async (ctx) => {
    try {
      await ctx.answer.send(ctx.msg.text)
    } catch (e) {
      console.error(e)
    }
  }
)
```

{% endtab %}
{% endtabs %}

You can also use it for bot.on and bot.command
