I am trying to use the available phone number API in order to claim and attach a contact flow. I tried following the documentation provided by AWS for python.
when I try to use it, it gives the following error
Exception thrown: ‘Connect’ object has no attribute ‘search_available_phone_numbers’"
client = boto3.client('connect')
response = client.search_available_phone_numbers(
TargetArn='arn:aws:connect:us-east-1:**********:instance/**********/contact-flow/....',
PhoneNumberCountryCode='US',
PhoneNumberType='TOLL_FREE'
)
NOTE: I tried using other APIs like create user, Associate lambda, and Associate LEX. All those worked except the one I .
Thanks in advance
2
Answers
I suspect that your boto3 package isn’t up to date.
Rerun
pip install boto3
and try again.You will need to create a layer for boto3 pointing to the latest version of the package that includes the search_available_phone_numbers API that you are trying to call and add that layer to the lambda.
The AWS Lambda service supports up to python 3.9 runtimes currently, and it’s associated boto3 package version points to version 1.20.32 (https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html)
You can double check this within your own lambda function on the console if you added
print(boto3.__version__)
after your boto3 import. As of right now, the python sdk (boto3) docs references version 1.25.4 and hence there will be quite a few features and updates in the docs that are not reflected by the package currently built into the AWS Lambda service.Hope this adds some clarity to your question!