일반적으로 에이전트는 사용자가 대화 중에 제공하는 정보 이외에는 커뮤니케이션하는 사용자에 대한 통찰력이 거의 없습니다. 하지만 에이전트는 OAuth로 사용자를 인증하여 사용자 ID를 확인하고 대화를 맞춤설정하며 사용자를 대신하여 조치를 취할 수 있습니다.
이 대화 흐름에서 사용자는 계정에 크레딧을 추가하기로 선택하고, 상담사에게는 사용자의 신원을 확인하고 사용자의 알려진 정보를 가져온 다음 크레딧을 주문하라는 메시지가 표시됩니다.
- 사용자가 상담사와 대화를 시작합니다.
사용자가 응답을 입력하기 시작하면 에이전트에 입력 이벤트가 전송됩니다.
{ "agent": "brands/1111/agents/2222", "conversationId": "3333", "customAgentId": "oauth", "requestId": "1234567890", "userStatus": { "isTyping": "true", "createTime": "2020-10-02T15:01:23.045123456Z", }, "sendTime": "2020-10-02T15:01:24.045123456Z", }
사용자가 내 계정에 크레딧 5개를 메시지에 추가하려고 합니다.
{ "agent": "brands/1111/agents/2222", "conversationId": "3333", "customAgentId": "oauth", "requestId": "123123123", "message": { "messageId": "4444", "name": "conversations/12345/messages/67890", "text": "Hi, I'd like to add 5 credits to my account", "createTime": "2020-10-02T15:05:23.045123456Z", }, "context": { "entryPoint": "PLACESHEET", "userInfo": { "displayName": "Michael", "userDeviceLocale": "en", }, "resolvedLocale": "en", } "sendTime": "2020-10-02T15:05:24.045123456Z", }
상담사가 도와드리겠습니다. 계속 진행하려면 계정에 로그인하세요.
clientId
및scopes
는 OAuth 제공업체에서 정의합니다. 에이전트는 OAuth 제공업체의 요구사항에 따라codeChallenge
값을 생성합니다.curl -X POST "https://businessmessages.googleapis.com/v1/conversations/3333/messages" \ -H "Content-Type: application/json" \ -H "`oauth2l header --json path/to/service/account/key.json businessmessages`" \ -d "{ 'messageId': '5555', 'text': 'I can help you with that. Sign into your account to continue.', 'suggestions': [ { 'AuthenticationRequest': { 'clientId': 'oauth_client_id_1234567890', 'codeChallenge': 'code_challenge', 'scopes': [ 'account', 'billing', ], }, }, ], 'representative': { 'avatarImage': 'https://oauth.agent/bot-avatar.jpg', 'displayName': 'OAuth Agent', 'representativeType': 'BOT' } }"
사용자가 메시지를 수신하고 인증 요청 추천을 탭한 후 계정에 로그인합니다.
에이전트는
authenticationResponse.code
필드에 OAuth 승인 코드가 포함된 메시지를 수신합니다.{ "agent": "brands/1111/agents/2222", "conversationId": "3333", "customAgentId": "oauth", "requestId": "1234567895", "authenticationResponse": { "code": "fkhoe541658sfk684d135j186mngkjdrt5425415a2s1dfa68s4edf", }, } "sendTime": "2020-10-02T15:01:24.045123456Z", }
에이전트가 OAuth 제공업체와 통신하여 액세스 토큰의 승인 코드를 교환하고 사용자의 계정 정보를 가져옵니다.
상담사가 로그인해 주셔서 감사합니다. 현재 크레딧이 2개 있습니다. 확인하겠습니다. 계정에 크레딧 5를 추가하고 기본 결제 수단에 'Yes' 및 'No'를 제안하는 메시지로 청구하는 것이 좋습니다.
curl -X POST "https://businessmessages.googleapis.com/v1/conversations/3333/messages" \ -H "Content-Type: application/json" \ -H "`oauth2l header --json path/to/service/account/key.json businessmessages`" \ -d "{ 'messageId': '7777', 'text': 'Thanks for signing in. You currently have 2 credits. To confirm, you'd like to me to add 5 credits to your account and bill your default payment method?', 'suggestions': [ { 'reply': { 'text': 'Yes', 'postbackData': 'process-transaction', }, }, { 'reply': { 'text': 'No', 'postbackData': 'cancel-transaction', }, }, ], 'representative': { 'avatarImage': 'https://oauth.agent/bot-avatar.jpg', 'displayName': 'OAuth Agent', 'representativeType': 'BOT' } }"
사용자가 '예'인 추천 답장을 탭합니다.
{ "agent": "brands/1111/agents/2222", "conversationId": "3333", "customAgentId": "oauth", "requestId": "1234567898", "suggestionResponse": { "message": "conversations/333/messages/8888", "postbackData": "process-transaction", "createTime": "2020-10-02T15:01:26.045123456Z", "text": "Yes", "suggestionType": "REPLY", } "sendTime": "2020-10-02T15:01:27.045123456Z", }
에이전트는 OAuth 액세스 토큰을 사용하여 거래를 처리한 후 '좋음' 메시지를 보냅니다. 방금 계정에 크레딧 5개를 추가해 드렸습니다. 도움이 필요한 문제가 또 있으신가요?
curl -X POST "https://businessmessages.googleapis.com/v1/conversations/3333/messages" \ -H "Content-Type: application/json" \ -H "`oauth2l header --json path/to/service/account/key.json businessmessages`" \ -d "{ 'messageId': '9999', 'text': 'Great. I just added 5 credits to your account. Is there anything else I can help you with?', 'representative': { 'avatarImage': 'https://oauth.agent/bot-avatar.jpg', 'displayName': 'OAuth Agent', 'representativeType': 'BOT' } }"
사용자가 '아니요'를 전송합니다.
{ "agent": "brands/1111/agents/2222", "conversationId": "3333", "customAgentId": "oauth", "requestId": "123123133", "message": { "messageId": "4444", "name": "conversations/12345/messages/101010", "text": "No, thanks", "createTime": "2020-10-02T15:05:23.045123456Z", }, "context": { "entryPoint": "PLACESHEET", "userInfo": { "displayName": "Michael", "userDeviceLocale": "en", }, "resolvedLocale": "en", } "sendTime": "2020-10-02T15:05:28.045123456Z", }
상담사가 문의해 주셔서 감사합니다. 행복한 하루 보내세요!”
curl -X POST "https://businessmessages.googleapis.com/v1/conversations/3333/messages" \ -H "Content-Type: application/json" \ -H "`oauth2l header --json path/to/service/account/key.json businessmessages`" \ -d "{ 'messageId': '11111111', 'text': 'Thanks for contacting us. Have a great day!', 'representative': { 'avatarImage': 'https://oauth.agent/bot-avatar.jpg', 'displayName': 'OAuth Agent', 'representativeType': 'BOT' } }"