Send custom message in action


I would like to send a custom message like below with an action. The idea is that i send three pictures as buttons and the user can pick the most desirable. The custom message below works just fine in the domain file, but since I have multiple pictures and I need to combine them very flexible Iā€™d like to make a custom action which sends these kind of messages. I tried the code below, but it just returns the text and not the custom buttons.

How can I send a custom message like below with actions?

Domain Example

    - custom:
        - payload: 'code_1'
          title: 'Neigung 1'
          typus: 'image_button'
          image_id: '1'
        - payload: 'code_2'
          title: 'Neigung 2'
          typus: 'image_button'
          image_id: '2'
        - payload: 'code_3'
          title: 'Neigung 3'
          typus: 'image_button'
          image_id: '3'
      text: 'Weches der drei Bilder passt am besten zu dir?'

Custom Action

class ImageButton(Action):

def name(self):
    # define the name of the action which can then be included in training stories
    return "action_imagebutton"

def run(self, dispatcher, tracker, domain):
    dicti = {"image_id": "1","payload": "code_1","title": "Neigung 1","typus": "image_button"}

Hey @Michael check this:

Awesome, that did it for me

1 Like