Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This repository was archived by the owner on May 28, 2025. It is now read-only.

We cannot resolve error "missing_unfurl_id" #12

@m0chi2

Description

@m0chi2

Right now I'm trying to send link unfurling to slack channel from AWS lambda(Node.js 14.x) & API Gateway.

I returned a postMessage (using @slack/bolt) including the unfurling_id that was in the value received from Slack via POST,but it did not work.(I tried to return a postMessage (using @slack/bolt) including the unfurling_id that was in the value I received in the POST from Slack, but it didn't work.

Please let me know if you have any advice or hints.
Thanky you.

const AWS = require("aws-sdk");
const docClient = new AWS.DynamoDB.DocumentClient();
const { App } = require('@slack/bolt');

exports.handler = async (event, context, callback) => {
    const obj = JSON.parse(JSON.stringify(event));
    const posted_url = obj.event.links[0].url;

    const postMessage = async (data) => {
          const app = new App({
              token: process.env.USER_OAUTH_TOKEN,
              signingSecret: process.env.SIGNING_SECRET
          });
            try {
                const result = app.client.chat.unfurl(data);
                return await result;
            }
            catch (error) {
                console.error(error);
            }
        };

    const setResnponse =  async(userName) => {
      const text = userName + "AAAA";
      const unfurling = {
              "token": process.env.USER_OAUTH_TOKEN,
              "channel": obj.event.channel,
              "ts": obj.event.message_ts,
              "source": "composer",
              "unfurl_id": obj.event.unfurl_id,
              "unfurls": {
                  posted_url: {
                      "blocks": [
                          {
                              "type": "section",
                              "text": {
                                  "type": "mrkdwn",
                                  "text": text
                          }
                      ]
                  }
              },
       };

    const data = setResnponse("BBB")
    const res = await postMessage(data);
    return res;
};
Value obtained from Slack
{
  token: 'QxsXXXXXX',
  team_id: 'YYYYYY',
  api_app_id: 'ZZZZZZZ',
  event: {
    type: 'link_shared',
    user: 'U0XXXXXX',
    channel: 'C0XXXXXX',
    message_ts: '163XXXX.XXXX',
    links: [ [Object] ],
    source: 'conversations_history',
    unfurl_id: 'C0XXXXX.163XXXXX.YYYYYY.4041d4facXXXXXXXXX',
    is_bot_user_member: true,
    thread_ts: '163XXXXX.000200',
    event_ts: '163XXXXXX.274916'
  },
  type: 'event_callback',
  ........
}
Error Code
ERROR    Error: An API error occurred: missing_unfurl_id
    at Object.platformErrorFromResult (/opt/nodejs/node_modules/@slack/web-api/dist/errors.js:51:33)
    at WebClient.apiCall (/opt/nodejs/node_modules/@slack/web-api/dist/WebClient.js:158:28)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async postMessage (/var/task/index.js:106:20)
    at async Runtime.exports.handler (/var/task/index.js:123:21) {
  code: 'slack_webapi_platform_error',
  data: {
    ok: false,
    error: 'missing_unfurl_id',
    response_metadata: { scopes: [Array], acceptedScopes: [Array] }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions