我正在建立一个系统,该系统将对从端点生成的客户端进行呼叫,但是在发起呼叫时,只会使状态排队并且不会响铃。
exports.capabilityToken = functions.https.onRequest((request, response) => {
const capability = new ClientCapability({
accountSid: accountSid,
authToken: authToken,
});
capability.addScope(new ClientCapability.IncomingClientScope(request.query.identity));
const appSid = "APXXXXXXXXXXX";
capability.addScope(
new ClientCapability.OutgoingClientScope({ applicationSid: appSid })
);
const token = capability.toJwt();
response.set('Content-Type', 'application/jwt');
response.send(token);
});
exports.accessToken = functions.https.onRequest((request, response) => {
console.log("tokenated");
var identity = null;
if (request.method == 'POST') {
identity = request.body.identity;
} else {
identity = request.query.identity;
console.log(request.query.identity);
}
// Used when generating any kind of tokens
const accountSid = "ACXXXXXXXX";
const apiKey = "SKXXXXXX";
const apiSecret = "XXXXXXX";
// Used specifically for creating Voice tokens
const pushCredSid = "CRXXXXXXXXX";
const outgoingApplicationSid = "APXXXXXXXXX";
// Create an access token which we will sign and return to the client,
// containing the grant we just created
const voiceGrant = new VoiceGrant({
outgoingApplicationSid: outgoingApplicationSid,
pushCredentialSid: pushCredSid
});
// Create an access token which we will sign and return to the client,
// containing the grant we just created
const token = new AccessToken(accountSid, apiKey, apiSecret);
token.addGrant(voiceGrant);
token.identity = identity;
token.clientName = identity;
latestToken = 'Token:' + token + " >>>>>>>>>> @ " + moment().format('hh:mm a');
console.log(latestToken);
response.send(token.toJwt());
});
我只是使用Dial.client拨打电话,然后设置了我的身份,但实际上并没有拨打电话,而是显示了此输出。
{ accountSid: 'ACXXXX',
annotation: null,
answeredBy: null,
apiVersion: '2010-04-01',
callerName: null,
dateCreated: null,
dateUpdated: null,
direction: 'outbound-api',
duration: null,
endTime: null,
forwardedFrom: null,
from: '+8628XXXXX',
fromFormatted: '+86XXXXX',
groupSid: null,
parentCallSid: null,
phoneNumberSid: null,
price: null,
priceUnit: 'USD',
sid: 'CAXXXXXX',
startTime: null,
status: 'queued'
}