# LetterSG

## What is LetterSG?

LetterSG is a platform that allows public officers to create, issue and track personalised official e-letters to citizens.

More information about LetterSG can be found [here](https://guide.letters.gov.sg/).

## Setting up LetterSG connection

1. Click on the :heavy\_plus\_sign: logo in between steps or "Add Step"
2. Select "LetterSG"
3. Under "Choose connection", click the dropdown
4. Click "Add new connection"
5. Under "Label", key in the name you want to associate this connection with
6. Login to [LetterSG](https://letters.gov.sg/) and follow this [guide](https://guide.letters.gov.sg/developer-guide/api-documentation) to obtain the API key. Key it under "API key"
7. Click "Connect"
8. Under "2. Create letter", a green dot will appear as an indication that the LetterSG connection is successful

<figure><img src="/files/Pc9rxJ4dVzM7hfCngzKj" alt=""><figcaption></figcaption></figure>

## Create letter

| Field               | Description                                                                                                                                                                                                                                                                  | Required?            |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- |
| Template            | Sets the template you want for creating a letter                                                                                                                                                                                                                             | :heavy\_check\_mark: |
| Export as PDF       | <p>Two options to select:</p><ol><li>Send the letter link directly (recommended): This does not generate a PDF to be sent to the user.</li><li>Export letter as PDF to send: This generates a PDF which can be used with an "Email by Postman" in the next step.  </li></ol> | :heavy\_check\_mark: |
| Personalised fields | <p>These are variables in your letter template in this format <code>{{field\_name}}</code> </p><p></p><p>Click on "+ And" to add all the fields in your template.</p>                                                                                                        | :heavy\_check\_mark: |

1. Set up your letter by completing the required fields:
   1. **Template**
   2. **Export as PDF**
   3. **Personalised fields**
2. Click on **Check step** to save and generate a letter for your templated based on the personalised fields you have set up.

### Check step

The **Check step** button saves your set up and tests the Create Letter action by generating a **sample** letter based on the personalised fields specified. This allows you to verify the letter design before the Pipe is published and the workflow runs automatically.

## Common Errors

<details>

<summary>Personalised field(s) not specified</summary>

<figure><img src="/files/gHk4Yu0oXjAf3ClfimWy" alt=""><figcaption></figcaption></figure>

This happens when you have not selected all the fields required in your template. Check that you have selected those fields that are indicated in the error message before running "Check step" again.

</details>

<details>

<summary><code>field_name</code> is repeated</summary>

This happens when you have selected repeated fields in your setup. Make sure you only include one of each before running "Check step" again.

</details>

<details>

<summary>Field empty</summary>

This happens when you have not selected a field in the dropdown. Please make sure you select the required fields for your template.

</details>

<details>

<summary>Value empty</summary>

This happens when you have not entered a value for your field. Please make sure you key in the respective value for your template fields.

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://guide.plumber.gov.sg/user-guides/actions/lettersg.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
