小编wil*_*ers的帖子

如何让我的 slackbot 在线程中回复,而不是使用 Google App 脚本回复整个频道

我尝试让 slackbot 通过回复消息中的某些关键词来提供技术支持。然而,它的响应使其所在的频道变得混乱。因此,我希望我的 Slackbot 在原始消息下的线程中进行回复,就像我自己回答问题时所做的那样。

从 Slack 文档中,我知道应该可以回复线程中的消息。我应该以某种方式使用thread_ts,但我无法让它工作。


var POST_MESSAGE_ENDPOINT = 'https://slack.com/api/chat.postMessage';
var TEXTS = [
  'Hi there! Maybe I can help you?',
];

  //Reply to  within a thread: 
  //data '{"channel":"CHANNEL-ID", "text":"curl", "thread_ts":"THREAD-TS"}'

function doPost(e){
  var event = JSON.parse(e.postData.contents).event;

  if(event.hasOwnProperty('bot_id')){
    return;
  }else if(event.text.match(/(log.?in)|(inlog)|(logging?)/)){
    postLogin(event, ['login']);
  }else if(event.text.match(/(syncing)|(sync)|(sync$$)/)){
    postSyncing(event, ['syncing']);
  }else if(event.text.match(/(issues?)|(problem)/)){
    postIssueOptions(event, ['issue']);
  }
}

function postLogin(event, keywords){
  var url1 = "<https://docs.google.com/document/d/1rcaGjyAMFpo9tG9YAgTpTFlxPZq5luwBlM3gMVCL9eI/edit|Runner can not login after changing password>";
  var url2 = "<https://docs.google.com/document/d/1rcaGjyAMFpo9tG9YAgTpTFlxPZq5luwBlM3gMVCL9eI/edit|Runner forgot password>";
  var url3 = "<https://docs.google.com/document/d/1rcaGjyAMFpo9tG9YAgTpTFlxPZq5luwBlM3gMVCL9eI/edit|Other …
Run Code Online (Sandbox Code Playgroud)

javascript google-apps-script slack-api

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

google-apps-script ×1

javascript ×1

slack-api ×1