This workflow demonstrates how to use the LINE Messaging API to handle two scenarios:
To simplify the setup process, create a Header Auth credential in n8n:
AuthorizationBearer {line token}POST{n8n-webhook-page}message.{{ $json.body.events[0].type }} equals "message"POSThttps://api.line.me/v2/bot/message/reply{
"replyToken": "{{ $('Webhook from Line Message').item.json.body.events[0].replyToken }}",
"messages": [
{
"type": "text",
"text": "收到您的訊息 : {{ $('Webhook from Line Message').item.json.body.events[0].message.text }}"
}
]
}
line_uid: UxxxxxxxxxxxxPOSThttps://api.line.me/v2/bot/message/push{
"to": "{{ $json.line_uid }}",
"messages": [
{
"type": "text",
"text": "推播測試"
}
]
}
此工作流程展示如何使用 LINE Messaging API 處理兩種情境:
為簡化設定流程,請在 n8n 中建立 Header Auth 憑證:
AuthorizationBearer {line token}POST{n8n-webhook-page}message。{{ $json.body.events[0].type }} 等於 "message"POSThttps://api.line.me/v2/bot/message/reply{
"replyToken": "{{ $('Webhook from Line Message').item.json.body.events[0].replyToken }}",
"messages": [
{
"type": "text",
"text": "收到您的訊息 : {{ $('Webhook from Line Message').item.json.body.events[0].message.text }}"
}
]
}
line_uid:UxxxxxxxxxxxxPOSThttps://api.line.me/v2/bot/message/push{
"to": "{{ $json.line_uid }}",
"messages": [
{
"type": "text",
"text": "推播測試"
}
]
}
完成示意圖 (Storyboard Example):
