如何通过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:
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_idfor 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)
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_idin theto.lineobject withgroup_idand use the group's unique ID instead.
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())
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

