Skip to content

Instantly share code, notes, and snippets.

@tylerlong
Last active February 7, 2018 07:58
Show Gist options
  • Save tylerlong/3ab9d32e637b6163caa5d9e8e32cebb7 to your computer and use it in GitHub Desktop.
Save tylerlong/3ab9d32e637b6163caa5d9e8e32cebb7 to your computer and use it in GitHub Desktop.
My awesome bot
const RingCentral = require('ringcentral')
const dotenv = require('dotenv')
dotenv.config()
const token = JSON.parse(process.env.token)
const rc = new RingCentral({
server: RingCentral.server.sandbox,
appKey: '',
appSecret: ''
})
rc.platform().auth().setData(token)
const subscription = rc.createSubscription()
subscription.on(subscription.events.notification, message => {
if (message.body.creatorId !== token.owner_id) { // not a message from the bot
if (message.body.text === 'ping') {
rc.platform().post('/glip/posts', {
groupId: message.body.groupId,
text: 'pong',
attachments: undefined
})
}
}
})
subscription.setEventFilters(['/glip/posts']).register().then(() => {
console.log('subscription registered')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment