向 Twilio POST 响应添加额外信息
Adding extra information to the Twilio POST response
有没有我可以添加到 client.calls.create({
方法的属性,它允许我向请求正文添加额外的信息,Twilio 将在回调 URL 中 post?像这样:
client.calls.create({
method: 'GET',
extraInfo: { employeeID: 'ABC123' }, <-- This would be what I want to add to the JSON response.
statusCallback: `${config.host}/completed`,
statusCallbackMethod: 'POST',
twiml: responseString,
to: data.number`,
from: `+1${availableNumbers[0]}`
})
会有 Twilio return 这是我的回调 URL:
{
"extraInfo": { employeeID: 'ABC123' }, <-- This would be what should be added to the POST request
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"annotation": null,
"answered_by": null,
"api_version": "2010-04-01",
"caller_name": null,
"date_created": "Tue, 31 Aug 2010 20:36:28 +0000",
"date_updated": "Tue, 31 Aug 2010 20:36:44 +0000",
"direction": "inbound",
"duration": "15",
"end_time": "Tue, 31 Aug 2010 20:36:44 +0000",
"forwarded_from": "+141586753093",
"from": "+18668675310",
"from_formatted": "(866) 867-5310",
"group_sid": null,
"parent_call_sid": null,
"phone_number_sid": "PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"price": "-0.03000",
"price_unit": "USD",
"sid": "CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"start_time": "Tue, 31 Aug 2010 20:36:29 +0000",
"status": "completed",
"subresource_uris": {
"notifications": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Notifications.json",
"recordings": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Recordings.json",
"feedback": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Feedback.json",
"feedback_summaries": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/FeedbackSummary.json",
"payments": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Payments.json"
},
"to": "+14155551212",
"to_formatted": "(415) 555-1212",
"trunk_sid": null,
"uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json",
"queue_time": "1000"
}
不使用 twiml 参数,而是使用 url 参数并将 HTTP 查询参数附加到 URL 的末尾。您可以对 statusCallback URL.
执行相同的操作
有没有我可以添加到 client.calls.create({
方法的属性,它允许我向请求正文添加额外的信息,Twilio 将在回调 URL 中 post?像这样:
client.calls.create({
method: 'GET',
extraInfo: { employeeID: 'ABC123' }, <-- This would be what I want to add to the JSON response.
statusCallback: `${config.host}/completed`,
statusCallbackMethod: 'POST',
twiml: responseString,
to: data.number`,
from: `+1${availableNumbers[0]}`
})
会有 Twilio return 这是我的回调 URL:
{
"extraInfo": { employeeID: 'ABC123' }, <-- This would be what should be added to the POST request
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"annotation": null,
"answered_by": null,
"api_version": "2010-04-01",
"caller_name": null,
"date_created": "Tue, 31 Aug 2010 20:36:28 +0000",
"date_updated": "Tue, 31 Aug 2010 20:36:44 +0000",
"direction": "inbound",
"duration": "15",
"end_time": "Tue, 31 Aug 2010 20:36:44 +0000",
"forwarded_from": "+141586753093",
"from": "+18668675310",
"from_formatted": "(866) 867-5310",
"group_sid": null,
"parent_call_sid": null,
"phone_number_sid": "PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"price": "-0.03000",
"price_unit": "USD",
"sid": "CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"start_time": "Tue, 31 Aug 2010 20:36:29 +0000",
"status": "completed",
"subresource_uris": {
"notifications": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Notifications.json",
"recordings": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Recordings.json",
"feedback": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Feedback.json",
"feedback_summaries": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/FeedbackSummary.json",
"payments": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Payments.json"
},
"to": "+14155551212",
"to_formatted": "(415) 555-1212",
"trunk_sid": null,
"uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json",
"queue_time": "1000"
}
不使用 twiml 参数,而是使用 url 参数并将 HTTP 查询参数附加到 URL 的末尾。您可以对 statusCallback URL.
执行相同的操作