📝

Amazon Connect のハンズオンを AWS CLI でやってみる #2

に公開

Amazon Connect のハンズオンを AWS CLI でやってみるシリーズの 2 回目です。
各回については以下のリンクからご覧ください。

  1. Amazon Connect のハンズオンを AWS CLI でやってみる #1

今から始める Amazon Connect 入門 #2 | DevelopersIO
前回は Amazon Connect インスタンスの作成やユーザーの作成を行いました。
今回は電話番号の取得を行います。

前提

  • AWS CLI の実行環境は CloudShell
  • 使用リージョンはバージニア北部

01. 電話番号の取得

search-available-phone-numbers — AWS CLI 2.31.10 Command Reference
電話番号の取得にあたって、まずは利用可能な電話番号の一覧を取得します。

  • target-arn: 前回作成した Amazon Connect インスタンスの ARN
  • phone-number-country-code: 電話番号の国コード
    • 今回はアメリカ
  • phone-number-type: 電話番号のタイプ
  • max-items: コマンドでの取得件数
    • 今回は 10 件
$ aws connect search-available-phone-numbers \
--target-arn your-instance-arn \
--phone-number-country-code US \
--phone-number-type DID \
--max-items 10

{
    "AvailableNumbersList": [
        {
            "PhoneNumber": "+13862677074",
            "PhoneNumberCountryCode": "US",
            "PhoneNumberType": "DID"
        },
        {
            "PhoneNumber": "+13862677073",
            "PhoneNumberCountryCode": "US",
            "PhoneNumberType": "DID"
        },
        {
            "PhoneNumber": "+13862677078",
            "PhoneNumberCountryCode": "US",
            "PhoneNumberType": "DID"
        },
        {
            "PhoneNumber": "+13862677079",
            "PhoneNumberCountryCode": "US",
            "PhoneNumberType": "DID"
        },
        {
            "PhoneNumber": "+13862677069",
            "PhoneNumberCountryCode": "US",
            "PhoneNumberType": "DID"
        },
        {
            "PhoneNumber": "+13853402904",
            "PhoneNumberCountryCode": "US",
            "PhoneNumberType": "DID"
        },
        {
            "PhoneNumber": "+13853414291",
            "PhoneNumberCountryCode": "US",
:

claim-phone-number — AWS CLI 2.31.10 Command Reference
続いて電話番後を取得します。

  • phone-number: search-available-phone-numbers のいずれか
    • 例: +13853414291 など
$ aws connect claim-phone-number \
--target-arn your-instance-arn \
--phone-number "xxx"

{
    "PhoneNumberId": "xxx",
    "PhoneNumberArn": "xxx"
}

これで電話番号を取得できました。

02. 電話番号の確認

list-phone-numbers — AWS CLI 2.31.10 Command Reference
Amazon Connect インスタンスに電話番号が紐づいていることを確認します。

$ aws connect list-phone-numbers \
--instance-id your-instance-arn

{
    "PhoneNumberSummaryList": [
        {
            "Id": "xxx",
            "Arn": "xxx",
            "PhoneNumber": "xxx",
            "PhoneNumberType": "DID",
            "PhoneNumberCountryCode": "US"
        }
    ]
}

03. 電話番号とフローの関連付け

電話番号の取得のみではフローと関連付けされないため、明示的に関連付けを行います。
なお、関連付けはあとで変更するのでここでは関連付けできることだけ確認できれば OK です。

list-contact-flows — AWS CLI 2.31.10 Command Reference
まずはフローの一覧を取得します。

$ aws connect list-contact-flows \
--instance-id your-instance-arn

{
    "ContactFlowSummaryList": [
        {
            "Id": "xxx",
            "Arn": "xxx",
            "Name": "Sample inbound flow (first contact experience)",
            "ContactFlowType": "CONTACT_FLOW",
            "ContactFlowState": "ACTIVE",
            "ContactFlowStatus": "PUBLISHED"
        },
        // 以下略
    ]
}

associate-phone-number-contact-flow — AWS CLI 2.31.10 Command Reference
今回は Sample inbound flow との関連付けを行います。

  • phone-number-id: list-phone-numbers で取得した電話番号の ID
$ aws connect associate-phone-number-contact-flow \
--phone-number-id your-phone-number-id \
--instance-id your-instance-arn \
--contact-flow-id your-contact-flow-id

batch-get-flow-association — AWS CLI 2.31.10 Command Reference
電話番号とフローの関連付けを確認します。

  • resource-ids: list-phone-numbers で取得した電話番号の ID
$ aws connect batch-get-flow-association \
--instance-id your-instance-arn \
--resource-ids your-phone-number-id \
--resource-type VOICE_PHONE_NUMBER

{
    "FlowAssociationSummaryList": [
        {
            "ResourceId": "xxx",
            "FlowId": "xxx",
            "ResourceType": "VOICE_PHONE_NUMBER"
        }
    ]
}

これで電話番号とフローが紐づきました。

まとめ

今回は Amazon Connect のハンズオンを AWS CLI でやってみるシリーズの 2 回目として、電話番号の取得を行いました。
次回は問い合わせフローの作成からやっていきます。

参考資料

Discussion