Send a Slack message

The following example demonstrates posting a visitor registration notification to someone on Slack. You can customise the message by changing the text value in the body of the slackResponse.

/**
 * @UseApp {SLACK}
 */

const visitor_name = quest.items.find((item) => item.name === "Your Full Name");
const host = quest.items.find((item) => item.name === "Who are you seeing today?");

await questmate.quests.questsPartialUpdate(
  quest.prototypeId,
  {
    name: `${visitor_name.data.text}`
  }
);

const slackResponse = await fetch(`https://slack.com/api/chat.postMessage`, {
  method: 'POST',
  body: JSON.stringify({
    text: `${visitor_name.data.text} is here to see you.`,
    channel: host.data.member
  }),
  headers: {
    "content-type": "application/json"
  }
});

const {data: thisQuestRun} = await questmate.quests.questsDetail(quest.prototypeId)
const {data: questTemplate} = await questmate.templates.templatesDetail(thisQuestRun.quest.id)
const {data: currentQuestPrototype} = await questmate.quests.questsDetail(questTemplate.currentQuestPrototype.id)
return {
  actions: [
    {
      type: 'navigate',
      autoRedirectDelay: 5000,
      linkText: 'Register another visitor',
      to: {
        screen: "PublicAssignment",
        params: { id: currentQuestPrototype.publicId },
      }
    }
  ]
}