in Python/ConnectDialer.py [0:0]
def callOutbound(phoneNumbers, cFlowID, cID, sNum, table):
# Start outbound call for each entry and update entry in DB
for item in phoneNumbers:
formatted = item['TelephoneNumber']
print('Attempting Call: ' + formatted)
try:
response = connect.start_outbound_voice_contact(
DestinationPhoneNumber=formatted,
ContactFlowId=cFlowID,
InstanceId=cID,
SourcePhoneNumber=sNum
)
print('Call success for: ' + formatted)
except Exception as inst:
print('Error: ', inst )
CA = client.get_item(
TableName=table,
Key={
'TelephoneNumber': {
'S': item["TelephoneNumber"]
}
},
AttributesToGet=['contactAttempts']
)
print('Existing attempts for ' + formatted + ': ' + str(CA['Item']['contactAttempts']['S']))
counter = int(CA['Item']['contactAttempts']['S'])
counter += 1
#publishCWMetric()
client.update_item(
TableName=table,
Key={
'TelephoneNumber': {
'S': item["TelephoneNumber"]
}
},
UpdateExpression="set contactAttempts =:attempts, lastAttempt=:time, lastAttemptDateTime=:dttime",
ExpressionAttributeValues={
':attempts': {'S': str(counter)},':time':{'N': str(datetime.now().timestamp())}, ':dttime':{'S':datetime.now().isoformat()}
},
)