2014-11-20 2 views
1

Twilio 대기열을 만들려고 여러 YouTube 동영상을 따라 왔지만 다음은 자습서와 거의 동일한 코드입니다.하지만 대기열은 지정된 대기열에 알려지기 전에 종료됩니다. 대기열에있는 사용자의 번호 (SMS를 통해). SMS 코드를 주석 처리했으며 대기열 응용 프로그램이 정상적으로 작동했습니다. 제가 언급 한 튜토리얼 동영상은 1 년 전에 작성되었습니다. 디버깅 할 때 내 계정 SID와 토큰을 식별 할 수있는 방법을 설명했습니다.twilio 대기열 : SMS 메시지에서 파이썬 코드 종료

from flask import Flask 
from flask import request 
from flask import url_for 
from twilio import twiml 
from twilio.rest import TwilioRestClient 
import os 

#from flask import render_template 

# Declare and configure application 
app = Flask(__name__) #, static_url_path='/static') 
#app.config.from_pyfile('local_settings.py') 


# Configure this number to a toll-free Twilio number to accept incoming calls. 
@app.route('/caller', methods=['POST']) #'GET' 
def caller(): 
    response = twiml.Response() 
    response.say("Thank you for calling the call center.") 
    response.pause(length = "1") 
    response.say ("Please hold.") 
    response.enqueue("Queue", waitUrl='/wait') 
    return str(response) 


# Configure waiting room to notify user of current position in the queue and 
# play the sweet, soothing sounds of Twilio's coffeeshop collection. 
@app.route('/wait', methods=['POST']) #'GET' 
def wait(): 
    response = twiml.Response() 
    response.pause(length = "1") 
    response.say("You are number %s in the queue." % request.form['QueuePosition']) 
    response.play("XXXXXXXXXXXXYYYYYYYYYYYZZZZZZZZZZZZZ") 
    ##response.play("http://com.twilio.music.guitars.s3.amazonaws.com/" \ 
    ##  "Pitx_-_Long_Winter.mp3") 
    #client = TwilioRestClient("XXXXXXYYYYYZZZZ","XXXXXXYYYYYYYZZZZ") 
    #client.sms.message.create(body="You have a customer waiting in your call center queue. Please call to help.", to="+XYYYYYZZZ", from_="+XXXXXYYYYZZZZ") 
    #message = client.messages 
    account_sid = "XXXXYYYYZZZ" 
    auth_token = "XXXXXYYYYYYZZZZ" 
    client = TwilioRestClient(account_sid, auth_token) 
    message = client.messages.create("You have a customer waiting in your call center queue. Please call to help.", 
    to="+XXXXYYYYZZZZ", # Replace with your phone number 
    from_="+XXXXXYYYYZZZZ") # Replace with your Twilio number 
    #response.redirect('/wait') 
    #print message.sid 
    return str(response) 


# Connect to support queue - assign to Twilio number for agent to call. 
@app.route('/agent', methods=['POST']) #'GET' 
def agent(): 
    response = twiml.Response() 
    with response.dial() as dial: 
     dial.queue("Queue") 
    return str(response) 


# If PORT not specified by environment, assume development config. 
if __name__ == '__main__': 
    port = int(os.environ.get("PORT", 5000)) 
    #if port == 5000: 
    app.debug = True 
    app.run(host='0.0.0.0', port=port) 

답변

0

1-2 세 비디오 자습서를 참조하는 경우 최신 의존성을 확인하십시오! 내 Heroku requirements.txt 파일에 지정된 내 Twilio 종속성 버전이 최신이 아니 었습니다.이 오래된 종속성이 내 초기 문의 (SMS 메시지를 보낼 수 없음)의 원인으로 확인되었습니다.

flask==0.9 
twilio==3.1 

이 고려 :

대신에 다음으로

flask>=0.9 
twilio>=3.1 

다음을 통해, 특정 의존성의 "보다"버전을 지정하는 옵션이 있습니다

>= 구문을 사용하면 해당 xx보다 큰 모든 버전을 가져올 수 있습니다. 프로젝트에 특정 (구형이 ​​아닌) 특정 종속성 버전이 필요할 수 있습니다. 일단 가상 환경을 활성화 virtualenv

선언 종속의 사용을 통해 가상 환경으로 방향을 가져올 수

는 거의 의존성을 분리하고 상호 배타적 종속 특정 프로젝트를 만들 수 있습니다.