Authorable Workflow Codelab 5: Cases and Atlas

This is an advanced codelab to integrate with Cases and Atlas signals. Learn how to do the following:

  1. Create a workflow that integrates with Cases
  2. Retrieve Cases attributes about the customer with GAIA, and CID
  3. Use the Submit button
  4. Retrieve Atlas product signals for the customer
  5. Link to a help center article
  6. Use a summary widget
  7. Set Cases to categories
  8. Set a Cases note
  9. Show a URL with dynamic parameters

The following is an outline of the workflow:

  1. Get the customer info associated with the Case.
  2. Show the Play Payment profile status.
  3. Show the link to a relevant KB article about the Payment profile based on the status.
  4. Add a note and categorize the case.

To start a new workflow, follow these steps:

  1. Use the Redwood prod HC playground to create your workflow in the authorable-wf-kickoff folder.
  2. Change the Workflow type from the default of Custom to Cases.

f5267ddb98b39148.png

The special keyword variable case_id has the invoking case ID. To create a form and display this value, follow these steps:

  1. Create a new Page node and rename it to ShowPlayUserInfo.
  2. Set Form title to Play User Segment.
  3. Add a new static Text field. Set Field name to ShowCaseId.
  4. Set Label to Case Id: ${case_id}.
  5. Set Next Step to Go To > Workflow Complete.

7a1b696167d601a3.png

To test a workflow from Cases, follow these steps:

  1. Open Cases UAT env.
  • Follow up with rickychang@ for access if you don't see it. Contact him at Authorable-WF-approved-TRD-user@google.com.
  1. Configure an authorable workflow.
  • Open the Cases overflow menu in the upper-right side.
  • Set the Help center ID and Article ID.

These IDs can be found in the "Workflow Info" panel:

  1. Attributes > ID
  2. Associations > Global > Top level entry

794236e21d482ca0.png

7ceee65b5f77044c.png

To create a new case and launch a new workflow, follow these steps:

  1. Open the Cases overflow menu at the upper right-hand side.
  • Create a new case.
  • In the Product drop-down of the "Home" card, select Play. *

d0908bcb48e0d062.png

  1. Open the Cases overflow menu again and launch Authorable workflow.
  2. See the results in the Resolution card.

The feature enhancement is done. The page won't disappear. But it's still useful to learn how to add a Submit button. Proceed with the codelab.

The following is a 2-step process to create a snippet for the Submit button's text and a field in a page:

  1. Create a snippet.
  • Find the authorable-wf-kickoff-snippets folder in the left-hand panel of Redwood.

704924d1a3092172.png

  • Click + Create new > Text snippet.
  • Click the workflow's Done button text to name the button.
  • Type Done in the text box.
  • Click Save.
  1. Add a field.
  • Open your workflow.
  • Click on the page title ShowPlayUserInfo.
  • Add a field Submit button, and name it DoneButton.
  • Click the Search > Recent tab > Workflow Done button text.
  • Click Select.
  • Set Label to Click done to complete the workflow.
  1. Add and connect to the next step.
  • Set Name to TerminalPage.
  • Click Go to > Workflow complete.

583f108ec5b674b8.png

Now you should see the Case ID and a Done button.

Click Done to complete the workflow.

1c69eb8c1552953.png

To improve the workflow and add an action to get the customer's email, follow these steps:

  1. Select the Start node.
  2. Click Next Step > Action > + Create Action.
  3. Select the new node and set it to GetCaseInfo.
  4. Add a storage directive.
  • case = GetCase(case_id: case_id)
  • gaiaEmail = case.from_email
  • caseLocale = GetCaseAttribute(attributes: case.attributes,
  • id: "^^9")
  1. Set Next Step > Page > ShowPlayUserInfo.

85655b7733693d01.png

To display the email and run a test, follow these steps:

  1. Select the Page node ShowPlayUserInfo.
  2. Select the field ShowCaseId.
  3. Update Label with the following 2 lines:
  • Set Email to ${gaiaEmail}.
  • Set Locale to ${caseLocale}.

397348a53c77daa5.png

  1. Open the "Cases" window and launch Authorable workflow.
  • The screen should be blank.
  1. Go to Cases and set the customer account to rickychang@google.com.
  2. Launch Authorable workflow again.
  3. Verify that you see the correct information.
  4. Go to Cases, change the language, and verify that you see the correct information.

Atlas is a signal repository for CE that the other products can publish read-only signals. It's fast and it works in real time. It's designed to handle a very high number of queries, with fallback features to ensure data accuracy and freshness.

It only requires a storage directive function with one parameter to get Atlas data.

Storage directive:

Variable <- atlas:<ATLASPRODUCT>(gaia_email: <email>)

For more information on Atlas, see Atlas reference and Atlas signals.

Let's get Play Atlas information and show it if the user has a Payments profile created.

Create a new Action node, after the GetCaseInfo. You could combine actions, but it's a good practice to break out different nodes for different purposes.

  1. Add a new node and set it to GetPlayAtlasInfo.
  2. Add the following new storage directives:
  • playAtlas = atlas: PLAY(gaia_email: gaiaEmail)
  • hasPaymentProfile = Coalesce(values: [playAtlas. HasPaymentsProfile, false])
  1. Select the Page node named ShowPlayUserInfo.
  • Select ShowCaseId.
  • Set Label to: Has Payment Profile: ${hasPaymentProfile}

f02e368065d5207a.png

Now it's time to put that signal to use. Different KB articles are recommended if a user has a payment profile or not.

To display this in a summary widget, follow these steps:

To create 2 snippets that have a link to the KB articles, follow these steps:

  1. Reference page 9 for the steps to create a snippet.
  2. Name the first snippet "Have Payment Method."
  3. Use the following text for the snippet: User has a payment method. Refer to this article to edit or delete payment methods.
  4. Add a URL with the following information to the keywords this article:
  1. Click Save.
  2. Name the second snippet No Payment Method.
  3. Use the following text for the snippet: User doesn't have a payment method. Refer to this article for more information.
  4. Add a URL with the following information to the keywords this article.
  1. Click Save.

A summary widget data field is a list of dictionary words with 3 fields for display_text, value, and selected.

The following are examples of display text:

[

{display_text: "This user is eligible for YouTube Music App pitch", value: "", selected: false},

{display_text: "TEXT_SNIPPET:9055232", value: "", selected: false}

]

To initiate a summary data widget as an empty list and add the appropriate KB articles, follow these steps:

  1. Select the node named GetPlayAtlasInfo.
  2. Add the following storage directive: paymentSummary = []

To check if a user has a payment profile and to set the summary data, follow these steps:

  1. Add a Decision node after GetPlayAtlasInfo and name it CheckHasPaymentProfile.
  • Set Branch 1 condition to hasPaymentProfile.
  • Click Go To > Action > + Create.
  • Set Else branch toGo To > Action > + Create
  1. Rename the new Action node for true branch SetHasPaymentSummary.
  2. Add a storage directive with the following information:
  • paymentSummary = ListAppend(arg:paymentSummary, value:{display_text: "TEXT_SNIPPET:9070646", value: "", selected: false})
  1. Click Go To > Page > ShowPlayUserInfo.
  2. Rename the new Action node for false branch SetNoPaymentSummary.
  3. Add a storage directive with the following information:
  • paymentSummary = ListAppend(arg:paymentSummary, value:{display_text: "TEXT_SNIPPET:9070648", value: "", selected: false})
  1. Click Go To > Page > ShowPlayUserInfo.
  2. Make sure all of the nodes are connected.

36077431c4564a9f.png

To add the summary widget, follow these steps:

  1. Select the ShowPlayUserInfo Page node.
  2. Click the Summary widget, and name it ShowPaymentsKB.
  • Set Input data to paymentSummary.
  • Set optional Label to Recommended KB article.

90fea967f1d6720a.png

d3354eac86b3d048.png

  1. Move the field above the Submit button field.
  2. Click Save and check for validation.

The next step is to test the summary widget.

ffd7fbe01e2aafda.png

For simplicity, use the same category for users with and without a Payment profile.

  1. The AddCaseAttribute function takes case_id and attributes, such as a list of dictionary values like ID and value.
  • Category attribute has the system ID ^^1.
  • Value is the comma separated list of Redwood category IDs. For our example, value is the following: 7061355,7073906,7073907,7076358,9006840
  1. Add an Action node after the ShowPlayUserInfo variable and name it SetCaseCategory. Set Enter a value for a function to the following:
  • AddCaseAttribute(case_id: case_id, attributes: [{id: "^^1", value: "7061355,7073906,7073907,7076358,9006840"}])
  1. Click Save, check the save message for validation, and then test the workflow.
  2. After a few minutes or a refresh, you should see the new category in the Categories card.

b83987eb7eb11c1f.png

f705d3fb1a5f6bd5.png

To add case notes for users with and without a Payment profile, follow these steps:

  1. The AddCaseNote function takes the following variables: case_id, from_address, note_text, and subject.
  • Set from_address to the workflow title.
  • Set subject to the purpose of the note.
  • Set variable note_text to the actual text of the note.
  1. Use the SetNoPaymentSummary and the SetHasPaymentSummary Action nodes to create custom text for the note_text variable.
  • Click Add storage directive and use the following information to create a storage directive:
  • caseNote = ToString(arg: "User does not have a Payment profile. Offer KB solution").
  • caseNote = ToString(arg: "User has a Payment profile. Offer KB solution").
  1. Add an Action node after SetCaseCategory node, and then set the name to SetCaseNote.
  2. Set Enter a value with the following information:
  • AddCaseNote(case_id: case_id, from_address: "code lab 4", note_text: caseNote, subject:"code lab 4 summary note").
  1. Set Next step > Page > TerminalPage
  2. Click Save, check the save message for validation, and then test the workflow.

94778c2399ed38bf.png

In some circumstances, you might need a link to external tools with Case ID as a parameter.

For example, for a Google Admin, you need the case ID as a URL parameter. This is easy to add with a Redwood link-generating function.

In this case, the dynamic URL is google-admin.corp.google.com/v2/account-recovery/case/${case_id}?jt=9&jv=${case_id}. ${case_id} is a dynamic variable substitution used in labels.

To add the URL, follow these steps:

  1. Create a Static text field.
  2. Type the user text into it.
  3. Highlight the text you want to convert to a URL link.

7081c46282f3d0e0.png

  1. Click the Link creation button.
  2. Enter the dynamic string for the URL information.
  • Select Protocol.
  • Target: New window for external tools outside of Cases.
  1. Click Save.
  2. Follow the steps in the next section to test the workflow.

The following is a user exercise. Use rickychang@yahoo.com as the customer email on Cases. You might get an error.

6713e119b3f7ad47.png

Skip to the end to see more hints.

The following are tips and suggestions for ____

Work with the Cases attribute system ID.

When you make a constant, give it a variable name that consist of ALL CAPs with underscores.

First, create some constant variables:

  • CATEGORY_CASE_ATTR = "^^1"
  • CUSTOMER_EMAIL_CASE_ATTR = "^^3"
  • LOCALE_CASE_ATTR = "^^9"

89e9a5c1dfd7c023.png

Now, update the function call for GetCaseAttribute with 1 of the constant variables we just created:

  • Original**:** GetCaseAttribute(attributes: case.attributes, id: "^^3")

New**:** GetCaseAttribute(attributes: case.attributes, id: CUSTOMER_EMAIL_CASE_ATTR)

This makes your code easier to read and understand. It also makes it easy to change different parts of your code if you need a different system ID.

Work with multiple categories

When you work with multiple categories, we suggest that you consolidate all of the different categories together into 1 map.

First, create the constant variables:

  • CASES_MAP
  • {AboutGooglePay: {id:"9103782", note:"Resolution completed. CR [AH TSR] inserted manually. Customer issue resolved & error code troubleshooted.", category: "7061355,7059042,7059129,9056802,9056743"},
  • S8: {id:"9103930", note:"Resolution completed. CR [AH PROMO USED] inserted manually. Order that used HDC located, and customer issue resolved.", category:"7061355,7059042,7059129,9056802,9056743"},
  • S6: {id:"9103930", note:"Resolution completed. CR [AH PROMO USED] inserted manually. Customer's HDC was already redeemed, and customer is ineligible for new HDC.", category:"7061355,7059042,7059129,9056802,9056743"}}

1f98cf115dd885d2.png

Now we can change the function call for AddCaseCategory:

  • Original: AddCaseAttribute(case_id: case_id, attributes: [{id: "^^1", value: "7061355,7073906,7073907,7076358,9006840"}])
  • New: AddCaseAttribute(case_id: case_id, attributes: case_id, attributes: [{id: CATEGORY_CASE_ATTR, value: CASES_MAP.AboutGooglePay.category}])

The following is the pattern you need to learn in order to add Atlas and perform field checks:

  1. Set the default Condition to false, which means no field exists.
  2. Create an Action node to get the Atlas signal.
  3. Create a Decision node to check the Atlas results and to check that the field exists.
  4. The final branch handles the case where the field exists and is valid.

The example below shows how this works:

  1. If the value IsNull() is true, continue.
  2. If Not(arg:HasField()) indicates that there's no field, continue.
  3. If IsWhitespace() is a blank field, continue.
  4. Finally, we have a valid field set to true condition.

b680dfd8d038714f.png