Co je facebook chatu bot užitečná pole?

hlasů
0

Může mi někdo vysvětlit, co je ‚náklad‘ pole facebook Chatbot tlačítko prvku? Jsem nový vývoj bot. By skvělé, kdyby vám může poskytnout příklad taky.

Položena 12/10/2016 v 07:44
zdroj uživatelem
V jiných jazycích...                            


1 odpovědí

hlasů
1

pole ‚užitečné zatížení‘ je uživatelem definované pole, které vám umožní volat opatření, kdykoli je přijat postback s tímto užitečným zatížením.

například; kdybych vytvoření stálé nabídky v mém bot, který obsahuje 2 tlačítka: ‚Domů‘ a ‚Kontakt‘ a užitečného zatížení pro každou z nich je stejný jako název tlačítka. Když uživatel klikne na tlačítko ‚domácí‘, postback poslána s užitečným zatížením ‚Home‘. V tomto případě můžete vytvořit akci, která navede uživatele na část ‚domácí‘ z bot.

Pro více informací o postbacks a užitečné zatížení, najdete na adrese: https://developers.facebook.com/docs/messenger-platform/send-api-reference/postback-button https://developers.facebook.com/docs/messenger-platform / webhook-reference / postback-přijatý

ujistěte se, že vytvoření funkce v hlavním ‚po‘ funkci, která zpracovává postback. Níže uvedený kód je od bot tutorial v Pythonu

# Post function to handle facebook messages
def post(self, request, *args, **kwargs):
    # converts the text payload into a python dictionary
    incoming_message = json.loads(self.request.body.decode('utf-8'))
    # facebook recommends going through every entry since they might send
    # multiple messages in a single call during high load
    for entry in incoming_message['entry']:
        for message in entry['messaging']:
            # check to make sure the received call is a message call
            # this might be delivery, optin, postback for other events

            if 'message' in message:
                pprint(message)
                ### add here the rest of the code that will be handled when the bot receives a message ###

            if 'postback' in message:
                # print the message in terminal
                pprint(message)
                ### add here the rest of the code that will be handled when the bot receives a postback ###
Odpovězeno 20/10/2016 v 13:59
zdroj uživatelem

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more