LoginSignup
7
9

More than 3 years have passed since last update.

UiPath Developer Community 第10回ワークショップ 覚え書き。。OrchestratorのWebhook連携、ほか。

Last updated at Posted at 2019-02-23

UiPath Developer Community 第10回ワークショップ で聞いてきた内容の覚え書き。。

さあ、第10回です。前回「次回からは広い場所で」との宣言どおり、今回はSPACESあらため、サンケイビルのホールです。。。会場が広いからか、なんだかUiPathの中のヒトたちも緊張しています。

image.png

今回のトピックは、OrchestratorのWebhook機能の紹介と、2019年のリリース計画、あとは字幕アクティビティです。

OrchestratorのWebhook連携

https://orchestrator.uipath.com/lang-ja/docs/about-webhooks
コレです。

Orchestrator上のイベント(ロボの登録・更新・削除とか、ジョブのアベンドとか。。) をトリガーに、設定したWEB APIへのPOSTを行ってくれる機能。Orchestratorの画面では、POST先のURLの指定と、どのイベントに反応するか、あとは署名をするための共通鍵(キャプチャの「シークレット」)の設定を行うようになってます。

image.png

署名ってのは、OrchestratorのWebhookリクエストはHTTPリクエストのBody部を共通鍵で署名した値を x-uipath-signature ヘッダにつけて送ってくる仕様になっています。なので受ける側は、その共通鍵でHTTPのBody部をハッシュして署名と突合することで、正規のOrchestratorからのリクエストであることを判定することができます。

デモでは IFTTTみたいなサービスの Zapier を使ってSlack連携してました。が、たぶんZapierやIFTTTだと署名の検証が出来ない気がするので、、、たとえばFirebase Functionsなどでやってみるとこんな感じになりそうです。

index.ts

import * as functions from 'firebase-functions'
import * as request from 'request'
import { createHmac } from 'crypto'

const headerName = 'x-uipath-signature'

export const uipath_webhook = functions.https.onRequest((req, res) => {
  //   console.log(req.header(headerName))
  //   console.log(req.headers['content-type'])

  // console.log(req.header('X-Orchestrator-Signature'))
  // 署名検証メソッド。Orchestratorの画面で設定した「シークレット」(共通鍵) を使って、
  // HTTPリクエストのBody部を署名した情報が、ヘッダ x-uipath-signature で渡ってくる。
  // なのでその署名を検証すれば、送信元の正当性(Orchのシークレットをしっているヒト)を確認できる
  const isValidRequest = (_req, secret) => {
    const actualSignature = _req.header(headerName)
    return (
      actualSignature == null ||
      createHmac('sha256', secret)
        .update(_req.rawBody)
        .digest('base64') === actualSignature
    )
  }

  let message = {}
  let status = 200
  if (isValidRequest(req, 'abcde')) { // ← 画面で設定した共通鍵
    message = JSON.stringify(req.body) + req.header(headerName)
  } else {
    message =
      '不正なリクエスト。:' + JSON.stringify(req.body) + req.header(headerName)
    status = 401
    // 本来なら、Slack送信しない
  }

  const option = {
    url:
      'https://hooks.slack.com/services/xxxxx',
    method: 'POST',
    headers: {
      'content-type': 'application/json'
    },
    json: {
      text: message
    }
  }

  request(option, (error, response, body) => {
    res.status(status).send('ok')
  })
})

Cloud Functions for Firebase をつかってみる。 でセットアップしたFunctions のindex.tsを上記に差し替えてデプロイすると、Firebase Functions上に、UiPath OrchestratorのWebhookをうけるサーバを構築できます。

あ、ライブラリは下記のようにインストールしてデプロイしてください。

$ cd functions
$ npm install --save request crypto

ちなみに上記のサイト https://orchestrator.uipath.com/lang-ja/docs/about-webhooks には ヘッダが X-Orchestrator-Signature だとかの記述があったりしますが、たぶん間違ってるのでご注意ください。

-- 2019/07/03追記--
今見たら、ヘッダの記述なおってますね。。
-- 2019/07/03追記 以上 --

リリースの考え方

詳細は省略。

2018年は年末ギリギリに突如LTS版がリリースされてザワつきましたが、、今回は、ロードマップを公開します、と。
今年は 4/15,10/21 の2回で、2回目の10/21がLTSになるんだそうです。

image.png

字幕アクティビティ

お客様にデモする機会がちょくちょくありますが、字幕を表示できるとデモが何かと楽になりそうです。。UiPath Goからダウンロード出来るようです。。

image.png

ノベルティ

今回のノベルティは、エナジードリンクとステッカーでした。
image.png

おつかれさまでした。。

関連リンク

7
9
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
9