# JSON API for LINE

You can make many kinds of HTTP requests for your bot to analyze your backend and send responses.

To be specific, you can run:

1. Create dynamic messages
2. Execute “postbacks”
3. Obtain and set up user arguments (coming soon)
4. Redirecting to other messages (coming soon)

### **Response reference**

We will parse the JSON response and send a message to the customer based on the response. For more information, please visit <https://developers.line.biz/en/reference/messaging-api/>

### Sending Text&#x20;

The response below will send text to a customer.

```
{
  "messages": [
    {
      "type": "text",
      "text": "Welcome to the smartest bot building tool ever —— YOCTOL.AI"
    },
    {
      "type": "text",
      "text": "what kind of bot do you want  to build?"
    }
  ]
}
```

### Sending Image

Image formats of JPG are supported as messages from JSON requests.

```
{
  "messages": [
    {
      "type": "image",
      "originalContentUrl": "https://example.com/original.jpg",
      "previewImageUrl": "https://example.com/preview.jpg"
    }
  ]
}
```

### Sending Video&#x20;

The following response is an example of using a video as message. Currently, LINE only supports MP4 files with size less than 10MB and time less than 1 minute.

```
{
  "messages": [
    {
      "type": "video",
      "originalContentUrl": "https://example.com/original.mp4",
      "previewImageUrl": "https://example.com/preview.jpg"
    }
  ]
}
```

### Sending Voice Messages

The following response will send a voice message file. Currently, LINE only supports memo files with size less than 10MB, less than 1 minute and extensions of M4A.

```
{
  "messages": [
    {
      "attachment": {
        "type": "audio",
        "payload": {
          "url": "https://ccrma.stanford.edu/~jos/mp3/bachfugue.mp3"
        }
      }
    }
  ]

```

### Sending Sticker

The following response will send a sticker.

```
{
  "messages": [
    {
      "type": "sticker",
      "packageId": "1",
      "stickerId": "1"
    }
  ]
}
```

### Sending Buttons

The following response will send a button template. You can manually set up the actions for each button, for example prompting to another website. For more usages of buttons, visit <https://developers.line.biz/en/reference/messaging-api/#buttons>

```
{
  "messages": [
    {
      "type": "template",
      "altText": "This is a buttons template",
      "template": {
        "type": "buttons",
        "thumbnailImageUrl": "https://example.com/bot/images/image.jpg",
        "imageAspectRatio": "rectangle",
        "imageSize": "cover",
        "imageBackgroundColor": "#FFFFFF",
        "title": "Menu",
        "text": "Please select",
        "defaultAction": {
          "type": "uri",
          "label": "View detail",
          "uri": "http://example.com/page/123"
        },
        "actions": [
          {
            "type": "postback",
            "label": "Buy",
            "data": "action=buy&itemid=123"
          },
          {
            "type": "postback",
            "label": "Add to cart",
            "data": "action=add&itemid=123"
          },
          {
            "type": "uri",
            "label": "View detail",
            "uri": "http://example.com/page/123"
          }
        ]
      }
    }
  ]
}
```

You can also send special buttons for actions, such as open camera.

```
{
  "messages": [
    {
      "type": "template",
      "altText": "This is a buttons template",
      "template": {
        "type": "buttons",
        "text": "Please select",
        "actions": [
          {
            "type": "camera",
            "label": "Camera"
          },
          {
            "type": "cameraRoll",
            "label": "Camera roll"
          }
        ]
      }
    }
  ]
}
```

### Sending Quick Reply

The following response provides text with quick reply buttons.

```
{
  "messages": [
    {
      "type": "text",
      "text": "Did you enjoy the last game of the CF Rockets?",
      "quickReply": {
        "items": [
          {
            "type": "action",
            "action": {
              "type": "cameraRoll",
              "label": "Send photo"
            }
          },
          {
            "type": "action",
            "action": {
              "type": "camera",
              "label": "Open camera"
            }
          }
        ]
      }
    }
  ]
}
```

<br>
