2017-02-19 36 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()方法。

相關問題