Amazon Connect examples using Amazon CLI
The following code examples show you how to perform actions and implement common scenarios by using the Amazon Command Line Interface with Amazon Connect.
Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.
Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.
Topics
Actions
The following code example shows how to use create-user.
- Amazon CLI
-
To create a user
The following
create-userexample adds a user with the specified attributes to the specified Amazon Connect instance.aws connect create-user \ --usernameMary\ --passwordPass@Word1\ --identity-infoFirstName=Mary,LastName=Major\ --phone-configPhoneType=DESK_PHONE,AutoAccept=true,AfterContactWorkTimeLimit=60,DeskPhoneNumber=+15555551212\ --security-profile-id12345678-1111-2222-aaaa-a1b2c3d4f5g7\ --routing-profile-id87654321-9999-3434-abcd-x1y2z3a1b2c3\ --instance-ida1b2c3d4-5678-90ab-cdef-EXAMPLE11111Output:
{ "UserId": "87654321-2222-1234-1234-111234567891", "UserArn": "arn:aws:connect:us-west-2:123456789012:instance/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111/agent/87654321-2222-1234-1234-111234567891" }For more information, see Add Users
in the Amazon Connect Administrator Guide. -
For API details, see CreateUser
in Amazon CLI Command Reference.
-
The following code example shows how to use delete-user.
- Amazon CLI
-
To delete a user
The following
delete-userexample deletes the specified user from the specified Amazon Connect instance.aws connect delete-user \ --instance-ida1b2c3d4-5678-90ab-cdef-EXAMPLE11111\ --user-id87654321-2222-1234-1234-111234567891This command produces no output.
For more information, see Manage Users
in the Amazon Connect Administrator Guide. -
For API details, see DeleteUser
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-user-hierarchy-group.
- Amazon CLI
-
To display the details for a hierarchy group
The following
describe-user-hierarchy-groupexample displays the details for the specified Amazon Connect hierarchy group.aws connect describe-user-hierarchy-group \ --hierarchy-group-id12345678-1111-2222-800e-aaabbb555gg\ --instance-ida1b2c3d4-5678-90ab-cdef-EXAMPLE11111Output:
{ "HierarchyGroup": { "Id": "12345678-1111-2222-800e-a2b3c4d5f6g7", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111/agent-group/12345678-1111-2222-800e-a2b3c4d5f6g7", "Name": "Example Corporation", "LevelId": "1", "HierarchyPath": { "LevelOne": { "Id": "abcdefgh-3333-4444-8af3-201123456789", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111/agent-group/abcdefgh-3333-4444-8af3-201123456789", "Name": "Example Corporation" } } } }For more information, see Set Up Agent Hierarchies
in the Amazon Connect Administrator Guide. -
For API details, see DescribeUserHierarchyGroup
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-user-hierarchy-structure.
- Amazon CLI
-
To display the details for a hierarchy structure
The following
describe-user-hierarchy-structureexample displays the details for the hierarchy structure for the specified Amazon Connect instance.aws connect describe-user-hierarchy-group \ --instance-ida1b2c3d4-5678-90ab-cdef-EXAMPLE11111Output:
{ "HierarchyStructure": { "LevelOne": { "Id": "12345678-1111-2222-800e-aaabbb555gg", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111/agent-group-level/1", "Name": "Corporation" }, "LevelTwo": { "Id": "87654321-2222-3333-ac99-123456789102", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111/agent-group-level/2", "Name": "Services Division" }, "LevelThree": { "Id": "abcdefgh-3333-4444-8af3-201123456789", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111/agent-group-level/3", "Name": "EU Site" } } }For more information, see Set Up Agent Hierarchies
in the Amazon Connect Administrator Guide. -
For API details, see DescribeUserHierarchyStructure
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-user.
- Amazon CLI
-
To display the details for a user
The following
describe-userexample displays the details for the specified Amazon Connect user.aws connect describe-user \ --user-id0c245dc0-0cf5-4e37-800e-2a7481cc8a60--instance-id40c83b68-ea62-414c-97bb-d018e39e158eOutput:
{ "User": { "Id": "0c245dc0-0cf5-4e37-800e-2a7481cc8a60", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/40c83b68-ea62-414c-97bb-d018e39e158e/agent/0c245dc0-0cf5-4e37-800e-2a7481cc8a60", "Username": "Jane", "IdentityInfo": { "FirstName": "Jane", "LastName": "Doe", "Email": "example.com" }, "PhoneConfig": { "PhoneType": "SOFT_PHONE", "AutoAccept": false, "AfterContactWorkTimeLimit": 0, "DeskPhoneNumber": "" }, "DirectoryUserId": "8b444cf6-b368-4f29-ba18-07af27405658", "SecurityProfileIds": [ "b6f85a42-1dc5-443b-b621-de0abf70c9cf" ], "RoutingProfileId": "0be36ee9-2b5f-4ef4-bcf7-87738e5be0e5", "Tags": {} } }For more information, see Manage Users
in the Amazon Connect Administrator Guide. -
For API details, see DescribeUser
in Amazon CLI Command Reference.
-
The following code example shows how to use get-contact-attributes.
- Amazon CLI
-
To retrieve the attributes for a contact
The following
get-contact-attributesexample retrieves the attributes that were set for the specified Amazon Connect contact.aws connect get-contact-attributes \ --instance-ida1b2c3d4-5678-90ab-cdef-EXAMPLE11111\ --initial-contact-id12345678-1111-2222-800e-a2b3c4d5f6g7Output:
{ "Attributes": { "greetingPlayed": "true" } }For more information, see Use Amazon Connect Contact Attributes
in the Amazon Connect Administrator Guide. -
For API details, see GetContactAttributes
in Amazon CLI Command Reference.
-
The following code example shows how to use list-contact-flows.
- Amazon CLI
-
To list the contact flows in an instance
The following
list-contact-flowsexample lists the contact flows in the specified Amazon Connect instance.aws connect list-contact-flows \ --instance-ida1b2c3d4-5678-90ab-cdef-EXAMPLE11111Output:
{ "ContactFlowSummaryList": [ { "Id": "12345678-1111-2222-800e-a2b3c4d5f6g7", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111/contact-flow/12345678-1111-2222-800e-a2b3c4d5f6g7", "Name": "Default queue transfer", "ContactFlowType": "QUEUE_TRANSFER" }, { "Id": "87654321-2222-3333-ac99-123456789102", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111/contact-flow/87654321-2222-3333-ac99-123456789102", "Name": "Default agent hold", "ContactFlowType": "AGENT_HOLD" }, { "Id": "abcdefgh-3333-4444-8af3-201123456789", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111/contact-flow/abcdefgh-3333-4444-8af3-201123456789", "Name": "Default customer hold", "ContactFlowType": "CUSTOMER_HOLD" }, ] }For more information, see Create Amazon Connect Contact Flows
in the Amazon Connect Administrator Guide. -
For API details, see ListContactFlows
in Amazon CLI Command Reference.
-
The following code example shows how to use list-hours-of-operations.
- Amazon CLI
-
To list the hours of operation in an instance
The following
list-hours-of-operationsexample lists the hours of operations for the specified Amazon Connect instance.aws connect list-hours-of-operations \ --instance-id40c83b68-ea62-414c-97bb-d018e39e158eOutput:
{ "HoursOfOperationSummaryList": [ { "Id": "d69f1f84-7457-4924-8fbe-e64875546259", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/40c83b68-ea62-414c-97bb-d018e39e158e/operating-hours/d69f1f84-7457-4924-8fbe-e64875546259", "Name": "Basic Hours" } ] }For more information, see Set the Hours of Operation for a Queue
in the Amazon Connect Administrator Guide. -
For API details, see ListHoursOfOperations
in Amazon CLI Command Reference.
-
The following code example shows how to use list-phone-numbers.
- Amazon CLI
-
To list the phone numbers in an instance
The following
list-phone-numbersexample lists the phone numbers in the specified Amazon Connect instance.aws connect list-phone-numbers \ --instance-ida1b2c3d4-5678-90ab-cdef-EXAMPLE11111Output:
{ "PhoneNumberSummaryList": [ { "Id": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111/phone-number/xyz80zxy-xyz1-80zx-zx80-11111EXAMPLE", "PhoneNumber": "+17065551212", "PhoneNumberType": "DID", "PhoneNumberCountryCode": "US" }, { "Id": "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111/phone-number/ccc0ccc-xyz1-80zx-zx80-22222EXAMPLE", "PhoneNumber": "+18555551212", "PhoneNumberType": "TOLL_FREE", "PhoneNumberCountryCode": "US" } ] }For more information, see Set Up Phone Numbers for Your Contact Center
in the Amazon Connect Administrator Guide. -
For API details, see ListPhoneNumbers
in Amazon CLI Command Reference.
-
The following code example shows how to use list-queues.
- Amazon CLI
-
To list the queues in an instance
The following
list-queuesexample lists the queues in the specified Amazon Connect instance.aws connect list-queues \ --instance-ida1b2c3d4-5678-90ab-cdef-EXAMPLE11111Output:
{ "QueueSummaryList": [ { "Id": "12345678-1111-2222-800e-a2b3c4d5f6g7", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111/queue/agent/12345678-1111-2222-800e-a2b3c4d5f6g7", "QueueType": "AGENT" }, { "Id": "87654321-2222-3333-ac99-123456789102", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111/queue/agent/87654321-2222-3333-ac99-123456789102", "QueueType": "AGENT" }, { "Id": "abcdefgh-3333-4444-8af3-201123456789", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111/queue/agent/abcdefgh-3333-4444-8af3-201123456789", "QueueType": "AGENT" }, { "Id": "hgfedcba-4444-5555-a31f-123456789102", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111/queue/hgfedcba-4444-5555-a31f-123456789102", "Name": "BasicQueue", "QueueType": "STANDARD" }, ] }For more information, see Create a Queue
in the Amazon Connect Administrator Guide. -
For API details, see ListQueues
in Amazon CLI Command Reference.
-
The following code example shows how to use list-routing-profiles.
- Amazon CLI
-
To list the routing profiles in an instance
The following
list-routing-profilesexample lists the routing profiles in the specified Amazon Connect instance.aws connect list-routing-profiles \ --instance-ida1b2c3d4-5678-90ab-cdef-EXAMPLE11111Output:
{ "RoutingProfileSummaryList": [ { "Id": "12345678-1111-2222-800e-a2b3c4d5f6g7", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111/routing-profile/12345678-1111-2222-800e-a2b3c4d5f6g7", "Name": "Basic Routing Profile" }, ] }For more information, see Create a Routing Profile
in the Amazon Connect Administrator Guide. -
For API details, see ListRoutingProfiles
in Amazon CLI Command Reference.
-
The following code example shows how to use list-security-profiles.
- Amazon CLI
-
To list the security profiles in an instance
The following
list-security-profilesexample lists the security profiles in the specified Amazon Connect instance.aws connect list-security-profiles \ --instance-ida1b2c3d4-5678-90ab-cdef-EXAMPLE11111Output:
{ "SecurityProfileSummaryList": [ { "Id": "12345678-1111-2222-800e-a2b3c4d5f6g7", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111/security-profile/12345678-1111-2222-800e-a2b3c4d5f6g7", "Name": "CallCenterManager" }, { "Id": "87654321-2222-3333-ac99-123456789102", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111/security-profile/87654321-2222-3333-ac99-123456789102", "Name": "QualityAnalyst" }, { "Id": "abcdefgh-3333-4444-8af3-201123456789", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111/security-profile/abcdefgh-3333-4444-8af3-201123456789", "Name": "Agent" }, { "Id": "12345678-1111-2222-800e-x2y3c4d5fzzzz", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111/security-profile/12345678-1111-2222-800e-x2y3c4d5fzzzz", "Name": "Admin" } ] }For more information, see Assign Permissions: Security Profiles
in the Amazon Connect Administrator Guide. -
For API details, see ListSecurityProfiles
in Amazon CLI Command Reference.
-
The following code example shows how to use list-user-hierarchy-groups.
- Amazon CLI
-
To list the user hierarchy groups in an instance
The following
list-user-hierarchy-groupsexample lists the user hierarchy groups in the specified Amazon Connect instance.aws connect list-user-hierarchy-groups \ --instance-id40c83b68-ea62-414c-97bb-d018e39e158eOutput:
{ "UserHierarchyGroupSummaryList": [ { "Id": "0e2f6d1d-b3ca-494b-8dbc-ba81d9f8182a", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/40c83b68-ea62-414c-97bb-d018e39e158e/agent-group/0e2f6d1d-b3ca-494b-8dbc-ba81d9f8182a", "Name": "Example Corporation" }, ] }For more information, see Set Up Agent Hierarchies
in the Amazon Connect Administrator Guide. -
For API details, see ListUserHierarchyGroups
in Amazon CLI Command Reference.
-
The following code example shows how to use list-users.
- Amazon CLI
-
To list the user hierarchy groups in an instance
The following
list-usersexample lists the users in the specified Amazon Connect instance.aws connect list-users \ --instance-id40c83b68-ea62-414c-97bb-d018e39e158eOutput:
{ "UserSummaryList": [ { "Id": "0c245dc0-0cf5-4e37-800e-2a7481cc8a60", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/40c83b68-ea62-414c-97bb-d018e39e158e/agent/0c245dc0-0cf5-4e37-800e-2a7481cc8a60", "Username": "Jane" }, { "Id": "46f0c67c-3fc7-4806-ac99-403798788c14", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/40c83b68-ea62-414c-97bb-d018e39e158e/agent/46f0c67c-3fc7-4806-ac99-403798788c14", "Username": "Paulo" }, { "Id": "55a83578-95e1-4710-8af3-2b7afe310e48", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/40c83b68-ea62-414c-97bb-d018e39e158e/agent/55a83578-95e1-4710-8af3-2b7afe310e48", "Username": "JohnD" }, { "Id": "703e27b5-c9f0-4f1f-a239-64ccbb160125", "Arn": "arn:aws:connect:us-west-2:123456789012:instance/40c83b68-ea62-414c-97bb-d018e39e158e/agent/703e27b5-c9f0-4f1f-a239-64ccbb160125", "Username": "JohnS" } ] }For more information, see Add Users
in the Amazon Connect Administrator Guide. -
For API details, see ListUsers
in Amazon CLI Command Reference.
-
The following code example shows how to use update-contact-attributes.
- Amazon CLI
-
To update a contact's attribute
The following
update-contact-attributesexample updates thegreetingPlayedattribute for the specified Amazon Connect user.aws connect update-contact-attributes \ --initial-contact-id11111111-2222-3333-4444-12345678910\ --instance-ida1b2c3d4-5678-90ab-cdef-EXAMPLE11111\ --attributesgreetingPlayed=falseThis command produces no output.
For more information, see Use Amazon Connect Contact Attributes
in the Amazon Connect Administrator Guide. -
For API details, see UpdateContactAttributes
in Amazon CLI Command Reference.
-
The following code example shows how to use update-user-hierarchy.
- Amazon CLI
-
To update a user's hierarchy
The following
update-user-hierarchyexample updates the agent hierarchy for the specified Amazon Connect user.aws connect update-user-hierarchy \ --hierarchy-group-id12345678-a1b2-c3d4-e5f6-123456789abc\ --user-id87654321-2222-1234-1234-111234567891\ --instance-ida1b2c3d4-5678-90ab-cdef-EXAMPLE11111This command produces no output.
For more information, see Configure Agent Settings
in the Amazon Connect Administrator Guide. -
For API details, see UpdateUserHierarchy
in Amazon CLI Command Reference.
-
The following code example shows how to use update-user-identity-info.
- Amazon CLI
-
To update a user's identity information
The following
update-user-identity-infoexample updates the identity information for the specified Amazon Connect user.aws connect update-user-identity-info \ --identity-infoFirstName=Mary,LastName=Major,Email=marym@example.com\ --user-id87654321-2222-1234-1234-111234567891\ --instance-ida1b2c3d4-5678-90ab-cdef-EXAMPLE11111This command produces no output.
For more information, see Configure Agent Settings
in the Amazon Connect Administrator Guide. -
For API details, see UpdateUserIdentityInfo
in Amazon CLI Command Reference.
-
The following code example shows how to use update-user-phone-config.
- Amazon CLI
-
To update a user's phone configuration
The following
update-user-phone-configexample updates the phone configuration for the specified user.aws connect update-user-phone-config \ --phone-configPhoneType=SOFT_PHONE,AutoAccept=false,AfterContactWorkTimeLimit=60,DeskPhoneNumber=+18005551212\ --user-id12345678-4444-3333-2222-111122223333\ --instance-ida1b2c3d4-5678-90ab-cdef-EXAMPLE11111This command produces no output.
For more information, see Configure Agent Settings
in the Amazon Connect Administrator Guide. -
For API details, see UpdateUserPhoneConfig
in Amazon CLI Command Reference.
-
The following code example shows how to use update-user-routing-profile.
- Amazon CLI
-
To update a user's routing profile
The following
update-user-routing-profileexample updates the routing profile for the specified Amazon Connect user.aws connect update-user-routing-profile \ --routing-profile-id12345678-1111-3333-2222-4444EXAMPLE\ --user-id87654321-2222-1234-1234-111234567891\ --instance-ida1b2c3d4-5678-90ab-cdef-EXAMPLE11111This command produces no output.
For more information, see Configure Agent Settings
in the Amazon Connect Administrator Guide. -
For API details, see UpdateUserRoutingProfile
in Amazon CLI Command Reference.
-
The following code example shows how to use update-user-security-profiles.
- Amazon CLI
-
To update a user's security profiles
The following
update-user-security-profilesexample updates the security profile for the specified Amazon Connect user.aws connect update-user-security-profiles \ --security-profile-ids12345678-1234-1234-1234-1234567892111\ --user-id87654321-2222-1234-1234-111234567891\ --instance-ida1b2c3d4-5678-90ab-cdef-EXAMPLE11111This command produces no output.
For more information, see Assign Permissions: Security Profiles
in the Amazon Connect Administrator Guide. -
For API details, see UpdateUserSecurityProfiles
in Amazon CLI Command Reference.
-