2017-02-19 100 views

回答

2

如果你只是在寻找一种方式,机器人只向用户呼吁机器人做出反应,那么你可以尝试利用松弛的ephemeral message type as documented here.

从文档:

默认情况下,发送到命令的响应消息仅对发出该命令的用户可见(我们称之为“短暂” 消息),可见为 。 ...将response_type设置为ephemeral与 完全不包括响应类型相同,只有发出该命令的用户才能看到响应消息 。

基本上,在群组通道中,短消息只发送给发出命令的用户,而不是广播给群组。

在你的机器人代码中,你只需要利用C#机器人构建器的custom channel message capability来改变传出消息的channelData字段。

例如:

{ 
    "type": "message", 
    "locale": "en-Us", 
    "channelId":"slack", 
    "conversation": { "id":"123123123123", "topic":"awesome chat" }, 
    "from": { "id":"12345", "name":"My Bot"}, 
    "recipient": { "id":"67890", "name":"Joe Doe"}, 
    "channelData": { 
     "response_type": "ephemeral", 
     "text": "This is some message.", 
     "attachments": [ 
      { 
       ... 
      } 
     ] 
    } 

} 

channelData遵循Slack Message formatting guidelines.

如果您正在寻找断裂成一个全新1的能力为你的机器人:1的对话与用户,maybe take a look at the documentation for Starting ConversationsCreateDirectConversation()方法。

相关问题