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

Support reply button in post message #36

Open
Tracked by #31
fabian4 opened this issue Apr 21, 2022 · 7 comments
Open
Tracked by #31

Support reply button in post message #36

fabian4 opened this issue Apr 21, 2022 · 7 comments

Comments

@fabian4
Copy link
Member

fabian4 commented Apr 21, 2022

No description provided.

@fabian4 fabian4 mentioned this issue Apr 21, 2022
9 tasks
@fabian4 fabian4 changed the title 卡片消息的回复按钮 Support reply button in post message Apr 21, 2022
@fabian4
Copy link
Member Author

fabian4 commented May 16, 2022

How to fit the struct of reply button data into the post as a kind of sayable ?

const suggestion = [
    {
      reply:{
        displayText:'aaa',
      },
    },
    {
      action:{
        displayText:'Open website or deep link',
        urlAction:{
          openUrl:{
            application:'webview',
            url:'https://xxx.com',
            viewMode:'half',
          },
        },
      },
    },
    {
      action:{
        dialerAction:{
          dialPhoneNumber:{
            phoneNumber:'+8617xxxxxxxxx0',
          },
        },
        displayText:'Call a phone number',
      },
    },
  ]
  • support 3 kinds of reply button for now
  • each one needs 2 or 3 input params

Should I create another sayable type to fit it or take other actions

@su-chang @huan

@huan
Copy link
Member

huan commented May 16, 2022

I think we need a new type of the Sayable: ‘ActionButton’

Could you please to do a research on the standard international RCS protocol, and reference the Action/Reply Button specifications and the data samples to here, so that we can have a better insight on it and design it in the right direction?

Thank you very much!

@fabian4
Copy link
Member Author

fabian4 commented May 17, 2022

There is only 3 kinds of buttons for now.

// reply text
{
  reply:{
    displayText:'aaa',
  },
}

// open link
{
  action:{
    displayText:'Open website or deep link',
    urlAction:{
      openUrl:{
        application:'webview',
        url:'https://xxx.com',
        viewMode:'half',
      },
    },
  },
}

// dial phone
{
  action:{
    dialerAction:{
      dialPhoneNumber:{
        phoneNumber:'+8617xxxxxxxxx0',
      },
    },
    displayText:'Call a phone number',
  },
}

@huan
Copy link
Member

huan commented May 17, 2022

Thanks for the data sample.

Could you please also research the standard international RCS protocol and reference the Action/Reply Button specifications links here?

More details will be needed to design our API because we want to make sure it will be generalized and following the international standard protocol specs.

@leochen-g
Copy link

目前和 @fabian4 沟通下来,发现suggestion 有共性的地方是三种快捷数据类型都需要 displayText postback属性:

1、关于displayText

每张卡片内建议操作和 建议回复按钮总数量不超过4个。位于悬浮菜单的建议操作和建议回复按钮总数量不超过11 个。每个建议操作和每个建议回复的展示文字(DisplayText)最多为25个字符(Byte)。

2、关于postback 暂时觉得应该是回调之类的,具体测试的时候,发现快捷回复返回的数据是把整个reply或者action直接原样返回的。所以对这个postback 还不是很明确具体功能是什么, @IronConrad 康嘉老师有时间可以帮解释一下

关于三种快捷回复类型所必须的参数:

1、纯文字型快捷回复(reply)
必填:displayText

{
    "reply": {
        "displayText": "快捷回复展示文字",
        "postback": {
            "data": "set_by_chatbot_reply_no"
        }
    }
},

2、url链接类型(action)

必填:displayTexturl

其余参数puppet可以使用默认值即可

{
    "action": {
        "urlAction": {
            "openUrl": {
                "url": "https://www.10010.cn",
                "application": "webview",
                "viewMode": "half"
            }
        },
        "displayText": "Open website or deep link",
        "postback": {
            "data": "set_by_chatbot_open_url"
        }
    }
}

3、弹框类型,拨打电话(action)

必填:displayTextphoneNumber

其余参数puppet可以使用默认值即可

{
    "action": {
        "dialerAction": {
            "dialPhoneNumber": {
                "phoneNumber": "+8617928222350"
            }
        },
        "displayText": "Call a phone number",
        "postback": {
            "data": "set_by_chatbot_open_dialer"
        }
    }
}

根据以上分析,其实可以归为两大类快捷回复,一个reply和一个actionaction可以细分两个类型linkdialer.

puppet需要根据建议回复消息的回复类型进行判断,如下图

image

关于以上提到的分析如果有误的话,欢迎提出,另外也希望我们能够尽快推进快捷回复的落地,因为这个场景实现的功能点是挺吸引开发者的

@leochen-g
Copy link

目前能想到可以实现的调用方式如下,在post基础上继续链式构造:

个人初步设想,并不是很完善

this.Post.builder()
          .add(msg.title)
          .add(msg.description)
          .add(FileBox.fromUrl(msg.thumbUrl))
           .reply('快捷一')
           .reply('快捷二')
           .action({type: 'link', text: '快捷三',url:'https://wechaty.js.org/'})
           .action({type: 'dialer', text: '快捷4', contact:'172*******082'})
          .type(0)
          .build()

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

3 participants