How to show email or HTML in Workshop?

I’m ingesting emails in Foundry, which I’m processing and extracting the HTML of the email body.

I need to display this to end users that are using the application, like if they would in an email inbox.

How can I show the HTML of an email in Workshop ?

1 Like

You can use a combination of Workshop and Slate.

The high level setup is that Workshop embeds a Slate application, containing the HTML widget that will display the HTML content of your choice.

There are 2 main ways to pass the HTML content to Slate:

  • Workshop pass the object reference that contains the HTML (so, in short, you pass a “reference” to something so that Slate can then figure out which HTML to display)
  • Workshop pass the HTML to Slate directly as a string (simpler)

I’ll detail the first option, but the second one should be even more straightforward.

Option 1 - Pass an Object reference between Workshop and Slate

The whole configuration is detailed there: https://www.palantir.com/docs/foundry/workshop/widgets-iframe

The configuration on the slate side:

  1. Create a variable that will contain a reference to the object passed by Workshop . The actual value will dynamically be passed, but will have the shape of the following json
{
  "static": {
    "objectRids": [
      "ri.phonograph2-objects.main.object.532bc14d-1234-4b0e-980f-5f528a8abd0f"
    ]
  },
  "type": "static"
}
  1. Create an event that fetch the value passed by Workshop and put it in the variable. The “key” should be the same key as used on the Workshop side, later.
const payload = {{slEventValue}}
return payload["email_object_pk"]
  1. Create a function that extract the RID of the object passed by Workshop
return {{v_email_object_pk.static.objectRids.[0]}}

  1. Create a Platform query, which is an object context retrieval, to fetch the content of the object by using the output of the function {{f_object_rid}}

  2. Add an HTML widget with the following configuration:
    Content (“email_body” is the property of the object that contains the html):

{{o_object_context_1.email_body}}

Custom styles:

width:100%;
height:100%;

The HTML widget needs to take all the space:

On the Workshop side:

  1. Add a Custom widget iframe
  2. Add Slate as the content of the iframe
  3. Add the input parameter and pass your object with the same key as what you fetch on the Slate side (step 2 earlier)

The email should be displayed !

Option 2 - Pass the HTML content between Workshop and Slate

Very similar to above, but instead:

  1. Create a variable that will contain the content to display . The actual value will dynamically be passed, and will be a flat string
<div>some html</div>
  1. Create an event that fetch the value passed by Workshop and put it in the variable. The “key” should be the same key as used on the Workshop side, later.
const payload = {{slEventValue}}
return payload["email_content"]
  1. Add an HTML widget with the following configuration:
    Content (“email_body” is the property of the object that contains the html):
{{my_variable_containing_the_content}}

Custom styles:

width:100%;
height:100%;

On the Workshop side:

  1. Add a Custom widget iframe
  2. Add Slate as the content of the iframe
  3. Add the input parameter and pass your object with the same key as what you fetch on the Slate side (step 2 earlier)

The email should be displayed !

Note: Storing large strings in Object might incur a significant cost. As usual, be mindful to propagate as Objects the necessary large strings for your workflows.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.