Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save erika-dike/0205fb7dccb810d088afe4d52813fac9 to your computer and use it in GitHub Desktop.
Save erika-dike/0205fb7dccb810d088afe4d52813fac9 to your computer and use it in GitHub Desktop.
Constructs list template from supplied elements and buttons
def create_list_template(recipient_id, elements, buttons):
"""
Returns a list template for detail view
recipient_id: integer
elements: list of elements to be injected into template
buttons: list of buttons to be injected into template
"""
template = copy.deepcopy(message_templates.LIST_TEMPLATE)
template['recipient']['id'] = recipient_id
payload_section = template['message']['attachment']['payload']
payload_section['template_type'] = 'list'
payload_section['top_element_style'] = 'compact'
template['message']['attachment']['payload']['elements'] = elements
template['message']['attachment']['payload']['buttons'] = buttons
return template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment