---
# System prepended metadata

title: Message-Proxy to Webhook Payload

---

# Message-Proxy to Webhook Payload

| property   | type   | required | desc                                                 |
| ---------- | ------ | -------- | ---------------------------------------------------- |
| events     | array  | required |                                                      |
| chatObject | object | required | ```chatObject```                                     |
| to.userId  | string | required | format = tp-{projectId}-native-{userId from Request} |
| messages   | array  | required | array of ```message```                               |

```
{
  "events: [{
    "chatObject": {...},
    "to": {
      "userId": "tp-2-native-11037#1581565331651"
    },
    "messages": [
      {...},
      {...},
      {...}
    ]
  }]
}
```

## chatObject
| property  | type    | required | desc                                       |
| --------- | ------- | -------- | ------------------------------------------ |
| id        | string  | required | chatObject id in database                  |
| from      | string  | required | format = cb-{projectId}                    |
| roomId    | string  | required | room id in database                        |
| timeStamp | integer | required | the number of milliseconds from 1970-01-01 |

```
{
  "id": "5d46b3e1-a3cb-4bd7-b276-1d51a906fe5a",
  "from": "cb-2",
  "roomId": "eddc1552-ebd9-4bbf-bb43-fa107fd52fbd",
  "timeStamp": 1581565403332
}
```

## message types

* text
* text card
* media card
* card carousel

## message details

### text
| property   | type   | required | desc              |
| ---------- | ------ | -------- | ----------------- |
| type       | string | required | ```text```        |
| text       | string | required | print content     |
| extensions | object | required | extensions object |
| customPayload | object | optional | custom payload |

```
{
  "type": "text",
  "text": "hello world",
  "extensions": {
    showFeedbackButtons: true,
  },
}
```

### text card
| property      | type   | required | desc                                          |
| ------------- | ------ | -------- | --------------------------------------------- |
| type          | string | required | ```textCard```                                |
| headerText    | string | opt      | header text                                   |
| bodyText      | string | opt      | content text                                  |
| defaultAction | object | opt      | action of click card or image.  action object |
| extensions    | object | required | extensions object                             |
| actions       | array  | required | array of action objects. max: 3               |
| customPayload | object | optional | custom payload |

```
{
  "type": "textCard",
  "headerText": "This is an awesome card!",
  "bodyText": "First line\nSecond line\nThird line...etc.",
  "extensions": {
    showFeedbackButtons: true,
  },
  "defaultAction": {
    "type": "postback",
    "payload": "PAYLOAD_IN_PLAIN_TEXT(while clicking image)"
  },
  "actions": [
    {...},
    {...},
    {...}
  ]
}
```

### media card
| property      | type   | required | desc                                          |
| ------------- | ------ | -------- | --------------------------------------------- |
| type          | string | required | ```mediaCard```                               |
| headerText    | string | opt      | header text                                   |
| bodyText      | string | opt      | content text                                  |
| imageSrc      | string | required | image url or base64 string                    |
| defaultAction | object | opt      | action of click card or image.  action object |
| extensions    | object | required | extensions object                             |
| actions       | array  | required | array of action objects. max: 3               |
| customPayload | object | optional | custom payload |

```
{
  "type": "mediaCard",
  "headerText": "This is an awesome card!",
  "imageSrc": "https://aabb.com/abcde.png",
  "bodyText": "First line\nSecond line\nThird line...etc.",
  "extensions": {
  },
  "defaultAction": {
    "type": "postback",
    "payload": "PAYLOAD_IN_PLAIN_TEXT(while clicking image)"
  },
  "actions": [
    {...},
    {...},
    {...}
  ]
}
```

### card carousel
| property | type   | required | desc                                               |
| -------- | ------ | -------- | -------------------------------------------------- |
| type     | string | required | ```cardCarousel```                                 |
| elements | array  | required | array of textCard, mediaCard or chartCard. max: 10 |
| customPayload | object | optional | custom payload |

```
{
  "type": "cardCarousel",
  "elements": [
    {...},
    {...}
  ]
}
```

# action types

* d8
  - postback
  - uri
  - message

* line
  - postback
  - message
  - uri
  - date time picker
  - camera
  - camera roll
  - location

* facebook
  - web_url
  - postback
  - element_share
  - payment
  - phone_number
  - account_link
  - account_unlink
  - game_play

## action details

### postback
| property | type   | required | desc                                                               |
| -------- | ------ | -------- | ------------------------------------------------------------------ |
| type     | string | required | ```postback```                                                     |
| payload  | string | required | string returned via webhook. max: 300                              |
| label    | string | required | label for the action. max: 20                                      |
| text     | string | required | text displayed in the chat as a message sent by the user. max: 300 |

```
{
  "type":"postback",
  "payload":"action=buy&itemid=111",
  "label":"Buy",
  "text":"Buy"
}
```

### uri
| property | type   | required | desc                                               |
| -------- | ------ | -------- | -------------------------------------------------- |
| type     | string | required | ```uri```                                          |
| label    | string | required | label for the action. max: 20                      |
| uri      | string | required | URI opened when the action is performed. max: 1000 |

```
{
  "type":"uri",
  "uri":"http://example.com/page/222",
  "label":"View details"
}
```

### message
| property | type   | required | desc                                             |
| -------- | ------ | -------- | ------------------------------------------------ |
| type     | string | required | ```message```                                    |
| label    | string | required | label for the action. max: 20                    |
| text     | string | required | Text sent when the action is performed. max: 300 |

```
{
  "type":"message",
  "label":"Yes",
  "text":"Yes"
}
```

# extensions object
| property            | type    | required | desc                             |
| ------------------- | ------- | -------- | -------------------------------- |
| showFeedbackButtons | boolean | opt      | whether to show feedback buttons |

```
{
  "showFeedbackButtons" : false,
}
```

# references
* [facebook](https://developers.facebook.com/docs/messenger-platform/reference/template/generic)
* [line](https://developers.line.biz/en/reference/messaging-api/#carousel)
* [facebook action types](https://developers.facebook.com/docs/messenger-platform/send-messages/buttons)
* [line action types](https://developers.line.biz/en/reference/messaging-api/#action-objects)
* [facebook message components](https://developers.facebook.com/docs/messenger-platform/introduction/conversation-components)
* [facebook message definition](https://developers.facebook.com/docs/messenger-platform/send-messages)
* [line message types](https://developers.line.biz/en/docs/messaging-api/message-types/)
