LANG SELRCT

Apps Script Reference  (Create: Create new Spreadsheet | Create new Apps Script

Sunday, July 29, 2018

Zendeskのwebhookを使ってみる


Zendeskのwebhookを利用する方法を調べたので書き残しておきます。


今回調べて実現したwebhookを使う手順
  1. Google Apps ScriptでWebアプリを作成する
  2. ZendeskのExtensionsのHTTP targetで1のアプリのURLを設定する
  3. ZendeskのTriggerで2を設定する



1.Google Apps ScriptでWebアプリを作成する

新規スクリプトファイルに以下のコードを書いて、ウェブアプリケーションとして導入する



コード.gs
function doPost(e) {
  console.log(e.postData.contents);
}
意訳
受け取ったデータeを
GCPのStackdriver Loggingに出す




STEP1 上記コードを新規スクリプトファイルに書


STEP2 ウェブアプリケーションとして導入...

STEP3
プロジェクトバージョン:説明を書く
次のユーザとしてアプリケーションを実行:自分
アプリケーションにアクセスできるユーザ:全員(匿名ユーザーを含む)←zendeskからアクセスできるように


STEP4 現在のウェブアプリケーションのURL:このURLをzendeskのHTTP targetのURLに設定する




2.ZendeskのExtensionsのHTTP targetで1のアプリのURLを設定する


STEP1
①歯車をクリック
②Extensionsをクリック
③add targetをクリック


STEP2 HTTP target >>をクリック

STEP3 HTTP targetを以下のように設定してSubmitをクリックする



3.ZendeskのTriggerで2を設定する


STEP1 
①Triggerをクリック
②Add triggerをクリック

STEP2 トリガー名と説明を設定

STEP3 Conditionsを以下のように設定

STEP4 Actionsで以下のように設定してSAVEする
JSONの中身はここで指定するらしい
JSON bodyに入れる{{{ticket.id}}}などは 下部のView available placeholders で確認できる


試してみる


新規チケットを作成するとStackdrive Loggingに以下のようなログが出力される

Stackdrive Loggingの確認方法はこちらに書きました
http://www.pre-practice.net/2018/07/consoleloggoogle-cloud.html


関連記事





参考

HTTPターゲットを使用したwebhookの作成
https://support.zendesk.com/hc/ja/articles/204890268-HTTP

Notifying external targets
https://support.zendesk.com/hc/en-us/articles/203662136#topic_hvf_eoa_vb

チケットの更新と通知のためのトリガの作成
https://support.zendesk.com/hc/ja/articles/203662106-Creating-and-managing-triggers-for-ticket-updates-and-notifications

About triggers and how they work
https://support.zendesk.com/hc/en-us/articles/203662246-About-triggers-and-how-they-work

プレースホルダの使用
https://support.zendesk.com/hc/ja/articles/203662116-Using-placeholders

外部ターゲットへ通知する

Latest post

Extracting data from Google Sheets with regular expressions

Introduction Regular expressions are a powerful tool that can be used to extract data from text.  In Google Sheets, regular expressions ca...