Tutorial 4: Run Automated Workflows Using Your CapacityDB Data
CapacityDB is a Capacity-hosted database that can conveniently and seamlessly integrate with the full Capacity tech stack and our customers’ mission-critical applications. Through an engaging and intuitive interface, even novice users will be able to create, update, and take action on useful data sets.
If you have any questions, contact firstname.lastname@example.org.
In the previous tutorials, you first created a CapacityDB schema, populated a table with data, wrote queries to read from and write to it. You then saw its value in a Guided Conversation. In this article, you’ll create a Guided Conversation - the template and flow for your interactions with a concierge.
1. Create a Workflow
First, navigate to Workflows by clicking the stacked boxes icon in the console side bar. Then click "New Workflow" in the top right corner of the window.
Click the first text field in the modal and name the workflow "Email Widget Report", and give it the description "This workflow sends a report of all widgets."
This workflow will eventually check your CapacityDB widget table, fetch all the widgets, and broadcast that information to an email address.
Click the Save button.
You'll next see the canvas for building your new workflow's steps. At first, you'll only see just a start step and an end step.
2. Add Steps
We'll add two more cards: an App Action step that will allow you to fetch information on widgets, and a Broadcast step that will send an email with details.
In the Builder's side bar, scroll to the bottom of the list of steps, and click the caret next to "Apps". The submenu will expand, and you should see an App Action card named "Delmar Widgets".
Drag and drop the App step into the console. Scroll back up and drag and drop a Broadcast step in as well. Then click the connection between the Start and End steps.
You'll want to rearrange your canvas a little. Delete the existing connection, drag the End step down, and connect the Action and Broadcast steps as shown.
Ok, the structure of your workflow is now complete, but you'll need to add information to the Action and Broadcast cards before it will work.
Click the notepad icon on the Action step. In the side panel, name the step "Get All Widgets" and select the Action with the same name. Be sure to click Save.
Click into the Broadcast step, and call it "Send an Email."
Enter "Widget Report" for the Email subject, and in the Message field, type "Widgets:"followed by the Rows variable. Rows will consist of all of the data returned by CapacityDB.
By only using these cards, we are ignoring the possibility of errors. Errors inevitably happen, and you'll want to create branching paths for situations where an error is returned from CapacityDB, for example, when a query syntax is broken.
Type in your email address, then be sure to hit the Enter or Return key to add it. Then click "Save" and you'll be ready to Publish the workflow!
3. Publish and Test the Workflow
Click Publish and select "Publish & Run" to start your workflow.
You should receive an email with some structured information about the widget data.
The output of the CapacityDB App step is in a text-based format named JSON. The data is not easy to read, but is extremely useful to programmers. If you'd like to make it more readable, you can use a helper app such as Capacity Functions that will make it easier to view.
If you don't receive the email, go back to the workflow and click the "Instances" tab. All steps should be green. If they aren't, go back to the step that's failing and check your inputs.
Congratulations! You should now be able to use CapacityDB in a Workflow. You can add error handling for stability, formatting for a better experience, and even schedule your workflow for hands-free reports!