# node.js Chat bot command

**URL:** https://forum.kirupa.com/t/node-js-chat-bot-command/638808
**Category:** programming
**Created:** [October 16, 2018, 8:07am UTC](https://forum.kirupa.com/t/node-js-chat-bot-command/638808 "2018-10-16T08:07:58Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![CameleJohn](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/camelejohn/32/9320_2.png) [@CameleJohn](https://forum.kirupa.com/u/CameleJohn)
#### Post date: [October 16, 2018, 8:07am UTC](https://forum.kirupa.com/t/node-js-chat-bot-command/638808/1 "2018-10-16T08:07:58Z")

</div>

```
> nativeBot.onText(/^\/trivia/, function(msg, match) {
var fromId = msg.chat.id;
var questions = ['Question 1', 'Question 2', 'Question 3', 'Question 4', 'Question 5', 'Question 6'];
  var chosenQuestions = questions[Math.floor(Math.random() * questions.length)];
  Bot.sendMessage(msg.chat.id, chosenQuestions);
});
```

---

<div class="post-metadata">

### Author: ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)
#### Post date: [October 26, 2018, 12:16pm UTC](https://forum.kirupa.com/t/node-js-chat-bot-command/638808/2 "2018-10-26T12:16:19Z")

</div>

Is there a question here? 🙂
