https://discord.gg/botpress logo
The "description" field should not be required by ...
# 🤝help
b
I'm using the Botpress team's WhatsApp integration. I made an interactive list with options that have both title and description and some options that don't have description, only title. When one tries to select an option without description, the Zod schema validator crashes, since it considers the "description" field required. The "description" field should not be required, since WhatsApp itself didn't make it required. Also, the display of the option changes slightly when providing a description, even if you provide a whitespace-only description like " ". The option title gets positioned slightly above the usual place, which seems strange and unaligned without a description. https://cdn.discordapp.com/attachments/1408191434456305737/1408191435039309875/image.png?ex=68a8d7f9&is=68a78679&hm=4c01ca57a0216e5461ccd1cd776907008e525ac083f4229c56bf9d283b90de6e&
@bumpy-butcher-41910 @acceptable-gold-88171
l
Copy code
const data = {
  purpose: 'sendmessage',
  message_data: {
    messaging_product: 'whatsapp',
    recipient_type: 'individual',
    to: user.phoneNumber,
    type: 'interactive',
    interactive: {
      type: 'list',
      header: {
        type: 'text',
        text: 'The K Story'
      },
      body: {
        text: 'Select an option to begin'
      },
      action: {
        button: 'The K Story Menu',
        sections: [
          {
            title: 'Restaurant Options',
            rows: [
              {
                id: 'the_k_tiffin',
                title: 'The K Tiffin',
                description: 'Subscription based home-style meals delivered to you'
              },
              {
                id: 'the_k_curry',
                title: 'The K Restaurant',
                description: 'Awesome food, great taste'
              },
              {
                id: 'the_k_catering',
                title: 'The K Catering',
                description: 'Home catering service for birthdays kitty party'
              }
            ]
          },
          {
            title: 'Other Actions',
            rows: [
              {
                id: 'profile',
                title: 'My Profile',
                description: 'View & Update Profile'
              },
              {
                id: 'faq',
                title: 'Customer Support',
                description: 'Chat with K Tiffin'
              },
              {
                id: 'exit',
                title: 'Exit',
                description: 'Exit the Menu'
              }
            ]
          }
        ]
      }
    }
  }
}
that is a interactive message in zod schema use .optional() to make description optional
b
Yes, we can use .optional() in zod to make a field optional. Nevertheless, I wouldn't be able to change it since the schema in question is controlled by the Botpress team, as far as I know. Is it not?
@limited-pencil-78283 @colossal-scientist-24455 @rapid-forest-80249 Do you have any thoughts on this? Is this really an unsolved bug?
c
You're right, .optional() in Zod would make the field optional, but since the schema is defined by the Botpress team, you can't modify it yourself. This isn't really a bug - it's just that the SDK enforces strict schema validation. if you think the field should be optional, the best way is to open an issue or feature requrest on the Botpress GitHub so the team can update the schema.
l
description: ' ' should work as well?
b
Thank you for the clarification. I didn't think of creating an issue on the Botpress repo, nice pointer!
I tried it, but I think WhatsApp ignores the field since it's an empty string. It only works when there's at least a character
c
It's my pleasure
5 Views