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

आम तौर पर, एजेंट को उन उपयोगकर्ताओं के बारे में कम जानकारी मिलती है जिनसे वे बातचीत के दौरान मिली जानकारी के अलावा, बातचीत करते हैं. हालांकि, एजेंट उपयोगकर्ताओं की पहचान की पुष्टि करने, बातचीत को मनमुताबिक बनाने, और उपयोगकर्ताओं की ओर से कार्रवाई करने के लिए, उपयोगकर्ताओं को 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. उपयोगकर्ता किसी मैसेज को कोट करके, मेरे खाते में पांच क्रेडिट जोड़ता है.

    {
      "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 फ़ील्ड में OAuth अनुमति कोड के साथ एक मैसेज मिलता है.

    {
      "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 ऐक्सेस टोकन का इस्तेमाल करके लेन-देन को प्रोसेस करता है और फिर मैसेज और कोटेशन भेजता है. मैंने अभी आपके खाते में 5 क्रेडिट जोड़े हैं. क्या आपको Shorts की मदद से मदद चाहिए?

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