Storing “Session Variables” in Facebook Messenger

余生长醉 提交于 2019-12-12 02:16:03

问题


I want to save information about a user (ex postal code, location...) for the duration of the 'session', how could I go about this? From my understanding each time a message is sent, the webhook is hit again, so variables aren't saved on the webhook side. Furthermore, meta data is only available sending from bot to client. I'm looking for a way for the client to influence the flow without the use of a database.

Is this possible given the current iteration of the facebook messenger platform?


回答1:


There is no way to store variables in messenger.

If you really want to avoid persistence in your webhook code, you could use postabck buttons. The payload text limit is 1000 characters, which you could use to encode some limited data.

See https://developers.facebook.com/docs/messenger-platform/send-api-reference/postback-button

Personally I'm using firebase to handle this type of session storage and it's working well



来源:https://stackoverflow.com/questions/39980855/storing-session-variables-in-facebook-messenger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!