React 애플리케이션에 amazon-Conect-streams 포함
아마존-connect-streams란 무엇입니까?
Amazon Connect Streams API(Streams)를 사용하면 기존 웹 응용 프로그램을 Amazon Connect와 통합할 수 있습니다.Streams를 사용하면 Contact Control Panel(CCP) UI 구성 요소를 페이지에 포함하여 에이전트와 접촉 상태 이벤트를 직접 처리하고 대상을 대상으로 하는 이벤트 드라이브 인터페이스를 통해 에이전트와 접촉 상태를 제어할 수 있습니다.
https://github.com/aws/amazon-connect-streams
온라인에서 간단한 샘플을 찾을 수 있지만, 리액트 앱에서 사용하면 오류를 시도해야 하니 프로그램을 정리해보자.
컨디션
OS: macOS Mojave (10.14.5)
Node: v11.15.0(v12는 아마존-Conect-streams의build에서 오류가 발생)
npm: v6.10.1
create-react-app: v3.0.1
사전 작업
절차.
React 프로젝트를 만들고 amazon-connect-Sstreams 설치
GiitHub clone에서 amazon-connect-streams build을 만듭니다.(2019/7/15 현재 npm에서 공개되지 않음)
로컬build 모듈
npm install
을 사용합니다.# Reactのプロジェクトを作成
$ create-react-app custom-ccp
$ cd custom-ccp
# Reactのプロジェクト配下にamazon-connect-streamsをclone
$ git clone [email protected]:aws/amazon-connect-streams.git
# .gitignoreに/amazon-connect-streamsを追加しておく
$ echo /amazon-connect-streams >> .gitignore
# amazon-connect-streamsをbuild
$ cd amazon-connect-streams
$ npm install
$ npx gulp
# buildしたファイルをamazon-connect-streams直下に移動
$ cp release/connect-streams.js ./index.js
$ cp src/index.d.ts ./
# buildしたamazon-connect-streamsをインストール
$ cd ..
$ npm install ./amazon-connect-streams
React 애플리케이션 설치
App.js
에서buildamazon-connect-streams
이 진행되었습니다.App.js
import React, { Component } from 'react';
import 'amazon-connect-streams';
import pkg from '../package.json';
import './App.css';
class App extends Component {
constructor(props) {
super(props);
this.containerDiv = React.createRef();
}
componentDidMount() {
// CCPの読み込み処理
// eslint-disable-next-line no-undef
connect.core.initCCP(this.containerDiv.current, {
ccpUrl: 'https://{YOUR_INSTANCE_NAME}.awsapps.com/connect/ccp#/',
});
}
render() {
return (
<div className="App">
<main>
<div className="ccp">
{/* ccp */}
<div
className="containerDiv"
ref={this.containerDiv}
/>
</div>
<div className="content" />
</main>
<footer>
<p className="version">version: {pkg.version}</p>
</footer>
</div>
);
}
}
export default App;
참조: App.css이번 일과는 상관없지만 참고로 앱.css의 내용도 기재되어 있습니다.
App.css
.App {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
}
main {
flex: 1;
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: stretch;
overflow: auto;
}
.ccp {
width: 330px;
min-width: 200px;
height: calc(100vh - 40px);
}
.containerDiv {
width: 320px;
min-width: 200px;
min-height: 400px;
height: 465px;
}
.content {
flex: 1;
}
footer {
height: 40px;
width: 100%;
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
background-color: #ececec;
}
.version {
font-size: small;
color: #666;
padding-right: 10px;
}
import
생성된 콘텐츠를 아마존 S3의 통에 올리고, HTTPS를 통해 접근할 때 다음 화면이 나온다.이렇게 하면 React 응용 프로그램에 끼워 넣을 수 있다
npm run build
.참고 자료
Reference
이 문제에 관하여(React 애플리케이션에 amazon-Conect-streams 포함), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/Kazunori-Kimura/items/546f2db361440467dc31텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)