Buttons in Microsoft Bot Framework vs REST channels

Hi,

As far as I know, the correct format for buttons is

{
  "title": "I don't recognise it.",
  "payload": "/affirm"
}

However, these buttons don’t show up at all when enabling the botframework channel and testing the bot in Microsoft’s Bot Framework Emulator. For that I have to change the format to

{
    "type": "messageBack",
    "title": "I don't recognise it.",
    "displayText": "Optional user message to be shown when clicked",
    "text": "/affirm",
}

But now the buttons don’t work anymore in the REST channel (I am using GitHub - scalableminds/chatroom: React-based Chatroom Component for Rasa Stack as front end.)

I can use a combination of fields so that the buttons work in both channels:

{
    "type": "messageBack",
    "title": "I don't recognise it.",
    "displayText": "Optional user message to be shown when clicked",
    "text": "/affirm",
    "payload": "/affirm",
}

But this of course only works because both clients ignore unknown fields.

What is the recommended practice for buttons across channels? Do I have to write my button code specifically for the channel I am planning to use?

1 Like

Hello!

In domain.yml, you can set Channel-Specific Response Variations.

Read more: Conditional Response Variations: Technical Blog

Thanks Chris, much appreciated.

I suppose for custom actions I look at tracker.get_latest_input_channel() and then produce a custom object?

Supporting more than one channel leads to quite a bit of duplication in domain.yml, for example:

responses:
  utter_spoken_to_retailer:
  - text: Have you already been to the retailer to request a refund?
    quick_replies:
      - title: Yes
        payload: /affirm
      - title: No
        payload: /deny
  - channel: botframework
    text: Have you already been to the retailer to request a refund?
    quick_replies:
      - title: Yes
        type: messageBack
        text: /affirm
      - title: No
        type: messageBack
        text: /deny

Any recommendations how to simplify that? We could add some pre-processing to domain.yml but I’d rather not complicate matters unnecessarily.

Related: Looking at the naming of the get_latest_input_channel() method I wonder if it is possible to have cross-channel conversations? And if so, will buttons rendered to display in one channel not display when continuing the conversation on another channel?

Thanks

1 Like

Yup!

To be honest I don’t know if there’s a better way to write that in the domain.

What I’d do if the utterances were very prone to changes is converting them all to Custom Actions. This way I’d only change the variables parts inside a switch statement on tracker.get_latest_input_channel().

Again, not sure if that’s the best way :slight_smile:

I think yes! sender ID will have to be the same in the different channels.

In your case, the default channel (REST) and Bot Framework are not compatible, so no, you cannot display the same buttons on both, unless your original idea works.

But if you build your own applications, let’s say a web and a mobile app, you can set yourself which fields they understand and thus buttons will display on both using the same format.