async function parseDefaultTopicTrigger(contentfulEntry) {
  const data = {
    id: contentful.getContentfulIdFromContentfulEntry(contentfulEntry),
    trigger: contentful.getTriggerTextFromDefaultTopicTrigger(contentfulEntry),
  };

  const responseEntry = contentful.getResponseEntryFromDefaultTopicTrigger(contentfulEntry);
  // Check for draft entries that may not contain a response reference.
  if (!responseEntry) {
    return null;
  }

  if (helpers.contentfulEntry.isDefaultTopicTrigger(responseEntry)) {
    data.redirect = contentful.getTriggerTextFromDefaultTopicTrigger(responseEntry);
    return data;
  }

  if (helpers.contentfulEntry.isFaqAnswer(responseEntry)) {
    data.reply = contentful.getTextFromMessage(responseEntry);
    return data;
  }

  if (helpers.contentfulEntry.isTransitionable(responseEntry)) {
    data.reply = contentful.getTextFromMessage(responseEntry);
    data.topic = await helpers.topic
      .getById(contentful.getContentfulIdFromContentfulEntry(responseEntry.fields.topic));
    return data;
  }

  // TODO: This will be removed once all defaultTopicTriggers that reference topic entries (e.g.
  // photoPost, textPost) are updated to reference transition entries (e.g. photoPostTransition).
  // The changeTopicTrigger code in Conversations will be deprecated as well once all entries are
  // backfilled with transition entries.
  data.topicId = contentful.getContentfulIdFromContentfulEntry(responseEntry);
  data.topic = await helpers.topic.getById(data.topicId);
  return data;
}
/**
 * Parses a defaultTopicTrigger Contentful entry as data for writing Rivescript to define
 * triggers on the default topic.
 *
 * @param {Object} contentfulEntry - defaultTopicTrigger
 * @return {Promise}
 */
Parses a defaultTopicTrigger Contentful entry as data for writing Rivescript to define
triggers on the default topic.

@param {Object} contentfulEntry - defaultTopicTrigger
@return {Promise}
Parses a defaultTopicTrigger Contentful entry as data for writing Rivescript to define triggers on the default topic . @param { Object } contentfulEntry - defaultTopicTrigger @return { Promise }
async function parseDefaultTopicTrigger(contentfulEntry) {
  const data = {
    id: contentful.getContentfulIdFromContentfulEntry(contentfulEntry),
    trigger: contentful.getTriggerTextFromDefaultTopicTrigger(contentfulEntry),
  };
  const responseEntry = contentful.getResponseEntryFromDefaultTopicTrigger(contentfulEntry);
  if (!responseEntry) {
    return null;
  }
  if (helpers.contentfulEntry.isDefaultTopicTrigger(responseEntry)) {
    data.redirect = contentful.getTriggerTextFromDefaultTopicTrigger(responseEntry);
    return data;
  }
  if (helpers.contentfulEntry.isFaqAnswer(responseEntry)) {
    data.reply = contentful.getTextFromMessage(responseEntry);
    return data;
  }
  if (helpers.contentfulEntry.isTransitionable(responseEntry)) {
    data.reply = contentful.getTextFromMessage(responseEntry);
    data.topic = await helpers.topic
      .getById(contentful.getContentfulIdFromContentfulEntry(responseEntry.fields.topic));
    return data;
  }
  data.topicId = contentful.getContentfulIdFromContentfulEntry(responseEntry);
  data.topic = await helpers.topic.getById(data.topicId);
  return data;
}
async function parseDefaultTopicTrigger ( contentfulEntry ) { const data = { id : contentful . getContentfulIdFromContentfulEntry ( contentfulEntry ) , trigger : contentful . getTriggerTextFromDefaultTopicTrigger ( contentfulEntry ) , } ; const responseEntry = contentful . getResponseEntryFromDefaultTopicTrigger ( contentfulEntry ) ; if ( ! responseEntry ) { return null ; } if ( helpers . contentfulEntry . isDefaultTopicTrigger ( responseEntry ) ) { data . redirect = contentful . getTriggerTextFromDefaultTopicTrigger ( responseEntry ) ; return data ; } if ( helpers . contentfulEntry . isFaqAnswer ( responseEntry ) ) { data . reply = contentful . getTextFromMessage ( responseEntry ) ; return data ; } if ( helpers . contentfulEntry . isTransitionable ( responseEntry ) ) { data . reply = contentful . getTextFromMessage ( responseEntry ) ; data . topic = await helpers . topic . getById ( contentful . getContentfulIdFromContentfulEntry ( responseEntry . fields . topic ) ) ; return data ; } data . topicId = contentful . getContentfulIdFromContentfulEntry ( responseEntry ) ; data . topic = await helpers . topic . getById ( data . topicId ) ; return data ; }
Parses a defaultTopicTrigger Contentful entry as data for writing Rivescript to define
 triggers on the default topic.
Parses a defaultTopicTrigger Contentful entry as data for writing Rivescript to define triggers on the default topic .
// Check for draft entries that may not contain a response reference. // TODO: This will be removed once all defaultTopicTriggers that reference topic entries (e.g. // photoPost, textPost) are updated to reference transition entries (e.g. photoPostTransition). // The changeTopicTrigger code in Conversations will be deprecated as well once all entries are // backfilled with transition entries.