def auto_call(): # Get Emergency Service for location # Dial number (Would be emergency service) response = VoiceResponse() dial = Dial() dial.number('470-705-7212') response.append(dial) print(response) # Get pickup status response = VoiceResponse() response.dial('415-123-4567', action='/handleDialCallStatus', method='GET') response.say('I am unreachable') # Twilio will submit a request to the action URL with the parameter 'DialCallStatus'. # If nobody picks up, 'DialCallStatus' will be 'no-answer'. # If the line is busy, 'DialCallStatus' will be 'busy'. # If the called party picks up, 'DialCallStatus' will be 'completed'. # If a conference is successfully dialed, 'DialCallStatus' will be 'answered'. # If an invalid phone number was provided, 'DialCallStatus' will be 'failed'. print(response) # Automated Voice Intro = "(person's name)" # Get information from Smart911Connect Account # http://www.smart911connect.com/get-access/ # Development Block :( # no free APIs that send medical info to Emergency Services, however they all return JSON # Use Mongoose, JSON -> DB -> JSON # Get information as JSON - Python NamedTuple -> String # Feed into IBM Watson import json from watson_developer_cloud import DialogV1 as Dialog dialog = Dialog(username='******', password='******') dialog_id = 'YOUR_DIALOGID' conversation = dialog.conversation(dialog_id) client_id = conversation['client_id'] print dialog.update_profile(dialog_id=dialog_id, client_id=client_id, name_values={"name_values": [{"name": "Product_Name", "value": "Sunglasses"}]}) print dialog.update_profile(dialog_id=dialog_id, client_id=client_id, name_values=[{"name": "Product_Name", "value": "Sunglasses"}]) # Operator Interface with Twilio return
def __init__(self): dialog_service = Dialog(username=WATSON_USERNAME, password=WATSON_PASSWORD) dialog_id = WATSON_DIALOG_ID # # CREATE A DIALOG # with open(join(dirname(__file__), '../dialog_files/jemboo-dialog-file.xml')) as dialog_file: # create_dialog_response = dialog_service.update_content(dialog_file=dialog_file, name='jemboo-dialog') # UPDATE A DIALOG # with open(join(dirname(__file__), '../dialog_files/jemboo-dialog-file.xml')) as dialog_file: # # create_dialog_response = dialog_service.update_dialog(dialog_file=dialog_file, dialog_id=dialog_id) handlers = [ url(r"/api/bluemix/initChat", InitChat, dict(dialog_service=dialog_service, dialog_id=dialog_id), name="root"), url(r"/api/bluemix/postConversation", Conversation, dict(dialog_service=dialog_service, dialog_id=dialog_id), name="conversation"), (r'/()', tornado.web.StaticFileHandler, { 'path': "static/index.html" }), (r'/(.*)', tornado.web.StaticFileHandler, { 'path': "static/" }), # (r'/static/(.*)', tornado.web.StaticFileHandler, {'path': static_path}), ] settings = dict( template_path=join(dirname(__file__), "../templates"), # static_path=os.path.join(os.path.dirname(__file__), "../static"), debug=tornado.options.options.debug, ) tornado.web.Application.__init__(self, handlers, **settings)
for opt, arg in opts: if opt == '-h': usage() sys.exit() elif opt in ("-f", "---dialogfile"): dialog_filepath = arg elif opt in ("-a", "---dialog_id"): dialog_id = arg elif opt == '-d': DEBUG = True if not dialog_filepath or not dialog_id: print('Required argument missing.') usage() sys.exit(2) try: # get dialog object dialog = Dialog(username=dialogConstants.getUsername(), password=dialogConstants.getPassword()) # update the dialog sys.stdout.write('Updating dialog %s\n' % dialog_id) with open(dialog_filepath, 'rb') as dialog_file: res = dialog.update_dialog(dialog_id, dialog_file) sys.stdout.write('Response: \n%s\n' % json.dumps(res, indent=2)) except Exception as e: sys.stdout.write(str(e)) exit(1)
from os.path import join, dirname from time import sleep from dialog.settings import WATSON_USERNAME, WATSON_PASSWORD, WATSON_DIALOG_ID from watson_developer_cloud import DialogV1 as Dialog from dialog_build_file import build build() dialog_service = Dialog(username=WATSON_USERNAME, password=WATSON_PASSWORD) dialog_id = WATSON_DIALOG_ID sleep(4) with open(join(dirname(__file__), 'dialog_files/jemboo-dialog-file.xml'), mode="r") as dialog_file: dialog_service.update_dialog(dialog_file=dialog_file, dialog_id=dialog_id) print("done")
# coding=utf-8 import json from os.path import join, dirname from watson_developer_cloud import DialogV1 as Dialog dialog = Dialog(username='******', password='******') print(json.dumps(dialog.get_dialogs(), indent=2)) # CREATE A DIALOG # with open(join(dirname(__file__), '../resources/dialog.xml') as dialog_file: # print(json.dumps(dialog.create_dialog( # dialog_file=dialog_file, name='pizza_test_9'), indent=2)) # dialog_id = '98734721-8952-4a1c-bb72-ef9957d4be93' # with open(join(dirname(__file__), '../resources/dialog.xml') as dialog_file: # print(json.dumps(dialog.update_dialog(dialog_file=dialog_file, dialog_id=dialog_id), indent=2)) # print(json.dumps(dialog.get_content(dialog_id), indent=2)) # # initial_response = dialog.conversation(dialog_id) # # print(json.dumps(initial_response, indent=2)) # # print(json.dumps(dialog.conversation(dialog_id=dialog_id, # dialog_input='What type of toppings do you have?', # conversation_id=initial_response['conversation_id'], # client_id=initial_response['client_id']), indent=2))