2017-06-30 4 views
1

RESTを使用してchatbotを開発しています。チャットボットの返信メッセージがボットフレームワークを使用している場合、 'replyToId'プロパティを作成できません

{ 
    "error": { 
     "code": "ServiceError", 
     "message": "Cannot create property 'replyToId' on string 'type=message&from[id]=ch1ilide7a2hm0lj3&from[name]=Bot&conversation[id]=e365an7nh78ckc8c4c&recipient[id]=default-user&recipient[name]=User&text=My+reply&replyToId=aj3d8l13dj1iik077c'" 
    } 
} 

マイボットメッセージを受信

{ 
    "type": "message", 
    "text": "test", 
    "from": { 
    "id": "default-user", 
    "name": "User" 
    }, 
    "locale": "en-US", 
    "timestamp": "2017-06-30T09:18:51.414Z", 
    "channelData": { 
    "clientActivityId": "1498814323988.43585210617995895.0" 
    }, 
    "id": "f981681n6mn1i6ef", 
    "channelId": "emulator", 
    "localTimestamp": "2017-06-30T16:18:51+07:00", 
    "recipient": { 
    "id": "ch1ilide7a2hm0lj3", 
    "name": "Bot" 
    }, 
    "conversation": { 
    "id": "2bc3d4ag3ekdg8f" 
    }, 
    "serviceUrl": "http://localhost:33893" 
} 

私のコードの応答メッセージ:ボット応答メッセージの前に

class ReplyMessagesService 
    def perform params, access_token 
    conversation = params['conversation'] 
    bot   = params['recipient'] 
    user   = params['from'] 
    activity_id = params['id'] 
    service_url = params['serviceUrl'] 
    url = service_url + '/v3/conversations/' + conversation['id'] + '/activities/' + activity_id 
    begin 
     RestClient.post url, 
     { 
      "type": "message", 
      "from": { 
      "id": bot["id"], 
      "name": bot["name"], 
      }, 
      "conversation": { 
      "id": conversation["id"], 
      }, 
      "recipient": { 
      "id": user["id"], 
      "name": user["name"], 
      }, 
      "text": "My reply", 
      "replyToId": activity_id, 
     }, 
     { 
      "authorization": "Bearer " + access_token, 
      "content_type": "application/json" 
     } 
    rescue RestClient::ExceptionWithResponse => e 
     e.response 
    end 
    end 
end 

マイのparams私のチャットボットは、ユーザーにメッセージを返信すると、私は問題を抱えています

//user 
<ActionController::Parameters {"id"=>"default-user", "name"=>"User"} permitted: false> 
    //bot 
<ActionController::Parameters {"id"=>"ch1ilide7a2hm0lj3", "name"=>"Bot"} permitted: false> 
    //conversation 
<ActionController::Parameters {"id"=>"b80253miifem6ie86"} permitted: false> 
    //activity_id 
"hk696f267j9gjdc6i" 
    //service_url 
"http://localhost:33893" 
    //url 
    "http://localhost:33893/v3/conversations/b80253miifem6ie86/activities/hk696f267j9gjdc6i" 

私を助けてください。

ありがとうございました!

答えて

0

私の場合は、コンテンツタイプのヘッダーのため、"Content-Type:application/json"に設定する必要があります。私が何をしているかを見せてもらうために、私は返信を作成していましたが、要求に応じてコンテンツタイプを設定していましたが、これはコンテンツに必要でしたが(これはC#でしたが)。私はRubyに堪能ではありませんが、コンテンツの種類を設定し、それが機能するかどうかを確認してみてください。

+0

ありがとうございます!あなたが言うように、私はそれを修正しました。 –

関連する問題