Beispiel #1
0
    def make_start(sender):
        # Mensaje
        responses = list()
        message = Message(text="Ya no mas filas en el banco")
        responses.append(Components.typing(responses, sender))
        responses.append(MessageRequest(sender, message))

        template = ListTemplate(
            style="compact",
            elements=[
                ListElement(
                    title="GENERAR UN TICKET",
                    image_url="https://s14.postimg.org/u9ohxgqsd/obtener.png",
                    subtitle="Ahorra tiempo con tickets electrónicos",
                    buttons=[
                        PostbackButton(title="OBTENER TICKET",
                                       payload="GET_TICKET")
                    ],
                ),
                ListElement(
                    title="MIS TICKETS",
                    image_url=
                    "https://s14.postimg.org/ea5udwuql/mistickets.png",
                    subtitle="Administra los tickets pendientes que tienes",
                    buttons=[
                        PostbackButton(title="VER MIS TICKETS",
                                       payload="MY_TICKETS")
                    ],
                )
            ])
        attachment = TemplateAttachment(template=template)
        message = Message(attachment=attachment)
        responses.append(Components.typing(responses, sender))
        responses.append(MessageRequest(sender, message))
        return responses
Beispiel #2
0
    def make_schedules(sender):
        # Mensaje
        responses = list()
        message = Message(
            text=
            "¿Deseas agendar una cita con un asesor?, (y) Estas son las fechas disponibles"
        )
        responses.append(Components.typing(responses, sender))
        responses.append(MessageRequest(sender, message))

        template = ListTemplate(
            style="compact",
            elements=[
                ListElement(
                    title="21 de Diciembre del 2016",
                    image_url="https://s14.postimg.org/hn996fblp/date.jpg",
                    subtitle="15:00 Hrs",
                    buttons=[
                        PostbackButton(title="AGENDAR", payload="AGENDA_1")
                    ],
                ),
                ListElement(
                    title="15 de Enero del 2017",
                    image_url="https://s14.postimg.org/hn996fblp/date.jpg",
                    subtitle="19:00 Hrs.",
                    buttons=[
                        PostbackButton(title="AGENDAR", payload="AGENDA_2")
                    ],
                )
            ])
        attachment = TemplateAttachment(template=template)
        message = Message(attachment=attachment)
        responses.append(Components.typing(responses, sender))
        responses.append(MessageRequest(sender, message))
        return responses
Beispiel #3
0
    def make_own_tickets(sender):
        # tickets = Ticket.objects.all()
        tickets = list()
        responses = list()
        elements = []
        if tickets.count() > 0:
            # Mensaje
            message = Message(text="Estos son tus tickets", )
            responses.append(Components.typing(responses, sender))
            responses.append(MessageRequest(sender, message))

            # Componente
            for ticket in tickets:
                lat, lng = Components.get_position(ticket.branch)
                if ticket.type == "CASH":
                    tty = "CAJA"
                else:
                    tty = "PLATAFORMA"

                element = Element(
                    title="%s: %s" % (tty, ticket.code),
                    subtitle="%s: %s" % (ticket.branch.bank.name, ticket.branch.name),
                    default_action=URLButton(
                        url=Components.get_map_url(lat, lng)
                    ),
                    buttons=[
                        PostbackButton(
                            title="CANCELAR",
                            payload="%(payload)s:%(id)s" % {
                                "payload": "CANCEL_TICKET",
                                "id": ticket.id
                            }
                        ),
                        PostbackButton(
                            title="RENOVAR",
                            payload="%(payload)s:%(id)s" % {
                                "payload": "REGENERATE_TICKET",
                                "id": ticket.id
                            }
                        )
                    ]
                )
                elements.append(element)
            template = GenericTemplate(
                elements=elements
            )

            attachment = TemplateAttachment(template=template)
            component = Message(attachment=attachment)
            responses.append(Components.typing(responses, sender))
            responses.append(MessageRequest(sender, component))

        else:
            message = Message(text="No tienes tickets")
            responses.append(Components.typing(responses, sender))
            responses.append(MessageRequest(sender, message))
        return responses
Beispiel #4
0
def get_start_button():
    return StartButton(
        call_to_actions=[
            PostbackButton(
                title="EMPEZAR",
                payload="EMPEZANDO"
            )
        ]
    )
Beispiel #5
0
    def make_atms(sender):
        """
        Envia la lista de Suscripciones de un usuario o la peticion para registrar una suscripción
        """
        branches = None
        responses = list()
        elements = []
        if branches.count() > 0:
            # Mensaje
            message = Message(text="Esta es la lista de Cajeros cerca :)", )
            responses.append(Components.typing(responses, sender))
            responses.append(MessageRequest(sender, message))

            # Componente
            for branch in branches:
                lat, lng = Components.get_position(branch)
                element = Element(
                    title=branch.name,
                    item_url=Components.get_map_url(lat, lng),
                    image_url=Components.get_map_screen(lat, lng),
                    subtitle=branch.address,
                    buttons=[
                        PostbackButton(
                            title="VER",
                            payload="%(payload)s:%(id)s" % {
                                "payload": "SELECT_BRANCH",
                                "id": branch.id
                            }
                        )
                    ]
                )
                elements.append(element)
            template = GenericTemplate(
                elements=elements
            )

            attachment = TemplateAttachment(template=template)
            component = Message(attachment=attachment)
            responses.append(Components.typing(responses, sender))
            responses.append(MessageRequest(sender, component))

        else:
            message = Message(text="No hay cajeros registrados :(")
            responses.append(Components.typing(responses, sender))
            responses.append(MessageRequest(sender, message))
        return responses
Beispiel #6
0
def get_button_template(sender):

    template = ButtonTemplate(
        text='Que quieres hacer?',
        buttons=[
            URLButton(
                title='Show website',
                url='https://oepbolivia.xyz/'
            ),
            PostbackButton(
                title='Start chatting',
                payload='USER_DEFINED_PAYLOAD'
            )
        ]
    )
    attachment = TemplateAttachment(template=template)
    message = Message(attachment=attachment)
    return MessageRequest(sender, message)
Beispiel #7
0
def get_generic_template(sender):
    template = GenericTemplate(
        elements=[
            Element(
                title="Welcome to Peter\'s Hats",
                item_url="https://oepbolivia.xyz/",
                image_url="https://upload.wikimedia.org/wikipedia/en/5/5e/Avatar(Neytiri).jpg",
                subtitle="Weve got the right hat for everyone.",
                buttons=[
                    URLButton(
                        url="https://oepbolivia.xyz/",
                        title="View Website"
                    ),
                    PostbackButton(
                        title="Start Chatting",
                        payload="PAYLOAD"
                    )
                ]
            ),
            Element(
                title="HOLA MUNDO",
                item_url="https://oepbolivia.xyz/",
                image_url="https://goo.gl/wODF4W",
                subtitle="Weve got the right hat for everyone.",
                buttons=[
                    URLButton(
                        url="https://oepbolivia.xyz/",
                        title="View Website"
                    ),
                ]
            ),
            Element(
                title="TERCERA PARTE",
                item_url="https://oepbolivia.xyz/",
                image_url="https://goo.gl/wODF4W",
                subtitle="Weve got the right hat for everyone.",
            )

        ]
    )

    attachment = TemplateAttachment(template=template)
    message = Message(attachment=attachment)
    return MessageRequest(sender, message)
Beispiel #8
0
def get_list_template(sender):
    template = ListTemplate(
        style="large",
        elements=[
            ListElement(
                title="Classic T-Shirt Collection",
                image_url="https://goo.gl/tqQNHV",
                subtitle="See all our colors",
                default_action=URLButton(
                    url="https://peterssendreceiveapp.ngrok.io/shop_collection",
                    webview_height_ratio=URLButton.RATIO_TALL,
                ),
                buttons=[
                    URLButton(
                        title="View",
                        url="https://peterssendreceiveapp.ngrok.io/collection",
                        webview_height_ratio=URLButton.RATIO_TALL
                    )
                ],
            ),
            ListElement(
                title="Classic T-Shirt Collection",
                image_url="https://goo.gl/JYkzoW",
                subtitle="100% Cotton, 200% Comfortable",
                default_action=URLButton(
                    url="https://peterssendreceiveapp.ngrok.io/view?item=100",
                    webview_height_ratio=URLButton.RATIO_TALL
                ),
                buttons=[
                    URLButton(
                        title="Shop Now",
                        url="https://peterssendreceiveapp.ngrok.io/shop?item=100",
                        webview_height_ratio=URLButton.RATIO_TALL
                    )
                ],
            ),
            ListElement(
                title="Classic Blue T-Shirt",
                image_url="https://goo.gl/tqQNHV",
                subtitle="100% Cotton, 200% Comfortable",
                default_action=URLButton(
                    url="https://peterssendreceiveapp.ngrok.io/view?item=101",
                    webview_height_ratio=URLButton.RATIO_TALL
                ),
                buttons=[
                    URLButton(
                        title="Shop Now",
                        url="https://peterssendreceiveapp.ngrok.io/collection",
                        webview_height_ratio=URLButton.RATIO_TALL
                    )
                ],
            ),
            ListElement(
                title="Classic Black T-Shirt",
                image_url="https://goo.gl/W2J5rE",
                subtitle="See all our colors",
                default_action=URLButton(
                    url="https://peterssendreceiveapp.ngrok.io/view?item=102",
                    webview_height_ratio=URLButton.RATIO_TALL
                ),
                buttons=[
                    URLButton(
                        title="Shop Now",
                        url="https://peterssendreceiveapp.ngrok.io/collection",
                        webview_height_ratio=URLButton.RATIO_TALL
                    )
                ],
            ),
        ],
        buttons=[
            PostbackButton(
                title="Ver mas",
                payload="UNDEFINED_PAYLOAD"
            )
        ]
    )
    attachment = TemplateAttachment(template=template)
    message = Message(attachment=attachment)
    return MessageRequest(sender, message)