उपयोगकर्ता की पुष्टि करें

आम तौर पर, एजेंट को उन उपयोगकर्ताओं के बारे में थोड़ी-बहुत जानकारी होती है जिनसे वे अलग से बातचीत करते हैं उस जानकारी से लिया जाता है जो उपयोगकर्ता बातचीत के दौरान देते हैं. हालांकि, एजेंट ये काम कर सकते हैं 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 की सेवा देने वाली कंपनी तय करती है. एजेंट 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'
      }
    }"
    
  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. एजेंट "साइन इन करने के लिए धन्यवाद. फ़िलहाल, आपके पास दो क्रेडिट हैं. यहां की यात्रा पर हूं पुष्टि करें, तो आपको मुझसे आपके खाते में 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': '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 ऐक्सेस टोकन का इस्तेमाल करके लेन-देन को प्रोसेस करता है. इसके बाद, और मैसेज मिला "बहुत बढ़िया. मैंने आपके खाते में पांच क्रेडिट जोड़े हैं. क्या यहां है क्या आपको कोई और मदद चाहिए?".

    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. इसके बाद, उपयोगकर्ता "नहीं, रहने दें" भेजता है.

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