Git Product home page Git Product logo

tamdilip / whatsapp-amazonconnect-chat Goto Github PK

View Code? Open in Web Editor NEW
14.0 2.0 8.0 762 KB

Node JS server for transferring real-time messages between WhatsApp and Amazon Connect Chat via Twilio's WhatsApp Business API Sandbox.

Home Page: https://tamdilip.github.io/whatsapp-amazonconnect-chat/

JavaScript 100.00%
sdk-api whatsapp whatsapp-amazonconnect-chat twilio-whatsapp-sandbox voice amazon-connect dynamodb nodejs twilio-sandbox websocket

whatsapp-amazonconnect-chat's Introduction

whatsapp-amazonconnect-chat

Open in CodeSandbox

Node JS server for transferring real-time messages between WhatsApp and Amazon Connect Chat using Twilio's WhatsApp Business API Sandbox via Server-Side Websocket Clients.

This proof-of-concept is an integration between WhatsApp and Amazon Connect Chat in realtime to leverage customer support by live agents without any BOT Madness 🤪 .

Architecture

Image of architecture

Usage of SDK API's

Image of sdk-api-flow

Local Testing

==================

Prerequisites

Node Server setup

        $ git clone https://github.com/tamdilip/whatsapp-amazonconnect-chat.git
        $ cd whatsapp-amazonconnect-chat
        $ npm i

Tunneling

        $ npm install ngrok -g
        $ ngrok http 3000

Post Installation

  • Configure the ngrok url/Node server host URL in Twilio WhatsApp Sandbox - Webhook

    WHEN A MESSAGE COMES IN - https://xxxxxxxx.ngrok.io/

    STATUS CALLBACK URL - https://xxxxxxxx.ngrok.io/status-callback

  • All set now, keep your Amazon Connect Chat Interface as Available and try sending a text from your whatsapp to Twilio-WhatsApp-Business-Number and continue the conversation bi-directionally 😁😎

  • Additionally if the customer texts as call me (update the text/chat-command as you like), it forwards the message to agent chat and also automatically places an outgoing voice call bidirectionally.

Notes

  • Looked for a suitable AWS service which provides serverless kind of approach to maintain an active websocket client connections on the serverside without any overhead efforts for scalability, load balancing, maintenance.
  • Lambda doesn't fit for this as it has execution time-out limitation, also don't want to spin up an EC2 instance/EKS/Fargate which requires a bit effort on maintaining and scalability just to host an active nodejs server.
  • Tested messaging simultaneously from multiple whatsapp numbers, all has been properply placed to the number of available agents.
  • In case of agent drop-out and reconnection, the support was placed correctly with the chat history conversation and also to the same agent on queue based on his availability as first preference.
  • Placing Voice call on call me was not tested in realtime, on how it behaves when an agent is active with chat support and the same agent is expected to get the call from the customer he's supporting. As per Amazon connects policy, an agent can either be available for chat or voice at a time.

Bookmarks

Happy coding :) !!

whatsapp-amazonconnect-chat's People

Contributors

dependabot[bot] avatar tamdilip avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

whatsapp-amazonconnect-chat's Issues

Error::sendWhatsappMessageToConnect AccessDeniedException: Access denied

Hi Team,

I am doing random testing and got one issue as explained below .

Use Case :- 1.Custome initiate the chat ,
                   2. Agent received and answered .
                  3. Now the Agent ends the chat .
                  4. The same customer sent the chat message again.
                   5.Application through the below error  while initiating the chat from a different number then working.

Error :-
  client.messages { accountSid: 'ACe1305ef50b020ec18bb9c88b5721e124' }
Success::sendMessage SM2c770e8a0ffc4c14a313e3428c266e14
CONNECT:: AGENT :: application/vnd.amazonaws.connect.event.participant.left
CONNECT:: undefined :: application/vnd.amazonaws.connect.event.chat.ended
Error::sendMessageToChat AccessDeniedException: Access denied
    at Object.extractError (C:\whatsapp-amazonconnect-chat\node_modules\aws-sdk\lib\protocol\json.js:51:27)
    at Request.extractError (C:\whatsapp-amazonconnect-chat\node_modules\aws-sdk\lib\protocol\rest_json.js:55:8)
    at Request.callListeners (C:\whatsapp-amazonconnect-chat\node_modules\aws-sdk\lib\sequential_executor.js:106:20)
    at Request.emit (C:\whatsapp-amazonconnect-chat\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
    at Request.emit (C:\whatsapp-amazonconnect-chat\node_modules\aws-sdk\lib\request.js:683:14)
    at Request.transition (C:\whatsapp-amazonconnect-chat\node_modules\aws-sdk\lib\request.js:22:10)
    at AcceptorStateMachine.runTo (C:\whatsapp-amazonconnect-chat\node_modules\aws-sdk\lib\state_machine.js:14:12)
    at C:\whatsapp-amazonconnect-chat\node_modules\aws-sdk\lib\state_machine.js:26:10
    at Request. (C:\whatsapp-amazonconnect-chat\node_modules\aws-sdk\lib\request.js:38:9)
    at Request. (C:\whatsapp-amazonconnect-chat\node_modules\aws-sdk\lib\request.js:685:12) {
  code: 'AccessDeniedException',
  time: 2020-10-29T06:32:44.336Z,
  requestId: '66f3f072-4b74-4c21-bb9c-0d45f10c0c07',
  statusCode: 403,
  retryable: false,
  retryDelay: 83.94447352367985
}
Error::sendWhatsappMessageToConnect AccessDeniedException: Access denied
    at Object.extractError (C:\whatsapp-amazonconnect-chat\node_modules\aws-sdk\lib\protocol\json.js:51:27)
    at Request.extractError (C:\whatsapp-amazonconnect-chat\node_modules\aws-sdk\lib\protocol\rest_json.js:55:8)
    at Request.callListeners (C:\whatsapp-amazonconnect-chat\node_modules\aws-sdk\lib\sequential_executor.js:106:20)
    at Request.emit (C:\whatsapp-amazonconnect-chat\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
    at Request.emit (C:\whatsapp-amazonconnect-chat\node_modules\aws-sdk\lib\request.js:683:14)
    at Request.transition (C:\whatsapp-amazonconnect-chat\node_modules\aws-sdk\lib\request.js:22:10)
    at AcceptorStateMachine.runTo (C:\whatsapp-amazonconnect-chat\node_modules\aws-sdk\lib\state_machine.js:14:12)
    at C:\whatsapp-amazonconnect-chat\node_modules\aws-sdk\lib\state_machine.js:26:10
    at Request. (C:\whatsapp-amazonconnect-chat\node_modules\aws-sdk\lib\request.js:38:9)
    at Request. (C:\whatsapp-amazonconnect-chat\node_modules\aws-sdk\lib\request.js:685:12) {
  code: 'AccessDeniedException',
  time: 2020-10-29T06:32:44.336Z,
  requestId: '66f3f072-4b74-4c21-bb9c-0d45f10c0c07',
  statusCode: 403,
  retryable: false,
  retryDelay: 83.94447352367985
}

I have tried to troubleshoot this issue and got some work around:

route.txt

file name : route.js
Work around:- I have made a connection again in catch block . Attaching the file or your reference.
I am looking for better solution if anybody can help on this

Regards
Tarun

Conversation is not working bi-directionally

Hi Team,
I have implemented the setup as suggested in this article and able to connect with chat agent from my WhatsApp number .

But conversation is not working bi-directionally i.e. I have only send message from my number to Agent but not able to
received the message whatever send by chat agent.

Could you suggest me how to check this issue . It can be any specific country wise number is required for testing.

Thanks & Regards
Tarun Jain

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.