Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We cannot resolve error "missing_unfurl_id" #12

Open
m0chi2 opened this issue Dec 14, 2021 · 0 comments
Open

We cannot resolve error "missing_unfurl_id" #12

m0chi2 opened this issue Dec 14, 2021 · 0 comments

Comments

@m0chi2
Copy link

m0chi2 commented Dec 14, 2021

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] }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant