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).
Property | Description | |
---|---|---|
text | the text to output | Required |
suggestions | a list of suggested responses | |
mode | either quick_reply or buttons | Optional Default: quick_reply |
passthru | automatically advance without waiting on user | Optional Default: false |
block | treat 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 |
output | the key used to store the data for subsequent steps in the flow | Optional Default: value |
scope | where 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")
meya.text_buttons
Similar to meya.text_suggestions. Uses buttons instead of suggestions.
Property | Description | |
---|---|---|
text | the text to output | Required (Messenger limit - 640 characters) |
buttons | an array of Buttons | |
mode | either quick_reply or buttons | Optional Default: buttons |
passthru | automatically advance without waiting on user | Optional Default: false |
block | treat 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 |
output | the key used to store the data for subsequent steps in the flow | Optional Default: value |
scope | where 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
Updated over 6 years ago