简体   繁体   English

与机器人进行环聊聊天不会将消息发布到发布/订阅

[英]Hangout chat to a bot doesn't post the message to pub/sub

I followed the steps in https://developers.google.com/hangouts/chat/how-tos/bots-publish 我遵循了https://developers.google.com/hangouts/chat/how-tos/bots-publish中的步骤

If I post to a topic through google console it received in java code for subscriber https://console.cloud.google.com/cloudpubsub/topics/ 如果我通过Google控制台发布到某个主题,则会以Java代码收到订阅者https://console.cloud.google.com/cloudpubsub/topics/

But chatting with the bot doesn't post the message to Pub/Sub 但是与漫游器聊天不会将消息发布到发布/订阅

Help me around 帮帮我

Here are some common things that can go wrong if you aren't able to get your chat bot to send messages to Cloud Pub/Sub: 如果您无法让聊天机器人将消息发送到Cloud Pub / Sub,以下是一些常见的错误:

  1. Ensure that the serviceAccount:chat-api-push@system.gserviceaccount.com account has publisher permission on the topic. 确保serviceAccount:chat-api-push@system.gserviceaccount.com帐户对该主题具有发布者权限。 You can do this by going to the Cloud Pub/Sub dashboard in the cloud console , clicking on the check box next to the topic to which you wish to publish, typing serviceAccount:chat-api-push@system.gserviceaccount.com into the box under "Add members" on the right, selecting the "Pub/Sub Publisher permission," and clicking on the "Add" button. 为此,您可以转到云控制台中Cloud Pub / Sub仪表板 ,单击要发布的主题旁边的复选框,然后在其中键入serviceAccount:chat-api-push@system.gserviceaccount.com右侧“添加成员”下的框,选择“发布/订阅发布者权限”,然后单击“添加”按钮。 If you do not see this panel on the side, you may need to click on "Show Info Panel" in the upper righthand corner. 如果您没有在侧面看到此面板,则可能需要单击右上角的“显示信息面板”。 Here is a screenshot of the page with the relevant pieces highlighted: 这是该页面的屏幕截图,其中突出显示了相关内容:

Cloud Pub / Sub控制台页面

  1. When proving the name of the topic in the bot configuration page, make sure you specify the full path, including the project name. 在bot配置页面上证明主题名称时,请确保指定完整路径,包括项目名称。 The topic name should be of the form projects/<project name>/topics/<topicname> . 主题名称的格式应为projects/<project name>/topics/<topicname>

  2. Make sure the subscription exists before you attempt to chat with your bot. 在尝试与漫游器聊天之前,请确保订阅存在。 Messages published before a subscription is created will not be delivered to that subscription. 在创建订阅之前发布的消息将不会传递到该订阅。

If you've gotten this far and things are still not working, try sending messages to your bot and then pulling them via the gcloud command line tool with the command 如果您到此为止,但仍然无法正常工作,请尝试将消息发送到您的机器人,然后使用gcloud命令行工具通过以下命令将其提取

 gcloud pubsub subscriptions pull <subscription name> --project <project name>

You should see a table output with the messages received. 您应该看到包含收到的消息的表输出。 If you can get this output, then messages are flowing correctly from the bot to the Cloud Pub/Sub topic and then to the subscription on that topic. 如果可以获得此输出,则消息从bot正确流到Cloud Pub / Sub主题,再到该主题的订阅。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM