Example #1
0
    def init_bot(self):
        self.add_whitelisted_domains("https://facebook.com/")
        greeting = GreetingText(text="카트라이더 패치 내역에 관한 알림을 받으세요!")
        self.set_messenger_profile(greeting.to_dict())

        get_started = GetStartedButton(payload="start")
        res = self.set_messenger_profile(get_started.to_dict())
Example #2
0
    def init_bot(self):
        self.add_whitelisted_domains('https://facebook.com/')
        greeting = GreetingText(text='Welcome to the fbmessenger bot demo.')
        self.set_messenger_profile(greeting.to_dict())

        get_started = GetStartedButton(payload='start')
        self.set_messenger_profile(get_started.to_dict())

        menu_item_1 = PersistentMenuItem(
            item_type='postback',
            title='Help',
            payload='help',
        )
        menu_item_2 = PersistentMenuItem(
            item_type='web_url',
            title='Messenger Docs',
            url='https://developers.facebook.com/docs/messenger-platform',
        )
        persistent_menu = PersistentMenu(menu_items=[
            menu_item_1,
            menu_item_2
        ])

        res = self.set_messenger_profile(persistent_menu.to_dict())
        app.logger.debug('Response: {}'.format(res))
Example #3
0
 def init_bot(self):
 	greeting_text = GreetingText('Welcome to InstaTickets')
 	messenger_profile = MessengerProfile(greetings=[greeting_text])
 	messenger.set_messenger_profile(messenger_profile.to_dict())        
 	get_started = GetStartedButton(payload='start')
 	messenger_profile = MessengerProfile(get_started=get_started)
 	messenger.set_messenger_profile(messenger_profile.to_dict())
Example #4
0
    def init_bot(self):
        """Handles greeting procedure and persistent menu"""

        greet_txt = responses["greet"]
        greeting_text = GreetingText(greet_txt)
        get_started = GetStartedButton(payload='WELCOME')

        menu_item = PersistentMenuItem(item_type='postback',
                                       title='Restart recipe search',
                                       payload='RESTART')
        menu = PersistentMenu(menu_items=[menu_item])

        messenger_profile = MessengerProfile(persistent_menus=[menu],
                                             get_started=get_started,
                                             greetings=[greeting_text])
        res = self.set_messenger_profile(messenger_profile.to_dict())
        app.logger.info('Response: {}'.format(res))
Example #5
0
    def init_bot(self):
        self.add_whitelisted_domains('https://facebook.com/')

        #get started button
        get_started = GetStartedButton(payload='start')
        messenger_profile = MessengerProfile(get_started=get_started)
        res = self.set_messenger_profile(messenger_profile.to_dict())
        app.logger.debug('Response: {}'.format(res))

        #persistent menu entries

        menu_item_1 = PersistentMenuItem(
            item_type='postback',
            title='Get Started',
            payload='start'
        )

        menu_item_2 = PersistentMenuItem(
            item_type='postback',
            title='Help',
            payload='help',
        )

        menu_item_3 = PersistentMenuItem(
            item_type='postback',
            title='Example',
            payload='example',
        )
     
        
        # menu_item_4 = PersistentMenuItem(
        #     item_type='web_url',
        #     title='Messenger Docs',
        #     url='https://developers.facebook.com/docs/messenger-platform',
        # )

        persistent_menu = PersistentMenu(menu_items=[
            menu_item_1,
            menu_item_2,
            menu_item_3
        ])

        messenger_profile = MessengerProfile(persistent_menus=[persistent_menu])
        res = self.set_messenger_profile(messenger_profile.to_dict())
        app.logger.debug('Response: {}'.format(res))
Example #6
0
 def _convert_to_get_started(
         custom_json: Dict[Text, Any]) -> GetStartedButton:
     """Convert json custom message for get_started into a GetStrted object support 
             by fbmessenger api ."""
     return GetStartedButton(payload=custom_json['payload'])
Example #7
0
msngr = Messenger()
greeting_text = GreetingText(texts["greetings"])

schedule_order_now_menu_item = PersistentMenuItem(item_type="postback",
                                                  title="Schedule Order Now",
                                                  payload=State.SCHEDULE_ORDER)
login_item = PersistentMenuItem(item_type="postback",
                                title="Login",
                                payload=State.LOGIN)
register_item = PersistentMenuItem(item_type="postback",
                                   title="Register",
                                   payload=State.REGISTER)

menu = PersistentMenu(
    menu_items=[schedule_order_now_menu_item, login_item, register_item])

messenger_profile = MessengerProfile(
    persistent_menus=[menu],
    greetings=[greeting_text],
    get_started=GetStartedButton(payload=State.HI),
)
msngr.set_messenger_profile(messenger_profile.to_dict())

print("msngr profile set")


def handle_message(json_response):
    print(json_response)
    msngr.handle(json_response)