# AddAttachmentInbound Message

Click on the **'Messages' icon** to open the Messages page. Click **New**.

![](https://content.gitbook.com/content/2EJsRh73QF1TvP9eLF8k/blobs/UjsHspVPyCKXxDrA9mmE/iapg-addattachmentinbound-message-1.png)

## New Message Modal

The fields to be configured for the AddAttachmentInbound New Message modal are as follows:

| Field        | Description                                                         | Value                  |
| ------------ | ------------------------------------------------------------------- | ---------------------- |
| Message name | The message name that is unique for this integration.               | 'AddAttachmentInbound' |
| Type         | The primary purpose of the message.                                 | 'Update'               |
| Direction    | The direction(s) this message is configured to support.             | 'Inbound'              |
| Description  | The description for this message and the requirement it is meeting. | \<Your description>    |

*Your AddAttachmentInbound New Message modal should look like this:*

![](https://content.gitbook.com/content/2EJsRh73QF1TvP9eLF8k/blobs/2KiL15fntUxnIbZG5dcP/iapg-addattachmentinbound-message-2.png)

Click **Submit and view** to further configure the Message.

## Response Fields

Navigate to **Message > Response**.

The Response fields to be configured are as follows:

| Field    | Description                                                                                                                              | Value              |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
| Response | The immediate synchronous response to this message.                                                                                      | lookup: 'Response' |
| Async\*  | Turn this option on if you want inbound processing to occur asynchronously or this message is the first of an asynchronous message pair. | \<false>           |

*\*This field is automatically defaulted to true.*

*Your Response form should look like this:*

![](https://content.gitbook.com/content/2EJsRh73QF1TvP9eLF8k/blobs/4Wna2epQCiJSQiNACmWj/iapg-addattachmentinbound-message-3.png)

Navigate to **Message > Bond**.

## Bond Fields

The Bond fields to be configured are as follows:

| Field                 | Description                                                                                                                                                                                                 | Value    |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| Bond ownership\*      | Determine if the sender should own the bond or not in order for this message to be processed? Use 'Ignore' to process regardless of the owner flag. *(Choices: Ignore, Must own, Must not own.)*            | 'Ignore' |
| Bond condition type\* | The type of conditional check made on the bond. (*None:* no checks are made. *State:* checks against the state are made using the conditional checkboxes. *Scripted:* the 'Bond condition' script is used.) | 'State'  |
| Bond pending          | Process this message when the bond state is Pending.                                                                                                                                                        | \<true>  |
| Bond open             | Process this message when the bond state is Open.                                                                                                                                                           | \<true>  |

*\*These fields are automatically populated.*

*Your Bond form should look like this:*

![](https://content.gitbook.com/content/2EJsRh73QF1TvP9eLF8k/blobs/2ub04d6OIdaGtwTCLcLZ/iapg-addattachmentinbound-message-4.png)

Navigate to **Inbound > Settings**.

## Inbound Settings Fields

The Inbound Settings fields to be configured are as follows:

| Field                   | Description                                                                    | Value      |
| ----------------------- | ------------------------------------------------------------------------------ | ---------- |
| Bond reference method\* | Method of searching for and validating an existing bond for incoming messages. | 'Internal' |

{% hint style="info" %}
*\*Bond reference method:*

*Internal -* lookup using the internal reference only.

*External -* lookup using the external reference only.

*Both -* lookup using both the internal and external references.
{% endhint %}

{% hint style="success" %}
We have chosen the 'Internal' method because, in the payload we built, we supplied the `correlation_id`.
{% endhint %}

*Your Inbound Settings form should look like this:*

![](https://content.gitbook.com/content/2EJsRh73QF1TvP9eLF8k/blobs/qBdxfeXw2box5ogRGF8x/iapg-addattachmentinbound-message-5.png)

Navigate to **Advanced > Script Editor**.

## Script Editor Fields

Click on **View > Inbound**.

The Script Editor fields to be configured are as follows:

| Field                      | Description        | Value                                                       |
| -------------------------- | ------------------ | ----------------------------------------------------------- |
| Payload to Stage (Inbound) | The script to run. | Replace the commented out instructions with the code below. |

*The code in the 'Payload to Stage' script field should look like this:*

```javascript
(function processPayloadToStage(payload, stage, transaction, message) {

  // set either internal/external reference on stage depending on what is needed.
  // make sure to configure the Bond reference lookup on the Message to be Internal/External

    stage.internal_reference = payload.correlation_id;

})(payload, stage, transaction, message);
```

*Your Script Editor fields should look like this:*

![](https://content.gitbook.com/content/2EJsRh73QF1TvP9eLF8k/blobs/XMCgoOH5BuZ2lf6CJOex/iapg-addattachmentinbound-message-6.png)

Click **Save**.

We can now move on to **Testing**.
