如何添加文本框,将值作为交互式用户菜单输入Slack chat bot?

2024-05-15 22:21:28 发布

您现在位置:Python中文网/ 问答频道 /正文

1)我想添加一个文本框,以便输入值,而不是选择“预定义” 下拉列表中的值

下面是用户交互消息图像的部分代码段,添加文本框以插入值的代码是什么

 web_client.chat_postMessage(
        channel=channel_id,
        text=f"```Hi <@{user}>!```\n" + mgs,
        thread_ts=thread_ts,
        attachments =   

{

                "text": "I can create the following orders.",
                "fallback": "If you could read this message, you'd be choosing something fun to do right now.",
                "color": "#3AA3E3",
                "attachment_type": "default",
                "callback_id": "game_selection",
                "actions": [
                    {
                        "name": "games_list",
                        "text": "Choose fullfilment",
                        "type": "select",
                        "options": [
                            {
                                "text": "a) spu - store pickup",
                                "value": "spu"
                            },
                            {
                                "text": "b) sth - ship to home",
                                "value": "sth"
                            },
                            {
                                "text": "c) del - delivery",
                                "value": "del"
                            },
                            {
                                "text": "d) digitalAsGuest - Digital item",
                                "value": "digitalAsGuest"
                            }
                        ]
                    }
                ]


}
        ]
}

下面是图片,我可以添加下拉菜单和按钮菜单,但我需要文本框字段

enter image description here

如何将以下文本字段代码集成到web\u客户端。聊天\u postMessage

{
    "type": "modal",
    "title": {
        "type": "plain_text",
        "text": "My App"    
    },
    "blocks": [
        {
            "type": "input",
            "element": {
                "type": "plain_text_input",
                "action_id": "sl_input",
                "placeholder": {
                    "type": "plain_text",
                    "text": "Please enter sku numberhere"
                }
            },
            "label": {
                "type": "plain_text",
                "text": "Sku number"
            },
            "hint": {
                "type": "plain_text",
                "text": "Example: 5580358"
            }
        }
    ]
}

enter image description here


Tags: to代码textyouwebidinputvalue