2017-07-25 80 views
1

我很難讓我的機器人發送Twilio消息。我不斷收到400個不好的請求我正在將msg對象看作JSON ---我認爲我爲Twilio創建地址的方式有問題嗎?我也已經通過並設置管理工具中的Twilio頻道在Microsoft Bot Framework中發送Twilio SMS

SMS == {「data」:{「type」:「message」,「agent」:「botbuilder」,「text」:「test msg「,」address「:{」channelId「:」sms「,」conversation「:{」id「:」4i4hlandl06ha5g3「,」isGroup「:false},」serviceUrl「:」https://sms.botframework.com「,」useAuth「 ,「source」:「sms」}} sendMsg - Session.sendBatch()發送0條消息

所以詳細一點。我使用Node.js的,沒有錯誤在控制檯您在上面看到是什麼sms從JSON版本:

 bot.dialog('sendMsg', function(session, context) { 
     var address = addresses.twilioAddress(session); 
     console.log(JSON.stringify(address)); 
     var sms = new builder.Message().text('test msg').address(address); 
     console.log("SMS == " + JSON.stringify(sms)); 
     bot.send(sms); 
    }).triggerAction({ matches: 'Communication.SendMessage' }) 
} 

我現在的想法是,我創建了地址Twilio錯誤。下面是一個樣子:

module.exports = { 
twilioAddress: function(session) { 
    console.log('made it to twilio Address'); 
    var address = init("twilio test", session, false, 'https://sms.botframework.com', 'sms'); 
    return address; 
} 

}

function init(name, session, isGroup, serviceUrl, channelId) { var address = { channelId: channelId, conversation: { id: session.message.address.id, isGroup: !!isGroup }, serviceUrl: serviceUrl, useAuth: true }; console.log(JSON.stringify(address)); return address; }

同樣,我的直覺告訴我,我莫名其妙地壓延創建地址。

回答