2016-10-13 2 views
1

웹 훅 설정이있어서 메시지를 수신하고 이에 응답 할 수 있습니다. Messaging Server에 첨부 된 응답을 webhook에서 보내도록하고 싶습니다.nodejs 라이브러리의 twiml 응답에 messagingServiceSid를 첨부하십시오.

내가 문서에

client.sendMessage({ 
    messagingServiceSid: 'MG9752274e9e519418a7406176694466fa', 
    to: '+16518675309', 
    body: 'Phantom Menace was clearly the best of the prequel trilogy.' 
}, function(err, message) { 
    console.log(message); 
}); 

이 코드 비슷한 무언가가 거기에 사용하는 경우에만 새 SMS에 대한 나의은 webhook로부터 응답이를 구성 할 수있는 방법을 찾지 못했습니다

? 그것은 UI를 통해 할 수 있습니까?

app.post('/foo/bar/sms', twilio.webhook({ 
    host:'gassy-ocelot-129.herokuapp.com', 
    protocol:'https' 
}), function(request, response) { 
    var twiml = new twilio.TwimlResponse(); 
    twiml.message('This HTTP request came from Twilio!'); 
    response.send(twiml); 
}); 

이미지 : No messagingService on reply messages sent using twiml response

Message Detail view from logs

답변

0

개발자 전도사 Twilio가 여기 있습니다.

알고있는 한 TwiML로 메시지 서비스의 메시지에 회신 할 수있는 방법이 없습니다.

그러나 TwiML을 사용하는 대신 send the SMS back to your user from the REST API을 입력하고 들어오는 webhook에 <Response>을 반환 할 수 있습니다. 다음과 같이 약간 :

app.post('/foo/bar/sms', twilio.webhook({ 
    host:'gassy-ocelot-129.herokuapp.com', 
    protocol:'https' 
}), function(request, response) { 
    // send the message from the message service 
    client.sendMessage({ 
    messagingServiceSid: 'MG9752274e9e519418a7406176694466fa', 
    to: request.body.From, 
    body: 'Your message' 
    }, function(err, message) { 
    console.log(message); 
    }); 
    // send empty TwiML response 
    var twiml = new twilio.TwimlResponse(); 
    response.send(twiml); 
}) 

그게 도움이되는지 알려주세요.

0

그런 다음, (웹 UI 또는 전화 번호 REST를 통해) 현재 해당 메시징 서비스에 설정 한 전화 번호에 들어오는 SMS를 수신하는 경우 들어오는 요청은 쿼리 문자열에 MessagingServiceSid이됩니다.

+0

명확성을 위해 질문을 편집하여 이미지를 추가했습니다. 메시징 서비스에 연결하기 위해 보내는 응답을 보내고 싶습니다. –

관련 문제