def get_attendants(): origin_bot_auth_key = '{{origin_bot_auth_key}}' origin_bot_session = BlipSession(origin_bot_auth_key) skip = 0 take = 100 attendants_response = origin_bot_session.force_command(get_request_body(skip, take)) attendants = attendants_response['resource']['items'] while attendants_response['resource']['total'] >= 100: skip = 100 take += 100 attendants_response = origin_bot_session.force_command(get_request_body(skip, take)) attendants += attendants_response['resource']['items'] return attendants
def set_attendants(attendants): destiny_bot_auth_key = '{{destinity_auth_key}}' destiny_bot_session = BlipSession(destiny_bot_auth_key) for attendant in attendants: crb = { "to": "*****@*****.**", "method": "set", "uri": "/attendants", "type": "application/vnd.iris.desk.attendant+json", "resource": create_attendant_body(attendant) } set_attendant_response = destiny_bot_session.force_command(crb, 3) if set_attendant_response['status'] == 'success': print(f'{attendant["fullname"]} adicionado com sucesso') else: print(f'Erro ao adicionar {attendant["fullname"]}')
from blip_session import BlipSession my_auth_key = '{{bot_auth_key}}' bs = BlipSession(my_auth_key) user_id = '{{phone_number}}@wa.gw.msging.net' ccrb = {'method': 'get', 'uri': f'/contexts/{user_id}'} response = bs.force_command(ccrb) print(response) context_variables = response['resource']['items'] for context in context_variables: bs.process_command({ 'method': 'delete', 'uri': f'/contexts/{user_id}/{context}' })
'resource': { 'itemType': 'application/vnd.iris.portal.user-permission+json', 'items': permissions }, 'metadata': { 'server.shouldStore': 'true' } } if __name__ == '__main__': print(f'Found {len(BOTS)} bots') for bot in BOTS: session = BlipSession(bot) bot_account = session.force_command(create_get_bot_account()) bot_account = bot_account['resource'] bot_identity = bot_account['identity'] bot_name = bot_account['fullName'] print(f'Starting to add on {bot_name}...') for member in TEAM_MEMBERS: print(f'Adding member {member} to {bot_name}') commands_to_exec = [ create_set_auth_permissions(member, ADMIN_AUTH_PERMISSIONS, bot_identity, bot_name), create_set_user(member, bot_identity), create_set_user_permissions(member, ADMIN_USER_PERMISSIONS, bot_identity)
if (len(sys.argv) < 5): print( 'Uso: python import_reports.py <chave_bot_origem> <chave_bot_destino>') exit() first_bot_key = sys.argv[1] + ' ' + sys.argv[2] second_bot_key = sys.argv[3] + ' ' + sys.argv[4] first_bot_bs = BlipSession(first_bot_key) second_bot_bs = BlipSession(second_bot_key) get_intent_body = { "to": "*****@*****.**", "method": "get", "uri": "/content" } bot_intentions = first_bot_bs.force_command(get_intent_body) print(bot_intentions['resource']) for intetion in bot_intentions['resource']['items']: print(intetion) response = second_bot_bs.force_command({ "to": "*****@*****.**", "method": "set", "uri": "/content", "type": "application/vnd.iris.ai.content-result+json", "resource": intetion })