簡體   English   中英

自動駕駛儀和功能收集數據他

[英]Autopilot and Functions collecting data he

我在自動駕駛儀中有一個任務,它從調用者那里收集數據,然后使用重定向調用 function。 我似乎無法訪問帖子變量。 請協助。

所以當運行這個我得到以下錯誤

錯誤 - 82002

Twilio Function 響應錯誤

這行代碼產生的

var first_name = memory.twilio.collected_data.lead_qual.lead_qual_first;

刪除該行,它可以正常工作,只是無法訪問收集的數據。

以下是我包含的依賴項、任務代碼和 function。

看起來像這樣..依賴項......>

lodash 4.17.11 twilio 3.29.2 fs 0.0.1-security got 9.6.0 moment-timezone 0.5.14 moment 2.29.1 xmldom 0.1.27 twilio/runtime-handler 1.0.1 util 0.11.0 request 2.8.7

任務……>

    {
"actions": [
{
"collect": {
"name": "lead_qual",
"questions": [
{
"question": "What is your first name?",
"name": "lead_qual_first",
"type": "Twilio.FIRST_NAME"
},
{
"question": "What is your last name?",
"name": "lead_qual_last",
"type": "Twilio.LAST_NAME"
},
{
"question": "If we are disconnected what is the best phone number to reach you on??",
"name": "lead_qual_phone",
"type": "Twilio.PHONE_NUMBER"
},
{
"question": "What is your date of birth?",
"name": "lead_qual_dob",
"type": "Twilio.DATE"
},
{
"question": "Are you currently covered by disability, yes or no?",
"name": "lead_qual_disability",
"type": "Twilio.YES_NO"
},
{
"question": "Do you have any form of federal medicare, yes or no?",
"name": "lead_qual_medicare",
"type": "Twilio.YES_NO"
},
{
"question": "Do you have medicaid or another state sponsored insurance, yes or no?",
"name": "lead_qual_medicaid",
"type": "Twilio.YES_NO"
},
{
"question": "Finally, Are you currently insured, yes or no?",
"name": "lead_qual_insured",
"type": "Twilio.YES_NO"
}
],
"on_complete": {
"redirect": {
"method": "POST",
"uri": "https://health-agent-3097.twil.io/Evaluate-Answers"
}
}
}
}
]
}
 

Function......>

// This is your new function. To start, set the name and path on the left.

exports.handler = function(context, event, callback) {

// Require the component used to post.

const got = require("got");

// Time zone for EST to check times with.

let moment = require('moment-timezone');

const now = moment().tz('America/New_York');

// initialize the return object

var responseObject = {};

var first_name = memory.twilio.collected_data.lead_qual.lead_qual_first;

responseObject =

{

"actions":[

  {

    "say":"Force Override result"

  },

  {

    "redirect": {

      "method": "POST",

      "uri": "task://goodbye"

    }

  }

]
}

// This callback is what is returned in response to this function being invoked.

callback(null, responseObject);}

Twilio 開發人員布道師在這里。

memory不是傳遞給 Twilio Z86408593C34AF77FDD1Z0DF932F8B526 的 arguments 之一你被傳遞eventcontextcallback 您正在正確使用callback ,並且context包含您的環境變量。

不過,您在這里需要event object。 event包括發送到 Function 的所有參數。 根據Autopilot 請求的文檔,您將收到一個Memory參數。 那個Memory將是一個需要解析的 JSON 字符串。 因此,請嘗試訪問:

const memory = JSON.parse(event.Memory);
const firstName = memory.twilio.collected_data.lead_qual.lead_qual_first;

讓我知道你是怎么做到的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM