Skip to content

Latest commit

 

History

History
35 lines (26 loc) · 1.01 KB

write-a-bot.md

File metadata and controls

35 lines (26 loc) · 1.01 KB

Write a personal bot

For a simple Hello bot:

/**
 * exmaple bot file
 * reply to Hello with Hi
 */

exports.onPostAdd = async ({
  text, // original text
  textFiltered, // text without metion user
  group,
  user, // user instance, check https://github.com/ringcentral/ringcentral-personal-chatbot-js/blob/master/src/server/models/ringcentral.js
  handled // if hanlded equals true, it means event already hanlded by prev skills
}) => {
  if (textFiltered === 'hello') {
    await user.sendMessage(group.id, {
      text: 'Hi'
    })
  }
}

exports.name = 'Hello bot'

exports.description = 'Bot only respond to "Hello"'

For more bot config, you can check https://github.com/ringcentral/ringcentral-personal-chatbot-js/blob/master/example-bots/full-config-bot.js

Real examples