How to send a message to a group chat

I would like to send a message to a group chat.

The following document seems to suggest that I should specify the groupId in the to field to send a message to the group chat members. cf. Sending push messages - LINE Developers

Now, how do I get the groupId?

  • 0
  • 4
  • 350
  • twitter facebook

There was no error in receiving the webhook or referencing the groupId.

When I run it against the groupId of a group chat that the bot has unsubscribed from, I get the following error.

    "message": "Failed to send messages"

I created a new channel and enabled webhooks. After setting up the bot to be able to join the group, I registered it as a friend with a QR code and created the group. I was able to send messages to the group chat by pushing to the groupId that I could get at this time.

My lack of knowledge of webhooks may have been the cause of my confusion.

I hope this will be useful for later learners.

  • 0

After restarting the server several times, I was able to retrieve messages via webhook. When I invited the bot to a group chat, I got the following message.

	"events": [
			"type": "join",
			"webhookEventId": "{webhookEventId}",
			"deliveryContext": {
				"isRedelivery": true
			"timestamp": 1654244950948,
			"source": {
				"type": "group",
				"groupId": "{groupId}"
			"replyToken": "{replyToken}",
			"mode": "active"

I believe the groupId shown here is the destination of the push message, but it seems to fail.

curl -L -X POST "https://api.line.me/v2/bot/message/push" -H "Authorization: Bearer {accessToken}" -H "Content-Type: application/json" -H "Content-Type: application/json" -D data-raw "{
    \"to\": \"{groupId}\",
            \"type\" : \"text\",
            \"text\" : \"Hello, world!

The following message is displayed.

    "message": "Failed to send messages"

Do you know why?

  • 0

@ksyt Thanks for the quick reply.

Is that something that can be retrieved when the bot joins the group chat?

Hmmm...is your webhook not set up properly? On my server I run the following code and observe the response body.

const express = require('express');
const bodyParser = require('body-parser');
const app = express();

app.post('/', (req, res) => {


On the LINE Developers page, press the "verify" button on the webhook URL, and the following message will appear in the console.

{ destination: '{userId}', events: [] }

I am assuming from this response that the webhook is set up, but the bot's behavior does not output any other message.

Is there anything odd about my behavior?

  • 0

If your bot (= official account) joins group and get some webhook, it contains group id. See https://developers.line.biz/ja/reference/messaging-api/#source-user.

  • 1

Similar posts

    No similar posts

Are you sure? question.vm