Event-triggered Paths Quickstart

This hidden component is needed for redocly SSR to work properly with Embeded OpenApiTryIt components

Loading...

Learning Objectives

In this quickstart, you'll learn to configure an Event and send a "Hello World" message out.

Before you start, make sure...

  1. You have the access to the Events Workspace.
  2. You have an API Key. If you need to create one, follow our guidance on Inbound Authentication.

Use Case Overview

Design Pattern: [DP-26] Event-Triggered Paths

Use Case Description: Send PO Approvals with all of the necessary details and ability to take action straight to Approvers in chat.

[object Object]
Moveworks11:43 AM

PO #1234 Requires your Approval
- Requested by: John Smith
- Requested on: 10/26/2023 - 10:03 PDT

Line Items
Item 1: LOGITECH 4K PRO WEBCAM
- Vendor: Logitech
- Cost Center: 0001
- Quantity: 32
- Total cost: $3119.68 USD

Do you want to Approve or Deny this PO?

Approve

Deny

[object Object]
Gwen11:43 AM

Approve

Approve Record (API Documentation)

[object Object]
Moveworks11:43 AM

Got it! Your Approval was submitted

Step 1: Create your Event-triggered Path

Events Basic Info

  1. Click CREATE on the Events Workspace homepage
100create event
  1. Copy & Paste the Event Name: Purple PO Approvals
  2. Click Yes under Do you want to add follow-up actions? 150name event
  3. Click Next to go to the next step

Setting up the Path Slot

info

The first slot configured in your Path will be sent along with Event Message.

Read more about Event-triggered Paths

  1. Click Add a bot action
  2. Click Ask a question 250paths question
  1. In Question Detail copy & paste: Do you want to approve or deny this request?. Make sure you note down the name of the slot that's created. 300paths question
  2. Click Create question
  3. Hover over your slot options and click Merge Options. This allows us to set up a single API call for both Approve & Deny options. 400merge path

Setting up the Approval API

  1. Click Add a bot action
  2. Click Execute an API 500select api
  3. Select your previously set up Creator Studio Demo Function connector
  4. Click Next 600select connector
  5. Click Create Slots in the top right of the API editor. This is how we will define variables that can be passed from an Event message to a Path API action. See Event Context Passing for more info
  6. Click + ADD SLOT
  7. Name your slot approval_id
  8. Click Save 700define slots
  9. In API Endpoint Path, insert /submitApproval
  10. In Method, insert POST
  11. In Headers, insert Content-Type as the Key and application/json as the Value 800api part1
  1. In the Request Body, copy & paste:
Copy
Copied
{
  "id": "{{approval_id}}",
  "email": "{{user_email_addr}}",
  "action": "{{request approval}}"
}
  • approval_id was defined in step 7. We will pass the Approval ID to the API call through our Event Message.
  • user_email_addr is the current user's email. You can read about system values like user attributes in the API Configuration page.
  • request approval is the title of the Paths slot we created in Setting up the Path Slot
  1. In Action Description, copy & paste This action takes action on a PO Approval 900api part2
  1. Click Submit
  2. Click Next to go to the next step

Launch Options & Publishing

  1. In Choose a launch option, select Launch to selected emails
  2. Add your email under Allow Emails Values
  3. Click Publish 1000launch options

Learn more about the other Launch Management Options.

Step 2: Send your Event Message

Loading...

Message Tester Instructions

  1. In the Security tab, copy and paste your Events API token. If you don't have one, see this our Key Management Guide to create one
  2. In the Body tab, copy and paste the below code block.
Copy
Copied
{
  "message": "Paste your message here",
  "recipients": [
    "<YOUR_EMAIL>"
  ],
  "context": {
    "slots": {
      "approval_id": "<YOUR_APPROVAL_ID>"
    }
  }
}
  • Remember to replace <YOUR_EMAIL> with your work email and <YOUR_APPROVAL_ID> with an Approval ID generated from our PurpleApproval Tool
  1. In the Parameters tab, copy and paste your Event ID. You can find this on the Basic Info page for your Event after publishing it. 1100eventid

Additional Resources