Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs handlebars #68

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions docs/docs/cli/integrations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accidentally committed this file into this PR?

## Overview

Mailscript provides integrations with external services such as Google Drive and Zoom. These integrations provide validated OAuth tokens to Mailscript Actions after the integrations are setup. The provided OAuth tokens can be used to interact directly with the integrated service.

## Google Drive

The Google Drive Integration provides an OAuth token with the permissions defined by [drive.files](https://www.googleapis.com/auth/drive.file). This allows for viewing and managing Google Drive files and folders that you have opened or created with this app.

### Setup

To setup the Google Drive Integration, first ensure you are logged in under the CLI with:
```
mailscript login
```

Then, add the Google Drive Integration with the following:
```
mailscript integrations:add --gdrive
```

This will open up your default web browsers with a prompt to sign in to Google.

### Usage

To access the Google Drive Integration from an Action, [Variable Interpolation]() is required on `integrations.google`, which returns the Integration's OAuth token.

Note: The Integration's OAuth token is only provided to Webhook-typed Actions.

## Zoom

The Zoom Integration provides an OAuth token. This allows for full access to the Zoom API with your authority.

Note: This Integration is not currently supported.

### Setup

There is currently no easy way to setup the Zoom Integration and is not currently supported.

### Usage

Since the Zoom Integration is not suppported yet, Zoom OAuth tokens are not exposed to Mailscript Actions.
58 changes: 41 additions & 17 deletions docs/docs/cli/workflow-variables.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,63 @@
# Workflow Variables

## Intro
## Overview

In workflows there are multiple variables that are passed down to the built in parser. In mailscript we use handlebars to allow you to substitute text in for processed variables. If you are unfamiliar with handlbars I'd suggest you read up on it [here](https://handlebarsjs.com/)
In the Mailscript Pipeline, E-Mail messages are parsed into a custom JSON object. This object contains a wealth of metadata based on each message and other useful bits of information like [Integrations](/cli/integrations). To access this data, Mailscript Actions' `body` and `text` tags are parsed with HandleBars, providing a method of Variable Interpolation and, thus, allowing you to substitute text in for processed metadata. For more in-depth documentaion on HandlBars, read up on it [here](https://handlebarsjs.com/guide/).

Some example handlebars syntax
### HandleBars Example

`
My subject is {{subject}}
`

Assuming the variable subject is not undefined and defined as "did you receive my email?"
```
My variable is {{variable}}
```

The processed output would look like: "My subject is did you receive my email?"
Assuming the variable is defined as "did you receive my email?", the processed output would look like:
```
My variable is did you receive my email?
```

## Available Metadata

## Available variables
There are many data fields generated by the Mailscript Pipeline for each E-Mail message. These fields can be used in the `body` or `text` section of a Mailscript Action in your Mailscript Workflow. The data fields will be available regardless of the type of the Action. Additional data fields may be supplied depending on the contents of the E-Mail message and the type of the Action. See the [Examplea](#examples) section for usage.

We provide a couple of different out of the box variables, which can be used in the body section of the action in your workflow. These variables will be available regardless of what integration, or trigger is used. Additional variables may be supplied depending on what integration is used.
### Subset of Metadata Fields

| Name | Description |
| ----------- | ----------- |
| `msg.text` | Body of the email in the pipeline |
| `msg.html` | HTML body of the email |
| `msg.text` | Body of the text-only email |
| `msg.html` | Body of the HTML-formatted email |
| `msg.subject` | Subject line of the email |
| `msg.attachments` | List of attachments in the email |

## Extended HandleBars Functionality

Some extra functionality has been added to HandleBars. This includes a special data field (`all`) and a Regular Expression matcher.

### `all` Data Field

The `all` data field returns the entirety of the JSON object created by the Mailscript Pipeline.

#### YML Example
### Regular Expression Matcher

The Regular Expression matcher is used on a data field to check if some formatted text is present or to collect dynamic data from an E-Mail message such as a time, date, or price. The syntax for the matcher is defined as follows:

```
{{ match data-field regex regex-flags index-of-match }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you include the example regex you showed us?

```

- match: the keyword to initiate the match
- data-field: the metadata field to run the Regular Expression on
- regex: the Regular Expression to run on the metadata field
- regex-flags: the flags to mask onto the Regular Expression
- index-of-match: the index of the match to choose (starting at 0)

## Examples

### YML Example

<img src="/images/var_example_yml.png"/>

This example was taken from the [annotated workflow example](https://github.com/mailscript/cli/blob/main/docs/docs/cli/annotated-workflow.yml)

#### CLI Example
### CLI Example
Or, if you are using the CLI:

Forwarding an email
Expand All @@ -45,4 +69,4 @@ Sending a SMS message
Note: This will require you to verify the sms number used ahead of time or this will not be able to receive SMS messages upon execution of the action.
```sh
mailscript actions:add --sms=1235555000 --text "The body of the email is {{msg.text}}"
```
```
7 changes: 4 additions & 3 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ site_url: https://docs.mailscript.com/
edit_uri: 'edit/main/docs/'

# Repository
repo_name: mailscript/docs
repo_url: https://github.com/mailscript/docs
repo_name: Mailscript()
repo_url: https://github.com/mailscript/cli

# Copyright
copyright: '&copy; Mailscript'
Expand Down Expand Up @@ -39,7 +39,8 @@ nav:
- Send: cli/send.md
- Daemon: cli/daemon-tutorial.md
- Custom Domains: cli/domains.md
- Workflow Variables: cli/workflow-variables.md
- Data Field Interpolation: cli/workflow-variables.md
- Integrations: cli/integrations.md
#- API: api.md
#- SDK Clients: sdk-clients.md

Expand Down