Facebook messenger API bot : “Typing bubble” “ indicator bubble”

给你一囗甜甜゛ 提交于 2019-12-18 19:06:29

问题


I've created a messenger bot, and some action that I perform can take some time. So in order to make the user wait I would like to display the "Indicator Bubble" (the one you see when the people you talk with are typing):

Typing bubble

It is not defined in the Messenger API documentation how to do it, but it seems possible has they perform it when you hit "callBack" on their card.

How can I simulate this?


回答1:


It's now available into the messenger bot API via the Sender Action. You can find the documentation here.

It's just a post with an on or off value to display / hide the bubble indicator.

{
    "recipient":{
          "id":"USER_ID"
    },
    "sender_action":"typing_on" // typing_off
}



回答2:


The official messenger API does not support this feature for now. Even if @hiponcho – one of the featured by Facebook chatbot is actually using it.

A workaround would be to use the unofficial messenger API, which has a method called sendTypingIndicator that does exactly what you want. But be careful, you can be banned for using of non-official API.

api.sendTypingIndicator(threadID, [callback])




回答3:


Yes, it is the only way.

When you have the Button Template and someone clicks on "button" for "postback" (documentation in section "button template").

Then during your parsing of the message and sending answer, it is shown like "writing".




回答4:


I know it is a hack, but currently I send the "Typing Bubble Indicator" as a animated gif as my first reply, if I anticipate a waiting time (like an API call). At the user end, you can't tell the difference.



来源:https://stackoverflow.com/questions/36887919/facebook-messenger-api-bot-typing-bubble-indicator-bubble

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