日本時間5月16日のContent Cloud Summitで、カスタムアプリにBox AI APIを活用する方法を紹介します。

詳細を表示

返信の作成

ガイド コメント 返信の作成

返信の作成

以前のコメントへの返信を作成するには、新しいコメントのメッセージと、返信を残す以前のコメントのIDを指定してPOST /comments APIを呼び出します。

cURL
curl -i -X POST "https://api.box.com/2.0/comments" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -H "content-type: application/json" \
     -d '{
       "message": "I agree with this.",
       "item": {
         "type": "comment",
         "id": 345344
       }
     }
Java
BoxComment comment = new BoxComment(api, "id");
comment.reply("I agree with this!");
Python
reply_comment = client.comment(comment_id='12345').reply('If possible, please finish this by the end of the week!')
Node
// Reply to the comment with ID 11111
client.comments.reply('11111', 'Yes, this is the latest version.')
    .then(comment => {
        /* comment -> {
            type: 'comment',
            id: '44444',
            is_reply_comment: true,
            message: 'Yes, this is the latest version',
            created_by: 
            { type: 'user',
                id: '55555',
                name: 'Example User 2',
                login: 'user2@example.com' },
            created_at: '2012-12-13T07:19:08-08:00',
            item: { id: '33333', type: 'file' },
            modified_at: '2012-12-13T07:19:08-08:00' }
        */
    });

返信のメッセージでは、@記号を使用してユーザーをメンションすることもできます。そのためには、メッセージ内の任意の場所に@[userid:name]という文字列を追加します。user_idはターゲットユーザーのIDで、nameには任意のカスタムフレーズを使用できます。Box UIでは、この名前がユーザーのプロフィールにリンクされます。

次に、この文字列をmessageではなくtagged_messageとして渡します。

cURL
curl -i -X POST "https://api.box.com/2.0/comments" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -H "content-type: application/json" \
     -d '{
       "message": " @[1234:John], I agree with this.",
       "item": {
         "type": "comment",
         "id": 345344
       }
     }
Java
BoxComment comment = new BoxComment(api, "id");
comment.reply("@[1234:user@box.com] I agree with this!");
Python
reply_comment = client.comment(comment_id='12345').reply('@[33333:John Doe], if possible, please finish this by the end of the week!')
Node
client.comments.createTaggedReply('11111', '@[22222:Sam] Yes, this is the most recent version!')
    .then(comment => {
        /* comment -> {
            type: 'comment',
            id: '44444',
            is_reply_comment: false,
            tagged_message: '@[22222:Sam] Yes, this is the most recent version!',
            created_by: 
            { type: 'user',
                id: '55555',
                name: 'Example User 2',
                login: 'user2@example.com' },
            created_at: '2012-12-13T07:19:08-08:00',
            item: { id: '33333', type: 'file' },
            modified_at: '2012-12-13T07:19:08-08:00' }
        */
    });