Typetalk Post Message
Posts a message to Typetalk.
Configs
  • A: Set topic id to post (e.g. 12345) *
  • B: Set OAuth2 Config Name (at [OAuth 2.0 Setting]) *
  • C: Select TEXT DATA for Post Message *
  • X: Select TEXT DATA for Log
Script (click to open)

//// == 注意 / Note ==
// Authorization Code Request URL: https://typetalk.in/oauth2/authorize
// Access Token Request URL: https://typetalk.in/oauth2/access_token
// Scope: chat:topic.post
// Client ID: ( from https://typetalk.com/my/develop/applications )
// Consumer Secret: ( from https://typetalk.com/my/develop/applications )

//// == 自動工程コンフィグの参照 / Config Retrieving ==
var topicId = configs.get("conf_TopicId") + "";
var myOAuthConfig = configs.get("conf_OAuth2") + "";

//// == ワークフローデータの参照 / Data Retrieving ==
var textForPost = engine.findDataByNumber( configs.get("conf_Message") ) + "";

//// == 演算 / Calculating ==
var token = httpClient.getOAuth2Token( myOAuthConfig );
var response = httpClient.begin()
  .bearer( token )
  .formParam( "message", textForPost )
  .post( "https://typetalk.com/api/v1/topics/" + topicId );

//// == ワークフローデータへの代入 / Data Updating ==
var dataNum_Log = configs.get("conf_Log") + "";
if (dataNum_Log !== "") {
  var log = "";
  log += "---POST request--- " + response.getStatusCode() + "\n";
  log += response.getResponseAsString() + "\n";
  engine.setDataByNumber( dataNum_Log, log);
}

Download

2021-04-16 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/addons/typetalk-messagepost/
The Addon-import feature is available with Professional or Enterprise edition.

Notes

Capture

%d bloggers like this: