Text cards

meya.text_suggestions

Outputs text and suggested responses. Renders on each integration differently, depending on the specifications of the integration (e.g. on Messenger suggestions are buttons, on Kik they are keyboard suggested responses).

PropertyDescription
textthe text to outputRequired
suggestionsa list of suggested responses
modeeither quick_reply or buttonsOptional Default: quick_reply
passthruautomatically advance without waiting on userOptional Default: false
blocktreat any non-button press as a user input. This will trigger the no_match action, so you must implement the transition as you would with an input.Optional Default: false
outputthe key used to store the data for subsequent steps in the flowOptional Default: value
scopewhere to store the data. One of flow, user, bot.Optional Default: flow

Example of text with suggestions used in flow and a custom component.

📘

Handling non-button presses

If you want your bot to listen for any input other than buttons, see this example.

component: meya.text_suggestions
properties:
  text: What is your favorite elelphant?
  mode: quick_reply
  suggestions:
    - African Elephant
    - Asian Elephant
    - Woolly Mammoth
from meya.cards import TextWithButtons, Button

text = 'What is your favorite elelphant?'
buttons = [
  Button(text='African Elephant'),
  Button(text='Asian Elephant'),
  Button(text='Woolly Mammoth')
]
card = TextWithButtons(text=text, buttons=buttons, mode="quick_reply")
744

meya.text_buttons

Similar to meya.text_suggestions. Uses buttons instead of suggestions.

PropertyDescription
textthe text to outputRequired (Messenger limit - 640 characters)
buttonsan array of Buttons
modeeither quick_reply or buttonsOptional Default: buttons
passthruautomatically advance without waiting on userOptional Default: false
blocktreat any non-button press as a user input. This will trigger the no_match action, so you must implement the transition as you would with an input.Optional Default: false
outputthe key used to store the data for subsequent steps in the flowOptional Default: value
scopewhere to store the data. One of flow, user, bot.Optional Default: flow

Example of text_buttons used in a flow - YAML + Python

component: meya.text_buttons
properties:
  text: What is your favorite elelphant?
  mode: buttons
  buttons:
    - text: African Elephant
      action: next
    - text: Asian Elephant
      action: next
    - text: Woolly Mammoth
      action: extinct
from meya.cards import TextWithButtons, Button

text = 'What is your favorite elelphant?'
buttons = [
  Button(text='African Elephant', action="next"),
  Button(text='Asian Elephant', action="next"),
  Button(text='Woolly Mammoth', action="extinct")
]
card = TextWithButtons(text=text, buttons=buttons, mode="buttons")
message = self.create_message(card=card)

Example text_buttons with transitions

states:
    text_buttons_state:
        component: meya.text_buttons
        properties:
            text: Pick your favorite football player
            output: player
            buttons:
                - text: Lionel Messi
                  action: messi
                - text: Cristiano Ronaldo
                  action: ronaldo
        transitions:
            messi: messi_state
            ronaldo: ronaldo_state
    messi_state:
        component: meya.image
        properties:
            image_url: 'https://upload.wikimedia.org/wikipedia/commons/f/f2/Lionel_Messi.png'
        return: true
    ronaldo_state:
        component: meya.image
        properties:
            image_url: 'https://upload.wikimedia.org/wikipedia/commons/d/d5/Cristiano_Ronaldo_20120609.jpg'
        return: true