orkestral / venom

Venom is a high-performance system developed with JavaScript to create a bot for WhatsApp, support for creating any interaction, such as customer service, media sending, sentence recognition based on artificial intelligence and all types of design architecture for WhatsApp.
https://orkestral.io
Apache License 2.0
6.08k stars 1.2k forks source link

sendListMenu doesn't work #2419

Closed assiz-git closed 6 months ago

assiz-git commented 1 year ago

Description

Even with an OK return in the "sendListMenu" function call, the list is not sent to the recipient.

Environment

Steps to Reproduce

  1. npm init
  2. npm install venom-bot
  3. Create script package.json: "dev": " npx ts-node ./src/app.ts"
  4. Run npm run dev

Log Output

message {
  id: 'true_55119xxxxxxx5@c.us_1XPSJJF5WPGYB7KO',
  type: 'list',
  t: 1690467634,
  notifyName: '',
  from: '55119xxxxxxx3@c.us',
  to: '55119xxxxxxx5@c.us',
  self: 'out',
  ack: 1,
  invis: true,
  isNewMsg: true,
  star: false,
  kicNotified: false,
  interactiveAnnotations: true,
  streamingSidecar: null,
  waveform: null,
  scanLengths: null,
  scansSidecar: null,
  isFromTemplate: false,
  pollInvalidated: false,
  isSentCagPollCreation: false,
  latestEditMsgKey: null,
  latestEditSenderTimestampMs: null,
  broadcast: false,
  mentionedJidList: [],
  groupMentions: [],
  footer: 'Subtitle',
  hydratedButtons: null,
  isVcardOverMmsDocument: false,
  isForwarded: false,
  hasReaction: false,
  list: {
    title: 'Title',
    description: 'Description',
    buttonText: 'Menu',
    listType: 1,
    sections: [ [Object], [Object] ]
  },
  productHeaderImageRejected: false,
  lastPlaybackProgress: 0,
  isDynamicReplyButtonsMsg: false,
  dynamicReplyButtons: null,
  isMdHistoryMsg: false,
  stickerSentTs: 0,
  isAvatar: false,
  lastUpdateFromServerTs: 0,
  requiresDirectConnection: false,
  invokedBotWid: null,
  chatId: '55119xxxxxxx5@c.us',
  fromMe: true,
  sender: {
    id: '55119xxxxxxx3@c.us',
    pushname: 'Rxxxxxxxxxxxz',
    type: 'in',
    isBusiness: false,
    isEnterprise: false,
    isSmb: false,
    isUser: true,
    profilePicThumbObj: { id: '55119xxxxxxx3@c.us', tag: '' },
    msgs: null
  },
  timestamp: 1690467634,
  chat: {},
  mediaData: {},
  replyButtons: null,
  buttons: null,
  isGroupMsg: false,
  groupInfo: null
}
Result {
  me: {
    id: {
      server: 'c.us',
      user: '55119xxxxxxx3',
      _serialized: '55119xxxxxxx3@c.us'
    },
    displayName: null,
    verifiedName: null,
    searchName: null,
    pushname: 'Rxxxxxxxxxxxz',
    notifyName: null,
    isBusiness: null,
    formattedUser: null,
    tag: '',
    stale: false,
    eurlStale: false,
    timestamp: 1690466313216,
    hostRetryCount: 0
  },
  to: {
    fromMe: true,
    remote: {
      server: 'c.us',
      user: '55119xxxxxxx5',
      _serialized: '55119xxxxxxx5@c.us'
    },
    id: '1XPSJJF5WPGYB7KO',
    _serialized: 'true_55119xxxxxxx5@c.us_1XPSJJF5WPGYB7KO'
  },
  erro: false,
  text: null,
  status: 'OK'
}

Your Code

  async sendListMenu(to: string, body: string) {

    if (!isValidNumber(to, "BR")) {
      throw new Error('Invalid phone number!')
    }

    let phoneNumber = parsePhoneNumber(to, "BR")?.format("E.164").replace('+', '') as string

    phoneNumber = phoneNumber.includes("@c.us")
      ? phoneNumber
      : `${phoneNumber}@c.us`

    const list = [
      {
        title: "Pasta",
        rows: [
          {
            title: "Ravioli Lasagna",
            description: "Made with layers of frozen cheese",
          }
        ]
      },
      {
        title: "Dessert",
        rows: [
          {
            title: "Baked Ricotta Cake",
            description: "Sweets pecan baklava rolls",
          },
          {
            title: "Lemon Meringue Pie",
            description: "Pastry filled with lemonand meringue.",
          }
        ]
      }
    ]

    await this.client.sendListMenu(phoneNumber, "Title", "Subtitle", "Description", "Menu", list)
      .then((result) => {
        console.log("Result", result)
      })
      .catch((error) => {
        console.error("Error when sending: ", error)
      })
  }

Additional context / Screenshot

image

marcusfonte18 commented 1 year ago

Tambem estou com o mesmo problema. Consigo enviar a lista retorna OK mas nao aparece na tela. No caso seria quando eu envio a Letra B

`async function start(client) { client.onMessage(async (message) => {

if (message.body.toLowerCase() === '/list') {
  ///envia uma lista sem simples.
} else if (message.body.toLowerCase() === 'b') {
  // Opções dos botões
  // Construindo a mensagem com botões
  const list = [
    {
      title: "Pasta",
      rows: [
        {
          title: "Ravioli Lasagna",
          description: "Made with layers of frozen cheese",
        }
      ]
    },
    {
      title: "Dessert",
      rows: [
        {
          title: "Baked Ricotta Cake",
          description: "Sweets pecan baklava rolls",
        },
        {
          title: "Lemon Meringue Pie",
          description: "Pastry filled with lemonand meringue.",
        }
      ]
    }
  ];

await client.sendListMenu(message.from, 'Title', 'subTitle', 'Description', 'menu', list)
  .then((result) => {
    console.log('Result: ', result); //return object success
  })
  .catch((erro) => {
    console.error('Error when sending: ', erro); //return object error
  });

}

}); } `

Result: { me: { id: { server: 'c.us', user: '5521966XXXXX', _serialized: '5521966XXXXXXX@c.us' }, displayName: null, verifiedName: null, searchName: null, pushname: null, notifyName: null, isBusiness: null, formattedUser: null, tag: '', stale: false, eurlStale: false, timestamp: 1690602853473 }, to: { fromMe: true, remote: { server: 'c.us', user: '5521975XXXXXX', _serialized: '5521975XXXXXX@c.us' }, id: 'NJAH1EJNXXXXXXXX', _serialized: 'true_55219XXXXXXX@c.us_NJAH1EXXXXXXXX' }, erro: false, text: null, status: 'OK' }

allanalcantara commented 1 year ago

Imagem do WhatsApp de 2023-09-11 à(s) 23 10 47

Tambem estou com o mesmo problema. Consigo enviar a lista retorna OK mas nao aparece na tela. No caso seria quando eu envio a Letra B

if (message.body.toLowerCase() === '/list') {
  ///envia uma lista sem simples.
} else if (message.body.toLowerCase() === 'b') {
  // Opções dos botões
  // Construindo a mensagem com botões
  const list = [
    {
      title: "Pasta",
      rows: [
        {
          title: "Ravioli Lasagna",
          description: "Made with layers of frozen cheese",
        }
      ]
    },
    {
      title: "Dessert",
      rows: [
        {
          title: "Baked Ricotta Cake",
          description: "Sweets pecan baklava rolls",
        },
        {
          title: "Lemon Meringue Pie",
          description: "Pastry filled with lemonand meringue.",
        }
      ]
    }
  ];

await client.sendListMenu(message.from, 'Title', 'subTitle', 'Description', 'menu', list)
  .then((result) => {
    console.log('Result: ', result); //return object success
  })
  .catch((erro) => {
    console.error('Error when sending: ', erro); //return object error
  });

}

}); } `

Result: { me: { id: { server: 'c.us', user: '5521966XXXXX', _serialized: '5521966XXXXXXX@c.us' }, displayName: null, verifiedName: null, searchName: null, pushname: null, notifyName: null, isBusiness: null, formattedUser: null, tag: '', stale: false, eurlStale: false, timestamp: 1690602853473 }, to: { fromMe: true, remote: { server: 'c.us', user: '5521975XXXXXX', _serialized: '5521975XXXXXX@c.us' }, id: 'NJAH1EJNXXXXXXXX', _serialized: 'true_55219XXXXXXX@c.us_NJAH1EXXXXXXXX' }, erro: false, text: null, status: 'OK' }

talvez seu erro seja o que os demais também esta apresentando, tenta assim: troca "await client.sendListMenu" por "

`else if (message.body.toLowerCase() === 'b') {
 const list = [..]
            // envia a lista de menu
            client.sendListMenu(message.from, 'Teste', 'subTitle', 'Descricao', 'ListMenu', list)
                .then((result) => {
                    console.log('Resultado da Lista: ', result); //return object success
                })
                .catch((erro) => {
                    console.error('Error when sending: ', erro); //return object error
                });
        }`

basicamente se vc fizer isso, vai aparecer conforme anexo

orkestral commented 6 months ago

New Release: npm i venom-bot@5.1.0 We have support for Venom for just $15 per month, if you are interested, call our support via the link: https://web.whatsapp.com/send?phone=5561985290357

llDanielll5 commented 3 months ago

Imagem do WhatsApp de 2023-09-11 à(s) 23 10 47

Tambem estou com o mesmo problema. Consigo enviar a lista retorna OK mas nao aparece na tela. No caso seria quando eu envio a Letra B

if (message.body.toLowerCase() === '/list') {
  ///envia uma lista sem simples.
} else if (message.body.toLowerCase() === 'b') {
  // Opções dos botões
  // Construindo a mensagem com botões
  const list = [
    {
      title: "Pasta",
      rows: [
        {
          title: "Ravioli Lasagna",
          description: "Made with layers of frozen cheese",
        }
      ]
    },
    {
      title: "Dessert",
      rows: [
        {
          title: "Baked Ricotta Cake",
          description: "Sweets pecan baklava rolls",
        },
        {
          title: "Lemon Meringue Pie",
          description: "Pastry filled with lemonand meringue.",
        }
      ]
    }
  ];

await client.sendListMenu(message.from, 'Title', 'subTitle', 'Description', 'menu', list)
  .then((result) => {
    console.log('Result: ', result); //return object success
  })
  .catch((erro) => {
    console.error('Error when sending: ', erro); //return object error
  });

}

}); } Result: { me: { id: { server: 'c.us', user: '5521966XXXXX', _serialized: '5521966XXXXXXX@c.us' }, displayName: null, verifiedName: null, searchName: null, pushname: null, notifyName: null, isBusiness: null, formattedUser: null, tag: '', stale: false, eurlStale: false, timestamp: 1690602853473 }, to: { fromMe: true, remote: { server: 'c.us', user: '5521975XXXXXX', _serialized: '5521975XXXXXX@c.us' }, id: 'NJAH1EJNXXXXXXXX', _serialized: 'true_55219XXXXXXX@c.us_NJAH1EXXXXXXXX' }, erro: false, text: null, status: 'OK' }`

talvez seu erro seja o que os demais também esta apresentando, tenta assim: troca "await client.sendListMenu" por "

`else if (message.body.toLowerCase() === 'b') {
 const list = [..]
            // envia a lista de menu
            client.sendListMenu(message.from, 'Teste', 'subTitle', 'Descricao', 'ListMenu', list)
                .then((result) => {
                    console.log('Resultado da Lista: ', result); //return object success
                })
                .catch((erro) => {
                    console.error('Error when sending: ', erro); //return object error
                });
        }`

basicamente se vc fizer isso, vai aparecer conforme anexo

Aqui pra mim continua dando o mesmo erro do amigo de erro text null

allanalcantara commented 3 months ago

Imagem do WhatsApp de 2023-09-11 à(s) 23 10 47

Tambem estou com o mesmo problema. Consigo enviar a lista retorna OK mas nao aparece na tela. No caso seria quando eu envio a Letra B

if (message.body.toLowerCase() === '/list') {
  ///envia uma lista sem simples.
} else if (message.body.toLowerCase() === 'b') {
  // Opções dos botões
  // Construindo a mensagem com botões
  const list = [
    {
      title: "Pasta",
      rows: [
        {
          title: "Ravioli Lasagna",
          description: "Made with layers of frozen cheese",
        }
      ]
    },
    {
      title: "Dessert",
      rows: [
        {
          title: "Baked Ricotta Cake",
          description: "Sweets pecan baklava rolls",
        },
        {
          title: "Lemon Meringue Pie",
          description: "Pastry filled with lemonand meringue.",
        }
      ]
    }
  ];

await client.sendListMenu(message.from, 'Title', 'subTitle', 'Description', 'menu', list)
  .then((result) => {
    console.log('Result: ', result); //return object success
  })
  .catch((erro) => {
    console.error('Error when sending: ', erro); //return object error
  });

}

}); } `Result: { me: { id: { server: 'c.us', user: '5521966XXXXX', _serialized: '[5521966XXXXXXX@c.us](mailto:5521966XXXXXXX@c.us)' }, displayName: null, verifiedName: null, searchName: null, pushname: null, notifyName: null, isBusiness: null, formattedUser: null, tag: '', stale: false, eurlStale: false, timestamp: 1690602853473 }, to: { fromMe: true, remote: { server: 'c.us', user: '5521975XXXXXX', _serialized: '[5521975XXXXXX@c.us](mailto:5521975XXXXXX@c.us)' }, id: 'NJAH1EJNXXXXXXXX', _serialized: '[true_55219XXXXXXX@c.us_NJAH1EXXXXXXXX](mailto:true_55219XXXXXXX@c.us_NJAH1EXXXXXXXX)' }, erro: false, text: null, status: 'OK' }

talvez seu erro seja o que os demais também esta apresentando, tenta assim: troca "await client.sendListMenu" por "

`else if (message.body.toLowerCase() === 'b') {
 const list = [..]
            // envia a lista de menu
            client.sendListMenu(message.from, 'Teste', 'subTitle', 'Descricao', 'ListMenu', list)
                .then((result) => {
                    console.log('Resultado da Lista: ', result); //return object success
                })
                .catch((erro) => {
                    console.error('Error when sending: ', erro); //return object error
                });
        }`

basicamente se vc fizer isso, vai aparecer conforme anexo

Aqui pra mim continua dando o mesmo erro do amigo de erro text null

posta o código de vocês que vou testar, mas pelo visto foi corrigido algumas coisas nas versões.

DesenvolvedoresLojasNossoLar commented 3 months ago

Were you able to resolve the error? I'm having the same problem with text: null

allanalcantara commented 3 months ago

Were you able to resolve the error? I'm having the same problem with text: null

traduz ai, acabei de vê que a atualização do sistema, "barrou" o processo do sendListMenu! Dessa forma somente com os administradores do projeto, pra corrigir, no antigo funciona.

DesenvolvedoresLojasNossoLar commented 3 months ago

Were you able to resolve the error? I'm having the same problem with text: null

traduz ai, acabei de vê que a atualização do sistema, "barrou" o processo do sendListMenu! Dessa forma somente com os administradores do projeto, pra corrigir, no antigo funciona.

qual seria a versão do antigo? no caso os botões também não funciona?