aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.42k stars 2.12k forks source link

Support Amazon Connect Chat in @amplify-js/interactions #5459

Open ranman opened 4 years ago

ranman commented 4 years ago

Problem Statement

Interactions currently supports Amazon Lex but many interactions still rely on human agents to resolve.

Amazon Connect is used by many customers as a call center service and it is increasingly used for chat interactions as well.

Ideally we could expand the interactions package to provide a new provider for chat interactions

Desired solution

The normal addition of amplify add interactions would work but in addition to accepting bots configurations it would accept chatProviders connection as well.

import Amplify from 'aws-amplify';

Amplify.configure({
  Auth: {
    identityPoolId: 'us-east-1:xxx-xxx-xxx-xxx-xxx',
    region: 'us-east-1'
  },
  Interactions: {
    chat: {
      connect: {
        "endpoint": "https://.../.../../",
        // "instanceId": "....",
       // "contactFlowId": "..."
      },
    }
  }
});

Alternatives

Adding it as a plugin?

Additional Context

Connect Chat Authentication and Lifecycle

auth sequence diagram

  1. Browser makes a request to start a chat. Typically this is an API hosted by a business outlined (here)[https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/cloudformationTemplates/startChatContactAPI]. Authenticated users could potentiaally call the StartChatContact API with IAM credentials from cognito.
  2. StartChatContact returns ParticipantId, ContactId, and ParticipantToken - a participant is a unique identifier for an individual in a conversation. A Participant can have multiple connections on multiple devices.
  3. Using the ParticipantToken a client calls the CreateParticipantConnection. This API does not use IAM/sigv4 auth. The call returns ConnectionToken and a Websocket wss:// URI. The ConnectionToken is used to send messages, events, and retrieve transcripts. The websocket is used to receive messages and events from Amazon Connect.

A single participant can be connected on multiple websockets (e.g. multiple devices like phone, computer, etc.).

Existing Implementations of Connect Chat

There's an existing chatjs package on NPM but it might be overly heavy for this implementation. It also vends its own, older version, of the v2 AWS JS SDK.

I would propose reimplementing some of the functionality in that library on top of the v3 JS SDK.

UI Considerations

Right now there's a focus solely on plain text messages. I believe richer messages (contact card style - quick replies, pictures, etc.) might be desired later.

The react and other UI implementations are interesting but those are not my area of expertise so I would appreciate some help here.

elorzafe commented 4 years ago

@ranman thanks for your feedback,

What about the use of having both (bot and human) interactions available, for example bot will ask some questions before connecting to the human in order to get more info or even resolve the problem without the human. Is like having a chain of interections where the output of one is the input for the next.

ranman commented 4 years ago

@elorzafe typically that's taken care of in Amazon Connect itself in a "Get Customer Input" block that's connected to a Lex bot.

https://aws.amazon.com/blogs/aws/new-amazon-connect-and-amazon-lex-integration/

I would be hesitant to build out an entire IVR system within the interactions package though.

I can see other situations where a customer might want a non-lex bot fronting a call and I'm open to that but it could be a non-trivial implementation to move that data around to various places. I'm also not aware of any non-lex implementations with amplify.