Rich responses#
Card#
- class Card(title=None, subtitle=None, image_url=None, buttons=None)[source]#
Bases:
dialogflow_fulfillment.rich_responses.base.RichResponse
Send a card response to the end-user.
Examples
Constructing a
Card
response:>>> card = Card( ... title='What is your favorite color?', ... subtitle='Choose a color', ... buttons=[{'text': 'Red'}, {'text': 'Green'}, {'text': 'Blue'}] ... )
- Parameters
- Return type
None
See also
For more information about the
Card
response, see the Card responses section in Dialogflow’s documentation.- property buttons: Optional[List[Dict[str, str]]]#
The buttons of the card response.
Examples
Accessing the
buttons
attribute:>>> card.buttons [{'text': 'Red'}, {'text': 'Green'}, {'text': 'Blue'}]
Assigning value to the
buttons
attribute:>>> card.buttons = [{'text': 'Cyan'}, {'text': 'Magenta'}] >>> card.buttons [{'text': 'Cyan'}, {'text': 'Magenta'}]
- property image_url: Optional[str]#
The URL of the card response’s image.
Examples
Accessing the
image_url
attribute:>>> card.image_url None
Assigning value to the
image_url
attribute:>>> card.image_url = 'https://picsum.photos/200/300.jpg' >>> card.image_url 'https://picsum.photos/200/300.jpg'
- property subtitle: Optional[str]#
The subtitle of the card response.
Examples
Accessing the
subtitle
attribute:>>> card.subtitle 'Choose a color'
Assigning value to the
subtitle
attribute:>>> card.subtitle = 'Select a color below' >>> card.subtitle 'Select a color below'
Image#
- class Image(image_url=None)[source]#
Bases:
dialogflow_fulfillment.rich_responses.base.RichResponse
Send an image response to the end-user.
Examples
Constructing an image response:
>>> image = Image('https://picsum.photos/200/300.jpg')
- Parameters
image_url (str, optional) – The URL of the image response.
- Return type
None
See also
For more information about the
Image
response, see the Image responses section in Dialogflow’s documentation.- property image_url: Optional[str]#
The URL of the image response.
Examples
Accessing the
image_url
attribute:>>> image.image_url 'https://picsum.photos/200/300.jpg'
Assigning a value to the
image_url
attribute:>>> image.image_url = 'https://picsum.photos/200/300?blur.jpg' >>> image.image_url 'https://picsum.photos/200/300?blur.jpg'
Payload#
- class Payload(payload=None)[source]#
Bases:
dialogflow_fulfillment.rich_responses.base.RichResponse
Send a custom payload response to the end-user.
This type of rich response allows to create advanced, custom, responses.
Examples
Constructing a custom
Payload
response for file attachments:>>> payload_data = { ... 'attachment': 'https://example.com/files/some_file.pdf', ... 'type': 'application/pdf' ... } >>> payload = Payload(payload_data)
- Parameters
payload (dict, optional) – The content of the custom payload response.
- Return type
None
See also
For more information about the
Payload
response, see the Custom payload responses section in Dialogflow’s documentation.- property payload: Optional[Dict[Any, Any]]#
The content of the custom payload response.
Examples
Accessing the
payload
attribute:>>> payload.payload {'attachment': 'https://example.com/files/some_file.pdf', 'type': 'application/pdf'}
Assigning a value to the
payload
attribute:>>> payload.payload = { ... 'attachment': 'https://example.com/files/another_file.zip', ... 'type': 'application/zip' ... } >>> payload.payload {'attachment': 'https://example.com/files/another_file.zip', 'type': 'application/zip'}
Quick Replies#
- class QuickReplies(title=None, quick_replies=None)[source]#
Bases:
dialogflow_fulfillment.rich_responses.base.RichResponse
Send a collection of quick replies to the end-user.
When a quick reply button is clicked, the corresponding reply text is sent back to Dialogflow as if the user had typed it.
Examples
Constructing a
QuickReplies
response:>>> quick_replies = QuickReplies('Choose an answer', ['Yes', 'No'])
- Parameters
- Return type
None
See also
For more information about the
QuickReplies
response, see the Quick reply responses section in Dialogflow’s documentation.- property quick_replies: Optional[Union[List[str], Tuple[str]]]#
The texts for the quick reply buttons.
Examples
Accessing the
quick_replies
attribute:>>> quick_replies.quick_replies ['Yes', 'No']
Assigning a value to the
quick_replies
attribute:>>> quick_replies.quick_replies = ['Yes', 'No', 'Maybe'] >>> quick_replies.quick_replies ['Yes', 'No', 'Maybe']
Rich Response#
- class RichResponse[source]#
Bases:
object
The base (abstract) class for the different types of rich responses.
See also
For more information about the
RichResponse
, see the Rich response messages section in Dialogflow’s documentation.
Text#
- class Text(text=None)[source]#
Bases:
dialogflow_fulfillment.rich_responses.base.RichResponse
Send a basic (static) text response to the end-user.
Examples
Constructing a
Text
response:>>> text = Text('this is a text response')
- Parameters
text (str, optional) – The content of the text response.
- Return type
None
See also
For more information about the
Text
response, see the Text responses section in Dialogflow’s documentation.