向AWS发送请求时出错

时间:2017-09-27 06:43:32

标签: api amazon-web-services

我使用AWS Lex API向其服务发送消息(AWS Lex) 但它给了我一个错误

  

并发客户端请求:保存会话数据时遇到资源冲突

这是我的代码

user_id = params[:appUser][:_id]
intercept = Intercept.find_by_user_id(user_id)
  begin
    app_id = params[:app][:_id]
    text = params[:messages][0][:text]
    platform = params[:appUser][:clients][0][:platform]
    status = params[:appUser][:devices][0][:active]
    unless params[:appUser][:userId].nil? && params[:appUser][:userId].eql?("19980216")
      CreateInterceptWorker.perform_async(app_id,status,platform,user_id)
    end
    CreateMessageUserWorker.perform_async(user_id,params[:messages][0][:name],text,params[:messages][0][:_id])
      unless intercept.nil? || intercept.is_human.eql?(true)
        bot = App.find_by_app_id(app_id).bot
        publish_alias = bot.publish_aliases.last.name
        response = @lex_runtime.post_text( bot_name: bot.name,bot_alias: publish_alias,input_text: text,user_id: user_id)
        text_response = response.message
        message_post_body = SmoochApi::MessagePost.new( text: text_response,role: 'appMaker',type: 'text')
        binding.pry
        result = @api_instance.post_message(app_id, user_id, message_post_body)
        CreateMessageMakerWorker.perform_async(result.message.author_id,result.message.text,result.message._id,user_id)
      end
  rescue Exception => x
    message_post_body = SmoochApi::MessagePost.new( text: x,role: 'appMaker',type: 'text')
    result = @api_instance.post_message(app_id, user_id, message_post_body)
  end

0 个答案:

没有答案