def incoming_sms(request):
""" Changes worker activity and returns a confirmation """
client = Client(ACCOUNT_SID, AUTH_TOKEN)
activity = 'Idle' if request.POST['Body'].lower().strip() == 'on' else 'Offline'
activity_sid = WORKSPACE_INFO.activities[activity].sid
worker_sid = WORKSPACE_INFO.workers[request.POST['From']]
workspace_sid = WORKSPACE_INFO.workspace_sid
client.workspaces(workspace_sid)\
.workers(worker_sid)\
.update(activity_sid=activity_sid)
resp = MessagingResponse()
message = 'Your status has changed to ' + activity
resp.message(message)
return HttpResponse(resp)
评论列表
文章目录