This repository was archived by the owner on Nov 26, 2019. It is now read-only.
  
  
  - 
                Notifications
    You must be signed in to change notification settings 
- Fork 93
01 Add a channel
        Jerome Houdan edited this page Apr 3, 2017 
        ·
        5 revisions
      
    To add a channel:
- your file must be in src/services
- the name of your file must be nameOfChannel.service.js
- your service must inherit from Template.service.js, as follows:
import ServiceTemplate from './Template.service.js'
export default class nameOfYourChannelService extends ServiceTemplate {
/* your code */
}A good starting point is to look at the existing channels.
You can also find more information here.
The Service template, in src/services/Template.service.js, contains all the functions you need to implement.
import { noop } from '../utils'
export default class ServiceTemplate {
  /* Call when the Connector is launched */
  static onLaunch = noop
  /* Check parameter validity to create a Channel */
  static checkParamsValidity = noop
  /* Call when a channel is created */
  static onChannelCreate = noop
  /* Call when a channel is updated */
  static onChannelUpdate = noop
  /* Call when a channel is deleted */
  static onChannelDelete = noop
  /* Call when a message is received for security purpose */
  static checkSecurity = noop
  /* Call when a message is received, before the pipeline */
  static beforePipeline = noop
  /* Call before entering the pipeline, to build the options object */
  static extractOptions = noop
  /* Call to parse a message received from a channel */
  static parseChannelMessage = noop
  /* Call to format a message received by the bot */
  static formatMessage = noop
  /* Call to send a message to a bot */
  static sendMessage = noop
}Each function is called at a specific time in the Connector flow. There are two categories of functions:
- Primary functions: those are required. If you don't implement them, your Service won't work.
- Secondary functions: those are functions that you may need to implement, depending of the channel you're working on.
- 
parseChannelMessageparse the incoming message of the channel to shape it in the Connector format.
- 
extractOptionsextract the information we need to get back in the message (chatId, id, senderid, ect).
- 
formatMessageformat the message according to the channel it will be sent to
- 
sendMessagesend the message to the channel
- 
beforePipelineis called when a message is received from the channel, before processing the message
- 
checkSecuritychecks that the message is coming from the channel
- 
checkParamsValiditychecks parameters validity when sending a message
- 
onLaunchis called when the connector is launched
- 
onChannelCreateis called when a channel is created
- 
onChannelUpdateis called when a channel is updated
- 
onChannelDeleteis called when a channel is deleted
- Discord
- Line
- Cisco Spark
- Twilio
- Telegram
- and every other you can think of! 👍