> For the complete documentation index, see [llms.txt](https://en.help.firstline.cc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://en.help.firstline.cc/feature/integrate/automation/send-line-message.md).

# Example: Send LINE message

We will demonstrate the steps according to the scenario to show the convenience that the "Automation" feature brings to businesses, as well as how it expands FIRST LINE capabilities through powerful integration.

## 1. Add a new Webhook script

Because sending LINE notifications requires using the LINE Message API, we need to call the API URL via a "Webhook script", and related information can be found at <https://developers.line.biz/en/reference/messaging-api/> the official documentation.

{% hint style="info" %}
**Request URL**: <https://api.line.me/v2/bot/message/push\\>
**Request method**: POST\
**Headers**: Select Authorization and fill in Bearer {channel access token}
{% endhint %}

![](https://3300265106-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MNRu7dk70ei7JV9HlW9%2F-McxvTUIppxp0z02aIlk%2F-Mcxva5APKU9oAmezxb7%2Fimage.png?alt=media\&token=b8164f98-31e6-46bc-a2d9-0eb712e389c9)

## 2. Configure LINE Message API parameters

Next, according to LINE's required format, you should have at least the following 2 fields&#x20;

1. to: ID of the target recipient. Use a userId, groupId, or roomId value returned in a webhook event object. Do not use the LINE ID found on LINE.
2. messages: Messages to send.

{% tabs %}
{% tab title="Ticket example" %}

```javascript
{     
    "to": "U121dadadasdadddsdc",     
    "messages":[         
        {             
           "type": "text",             
           "text": "{{ subject }} event notification!"         
        }     
    ] 
}
```

{% endtab %}

{% tab title="LIFF integration example" %}

```javascript
{
  "to": "{{ textCall.liff_user_id }}",
  "messages": [
    {
      "type": "text",
      "text": "Mr./Ms. {{ contact.full_name }}, hello, the agent sent “{{ textCall.last_message.content }}”,\n please click 👉 https://liff.line.me/xxxxxxx to view the message."
    }
  ]
}
```

{% endtab %}
{% endtabs %}

![Example of LIFF cooperating with real-time chat notifications to users](https://3300265106-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MNRu7dk70ei7JV9HlW9%2F-Mcxyj6JL2HTTB4lZDBo%2F-McxytjbVHmBQZepfSOE%2Fimage.png?alt=media\&token=829f77f7-eff3-4bfb-bc17-88ce281a6535)

## 3. Add automation

Finally, after adding the "Send LINE Notification" Webhook script, it will not run automatically, so we need to set the desired conditions via the "Automation" feature and select this "Webhook" in the "Actions". Then just wait for the event to occur to enjoy the benefits of automation.

![](https://3300265106-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MNRu7dk70ei7JV9HlW9%2F-McxzIR6mSTyKbRJ7Mfu%2F-McxzS7nTqceJIs6utb-%2Fimage.png?alt=media\&token=4bfa8266-4905-4ea2-a703-9c89eaec3fea)

### Design use cases

You can decide when to send LINE notifications based on different use cases and add corresponding conditions and triggers, such as the following situations:

* When there is an urgent ticket, send a LINE notification to alert the relevant department.
* When integrating real-time chat in LIFF, if the agent replies but the customer hasn't opened the chat window, send a LINE notification informing them of the content and the LIFF URL.
* When a ticket is reassigned to a specified supervisor, also send a notification reminder.

![Send LINE notification to alert the relevant department](https://3300265106-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MNRu7dk70ei7JV9HlW9%2F-Mcy-hVrF16zohGfyRtn%2F-Mcy-pU4unBiwwfF_2o6%2Fimage.png?alt=media\&token=4e2fd37b-b07b-4f9e-b879-93e9dbf4000b)
