Custom Code triggers are a low level way of inspecting a Slack message, and determining if it matches criteria that should launch your Mission.  To create one, you need to provide a Javascript function such as the one below:

function trigger (body) {
  if (!body.event || !body.event.text) return
  return tmpl(body.event.text, 'new order for {{customer}} of {{product}}')
}

The function takes the body of a Slack event. If you wanted to just inspect the main text of a message you would look at body.event.text, but you have the full event object available in case you need to look at other properties.  

Matching Strings

The example above uses a module that gets injected for you that is here https://github.com/mbrevoort/reverse-string-template, and exposed as the function tmpl() . It makes it easier to do simple matching on text strings.

Extracting Data

Data can be extracted from the message to be made available to your Mission.  If you return an object, it considers it a match. The above example, will return an object with customer  and product  properties for a message like "new order for BigCo Industries of 1000 bottles of beer on the wall" where customer  would then be BigCo Industries  and product  would be 1000 bottles of beer on the wall.  To signal a non-match on the event you would return a falsey value (null, undefined, false, 0 ).

Using the tmpl() function is not required, it's just a convenience.  If you wanted to match on ANY message that contains "kudos", it could look like this:

function trigger (body) {
  if (!body.event || !body.event.text) return
  let text = body.event.text
  if (text.indexOf('kudos') < 0) return
  return { text }
}

This would product a property called text  with the complete text of the message.

Did this answer your question?