Was ist Facebook Chat-Bot Nutzfeld?

stimmen
0

Kann mir jemand erklären, was die ‚Nutzlast‘ Feld ist in Element facebook chatbot Taste? Ich bin neu in Bot Entwicklung. Wäre toll, wenn Sie ein Beispiel liefern.

Veröffentlicht am 12/10/2016 um 07:44
quelle vom benutzer
In anderen Sprachen...                            


1 antworten

stimmen
1

die ‚Nutzlast‘ Feld ist ein benutzerdefiniertes Feld, das Ihnen ermöglicht, eine Aktion aufzurufen, wenn ein Postback mit dieser Nutzlast empfangen wird.

beispielsweise; wenn ich ein persistentes Menü in meinem Bot erstellen, die zwei Schaltflächen enthalten: ‚Home‘ und ‚Kontakt‘, und die Nutzlast für jeden von ihnen ist die gleiche wie der Name der Schaltfläche. Wenn ein Benutzer klickt auf die Schaltfläche ‚Start‘ wird ein Postbacks mit der Nutzlast ‚Home‘ gesendet. In diesem Fall können Sie eine Aktion erstellen, die den Benutzer auf den ‚Home‘ Teil des Bot nimmt.

gehen für mehr über Postbacks und Nutzlast, zu: https://developers.facebook.com/docs/messenger-platform/send-api-reference/postback-button https://developers.facebook.com/docs/messenger-platform / Webhook-Referenz / Postback-empfangenen

stellen Sie sicher, eine Funktion in der Haupt ‚post‘ Funktion zu erstellen, die die Postbacks behandelt. Der folgende Code ist von einem Bot Tutorial in Python

# 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 ###
Beantwortet am 20/10/2016 um 13:59
quelle vom benutzer

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