用于Java的Facebook Messenger bot对象结构 [英] Facebook Messenger bot object structure for java

查看:164
本文介绍了用于Java的Facebook Messenger bot对象结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人创建了一个开放源码项目,在java中暴露了facebook messenger bot API? (或另一种可以转换的语言)



基本上是一个堆栈中的对象层次结构:
https://developers.facebook.com/docs/messenger-platform/send-api-reference



我宁愿不仅仅使用JsonObjects等,还可以使用Maps来提取传入的JSON聊天消息或构建传出的结构化聊天回复。如果一个开源项目存在,我还没有找到。

解决方案

看看 FaceBot 。 FaceBot的目标是让Facebook的Messenger平台更轻松:使用FaceBot,您只需要少于5行代码来设置您自己的Messenger机器人。



这是一个例子:

  public class MyFaceBotBehavior extends AbstractFaceBot {

public void defineBehavior(){
/ /从Facebook设置我的令牌(页面令牌和webhook的验证令牌)。
FaceBotContext.getInstance()。setup(myFacebookPageToken,myFacebookWebhookValidationToken);

//定义一个将以Hello World!回覆的机器人一旦我写Hi
addActionFrame(new MessageEvent(Hi),
new MessageAutoReply(Hello World!));
}
}

如果您有任何问题或需要帮助,请随时联系我(我是开发人员)。


Has anyone created an open source project that exposes the facebook messenger bot API in java? (or another language I could convert?)

Essentially an object hierarchy for the stack found in: https://developers.facebook.com/docs/messenger-platform/send-api-reference

I'd rather not just use JsonObjects, etc. nor Maps to extract the incoming JSON chat messages or to build the outgoing structured chat replies. If an open source project for this exists -- I have not found it.

解决方案

Take a look at FaceBot. The goal of FaceBot is making the Facebook's Messenger Platform easier: with FaceBot, you only need less than 5 lines of code to set up your own Messenger bot.

Here's an example:

public class MyFaceBotBehavior extends AbstractFaceBot {

  public void defineBehavior() {
     // Setting my tokens from Facebook (page token and validation token for webhook).
     FaceBotContext.getInstance().setup("myFacebookPageToken", "myFacebookWebhookValidationToken");

     // Defining a bot which will reply with "Hello World!" as soon as I write "Hi"
     addActionFrame(new MessageEvent("Hi"),
          new MessageAutoReply("Hello World!"));
 }
}

If you have questions or need help, feel free to contact me (I'm the developer).

这篇关于用于Java的Facebook Messenger bot对象结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆