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
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'
- set_buttons(buttons=None)[source]¶
Set the buttons of the card response.
Warning
This method is deprecated and will be removed. Assign value to the
buttons
attribute instead
- set_image(image_url=None)[source]¶
Set the URL of the card response’s image.
Warning
This method is deprecated and will be removed. Assign value to the
image_url
attribute instead
- set_subtitle(subtitle=None)[source]¶
Set the subtitle of the card response.
Warning
This method is deprecated and will be removed. Assign value to the
subtitle
attribute instead
- set_title(title=None)[source]¶
Set the title of the card response.
Warning
This method is deprecated and will be removed. Assign value to the
title
attribute instead
- 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')
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)
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
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']
- set_quick_replies(quick_replies=None)[source]¶
Set the texts for the quick reply buttons.
Warning
This method is deprecated and will be removed. Assign value to the
quick_replies
attribute instead.- Parameters
quick_replies (list, tuple(str), optional) – The texts for the quick reply buttons.
- Warns
DeprecationWarning – Assign value to the
quick_replies
attribute instead.- Return type
- set_title(title=None)[source]¶
Set the title of the quick reply buttons.
Warning
This method is deprecated and will be removed. Assign value to the
title
attribute instead.
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')
See also
For more information about the
Text
response, see the Text responses section in Dialogflow’s documentation.- set_text(text=None)[source]¶
Set the content of the text response.
Warning
This method is deprecated and will be removed. Assign value to the
text
attribute instead.