Option 2: Integrate in-app, web, and video calling natively into your mobile application using the Amazon Chime SDK client APIs - Amazon Connect

Option 2: Integrate in-app, web, and video calling natively into your mobile application using the Amazon Chime SDK client APIs

To integrate Amazon Connect in-app, web, and video calling natively with your mobile application use the Amazon Connect StartWebRTCContact API to create the contact, and then use the details returned by the API call to join the call using the Amazon Chime client library for iOS or Android.

How a client device initiates an in-app or web call

The following diagram shows the sequence of events for a client device (mobile application or browser) to initiate an in-app or web call.

A conceptual diagram that shows how a client devices initiates a call.
  1. Your customer uses the client application (website or application) to start an in-app or web call.

  2. The client application (website or mobile application) or web server uses the Amazon Connect StartWebRTCContact API to start the contact passing any attributes or context to Amazon Connect.

  3. The client application joins the call using the details returned from the StartWebRTCContact in step 1.

  4. (Optional) Client uses the CreateParticipantConnection API to receive a ConnectionToken that is used to send DTMF through the SendMessage API.

  5. The contact reaches the flow and is routed based on the flow and placed in queue.

  6. The agent accepts the contact.

  7. (Optional) If video is enabled for customer and the agent, they are able to start their video.

Get started

Following are the high level steps to get started:

  1. Use the StartWebRTCContact API to create the contact. The API returns the details needed for the Amazon Chime client SDK to join the call.

  2. Instantiate the Amazon Chime SDK client MeetingSessionConfiguration object using the configurations returned by StartWebRTCContact.

  3. Instantiate Amazon Chime SDK client DefaultMeetingSession with MeetingSessionConfiguration, which was created in step 2 to create a client meeting session.

    • iOS (Swift)

      let logger = ConsoleLogger(name: "logger") let meetingSession = DefaultMeetingSession(configuration: meetingSessionConfig, logger: logger)
    • Android (Kotlin)

      val logger = ConsoleLogger() val meetingSession = DefaultMeetingSession( configuration = meetingSessionConfig, logger = logger, context = applicationContext )
  4. Use the meetingSession.audioVideo.start() method to join the WebRTC contact with audio.

  5. Use the meetingSession.audioVideo.stop() method to hangup the WebRTC contact.

  6. Optional steps

    1. To send DTMF to the call, two Amazon Connect Participant Service APIs are needed: CreateParticipantConnection and SendMessage respectively.

      Note

      contentType for the SendMessage API must be audio/dtmf.

      1. Invoke CreateParticipantConnection to retrieve ConnectionToken. (ParticipantToken is needed for calling this API. You can find it in the StartWebRTCContact response.)

      2. With the ConnectionToken, call SendMessage for sending DTMF digits.

    2. For mute and unmute, use meetingSession.audioVideo.realtimeLocalMute() and meetingSession.audioVideo.realtimeLocalUnmute().

    3. To start self video on the mobile application, use the meetingSession.audioVideo.startLocalVideo().

    4. To stop self video on the mobile application, use the meetingSession.audioVideo.stopLocalVideo().

    5. To allow receiving and loading video of the agent inside mobile application, use the meetingSession.audioVideo.startRemoteVideo().

    6. To disallow receiving and loading video of the agent inside mobile application, use the meetingSession.audioVideo.stopRemoteVideo().

    7. To select the audio input/output device, you can use the methods from the Amazon Chime SDK client for Android and iOS or the native iOS capabilities for iOS.