אימות המשתמש

בדרך כלל, לנציגים אין הרבה תובנות לגבי המשתמשים שהם מתקשרים איתם, מלבד המידע שהמשתמשים מוסרים במהלך שיחה. עם זאת, הנציגים יכולים לאמת משתמשים באמצעות OAuth כדי לאמת את זהות המשתמש, להתאים אישית שיחות ולבצע פעולות בשם המשתמשים.

בתהליך השיחה הזה, המשתמש בוחר להוסיף זיכויים לחשבון שלו, והסוכן מבקש מהמשתמש להיכנס כדי לאמת את זהות המשתמש, לאחזר מידע ידוע על המשתמש ולבצע הזמנה לזיכויים.

  1. המשתמש יתחיל את השיחה עם הנציג.
  2. כשהמשתמש מתחיל להקליד תגובה, הוא שולח אירוע הקלדה לסוכן.

    {
      "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",
    }
    
  3. המשתמש שולח "שלום, אני רוצה להוסיף 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",
    }
    
  4. הנציג ישלח לך &ציטוט. אשמח לעזור. היכנסו לחשבון שלכם כדי להמשיך.

    clientId ו-scopes מוגדרים על ידי ספק ה-OAuth. הנציג יוצר את הערך codeChallenge בהתאם לדרישות של ספק OAuth.

    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'
      }
    }"
    
  5. המשתמש מקבל את ההודעה, מקיש על ההצעה לבקשת האימות ונכנסים לחשבון שלו.

  6. נציג התמיכה יקבל הודעה עם קוד האימות בשדה authenticationResponse.code.

    {
      "agent": "brands/1111/agents/2222",
      "conversationId": "3333",
      "customAgentId": "oauth",
      "requestId": "1234567895",
      "authenticationResponse": {
        "code": "fkhoe541658sfk684d135j186mngkjdrt5425415a2s1dfa68s4edf",
        },
      }
      "sendTime": "2020-10-02T15:01:24.045123456Z",
    }
    
  7. הנציג יוצר קשר עם ספק ה-OAuth, מחליף את קוד ההרשאה של אסימון הגישה ומאחזר את פרטי החשבון של המשתמש.

  8. הנציג שולח "תודה על הכניסה לחשבון. נכון לעכשיו יש לך 2 זיכויים. כדי לאשר, אתם רוצים שאוסיף 5 זיכויים לחשבון שלכם ונחייב את אמצעי התשלום המוגדר כברירת מחדל, {/4}כהודעה עם הצעות כמו כן.

    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'
      }
    }"
    
  9. המשתמש מקיש על ה &הצעה; כן" התשובה המוצעת.

    {
      "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",
    }
    
  10. הסוכן מעבד את העסקה באמצעות אסימון הגישה של 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'
      }
    }"
    
  11. המשתמש שולח "No, thank".

    {
      "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",
    }
    
  12. הנציג שולח "תודה שפנית אלינו. שיהיה לך יום מצוין!"

    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'
      }
    }"