Hi Ramjot,
Thanks for the pointers shared so far; we are able to successfully read chat messages from the Graph Subscription API, across tenants.
However, the ID of the user who posted the chat message is not available in the chat message payload. This is required for our app to respond to this user (privately). Refer to the Graph Subscription payload below as opposed to payload of messages with RSC using Teams Bot API.
Payload using Graph Subscription API (does NOT contain user identifier):
{
value: [
{
subscriptionId: 'ae--------------',
changeType: 'created',
clientState: null,
subscriptionExpirationDateTime: '2021-09-23T04:08:45-07:00',
resource: "teams('9d----------------')/channels('19:a-----------@thread.tacv2')/messages('16------')/replies('16-------')",
resourceData: {
id: '16----------',
'@odata.type': '#Microsoft.Graph.chatMessage',
'@odata.id': "teams('9d--------------')/channels('19:a---------@thread.tacv2')/messages('16-----')/replies('16---------')"
},
encryptedContent: {
data: 'qVuJB/PkQaKAbqp+zpxTm0hsQiDGUemanHuW1Y',
dataSignature: 'JM---------------',
dataKey: 'mtg--------------------',
encryptionCertificateId: '------',
encryptionCertificateThumbprint: 'B---------------------'
},
tenantId: '8-------------------'
}
],
validationTokens: [
'eyJ0eXAiOiJ----------------'
]
}
Payload with RSC using Teams Bot API (contains user identifier):
TurnContext {
_respondedRef: { responded: false },
_turnState: TurnContextStateCollection [Map] {
Symbol(BotIdentity) => ClaimsIdentity { claims: [Array], authenticationType: true },
Symbol(ConnectorClient) => ConnectorClient {
_withCredentials: false,
_httpClient: [AxiosHttpClient],
_requestPolicyOptions: [RequestPolicyOptions],
_requestPolicyFactories: [Array],
baseUri: 'https://smba.trafficmanager.net/in/',
requestContentType: 'application/json; charset=utf-8',
credentials: [MicrosoftAppCredentials],
attachments: [Attachments],
conversations: [Conversations]
},
Symbol(OAuthScope) => 'https://api.botframework.com',
'botCallbackHandler' => [AsyncFunction],
turn: { locale: 'en-GB' }
},
_onSendActivities: [],
_onUpdateActivity: [],
_onDeleteActivity: [],
_turn: 'turn',
_locale: 'locale',
bufferedReplyActivities: [],
_adapter: BotFrameworkAdapter {
middleware: MiddlewareSet { middleware: [Array] },
BotIdentityKey: Symbol(BotIdentity),
ConnectorClientKey: Symbol(ConnectorClient),
OAuthScopeKey: Symbol(OAuthScope),
TokenApiClientCredentialsKey: Symbol(TokenApiClientCredentials),
settings: {
appId: '42--------------------',
appPassword: '0------------------',
channelService: undefined,
openIdMetadata: undefined
},
credentials: MicrosoftAppCredentials {
refreshingToken: null,
appId: '42-------------------------',
_tenant: 'botframework.com',
_oAuthEndpoint: 'https://login.microsoftonline.com/botframework.com',
authenticationContext: [AuthenticationContext],
_oAuthScope: 'https://api.botframework.com',
tokenCacheKey: '42-------------------https://api.botframework.com-cache',
appPassword: '0-------------------------'
},
credentialsProvider: SimpleCredentialProvider {
appId: '42-------------------',
appPassword: '0----------------4'
},
isEmulatingOAuthCards: false,
authConfiguration: AuthenticationConfiguration {
requiredEndorsements: [],
validateClaims: undefined
},
turnError: [AsyncFunction]
},
_activity: {
text: '<at>converseBot2-local-debug</at> intro \n',
textFormat: 'plain',
attachments: [ [Object] ],
type: 'message',
timestamp: 2021-09-23T10:52:07.986Z,
localTimestamp: 2021-09-23T10:52:07.986Z,
id: '16**********',
channelId: 'msteams',
serviceUrl: 'https://smba.trafficmanager.net/in/',
from: {
id: '29:1mOwl*************************',
name: 'FNU LNU',
aadObjectId: 'd4*******************'
},
conversation: {
isGroup: true,
conversationType: 'channel',
tenantId: '8f*****************',
id: '19:a********************@thread.tacv2;messageid=16********'
},
recipient: {
id: '28:42******************2',
name: 'converseBot2-local-debug'
},
entities: [ [Object], [Object] ],
channelData: {
teamsChannelId: '19:a*******************@thread.tacv2',
teamsTeamId: '19:0*******************@thread.tacv2',
channel: [Object],
team: [Object],
tenant: [Object]
},
locale: 'en-GB',
localTimezone: 'Asia/Calcutta',
rawTimestamp: '2021-09-23T10:52:07.9862382Z',
rawLocalTimestamp: '2021-09-23T16:22:07.9862382+05:30',
callerId: 'urn:botframework:azure'
}
}