You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过UnificationEngine(UE)利用已有Line连接发送消息?

Hey there! Since you've already set up a user and linked Line via Unification Engine (UE), sending messages through that connection is straightforward. Here's a step-by-step breakdown to get you going:

Step 1: Gather Required Credentials

First, make sure you have these details ready (you can find most of them in your UE dashboard or via API responses from your setup steps):

  • Your UE user_id (the unique ID for the user you created)
  • The connection_id for your Line integration (assigned when you added the Line link to your UE user)
  • Your UE API access token (located in your UE account settings under API credentials)
Step 2: Construct the Message Payload

UE uses a standardized JSON payload that works across all supported channels. For Line, here's a basic example of what your payload should look like:

{
  "user_id": "YOUR_UE_USER_ID",
  "connection_id": "YOUR_LINE_CONNECTION_ID",
  "message": {
    "text": "Hey there! This message is sent via Unification Engine to Line."
  },
  "to": {
    "line": {
      "user_id": "TARGET_LINE_USER_ID" // Replace with the recipient's Line user ID
    }
  }
}
  • Want to send rich content? Line supports stickers, images, and more. Here's a quick example for a sticker:
    "message": {
      "sticker": {
        "package_id": "1",
        "sticker_id": "100"
      }
    }
    
  • If sending to a Line group, swap user_id in the to.line object with group_id and use the group's unique ID instead.
Step 3: Send the Request via UE API

Use a POST request to UE's message endpoint. Here's how to do it with curl:

curl -X POST \
  https://api.unificationengine.com/v1/messages \
  -H 'Authorization: Bearer YOUR_UE_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "user_id": "YOUR_UE_USER_ID",
    "connection_id": "YOUR_LINE_CONNECTION_ID",
    "message": {
      "text": "Hello from UE!"
    },
    "to": {
      "line": {
        "user_id": "TARGET_LINE_USER_ID"
      }
    }
  }'
  • For programming languages, use their native HTTP libraries. Here's a Python example with requests:
import requests

url = "https://api.unificationengine.com/v1/messages"
headers = {
    "Authorization": "Bearer YOUR_UE_API_TOKEN",
    "Content-Type": "application/json"
}
payload = {
    "user_id": "YOUR_UE_USER_ID",
    "connection_id": "YOUR_LINE_CONNECTION_ID",
    "message": {"text": "Hello from UE!"},
    "to": {"line": {"user_id": "TARGET_LINE_USER_ID"}}
}

response = requests.post(url, json=payload)
print(response.json())
Step 4: Check the Response

UE will return a JSON response to confirm success or flag errors. A successful response looks like this:

{
  "status": "success",
  "message_id": "UE_GENERATED_MESSAGE_ID"
}
  • If you get an error, the response will include details to troubleshoot—common issues include invalid credentials, incorrect target IDs, or missing required fields in the payload.

内容的提问来源于stack exchange,提问作者Bernad Vicky

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 09:55:31