1
votes

Messages delivered from Bot Framework don't have name property in from object if message was sent by user who doesn't have username and full name. For example if you delete first or last name from profile like that

example of profile

Here's example of json that I get for messages sent from user that only has first name (look at from object):

{
  "channelData": {
    "message": {
      "chat": {
        "all_members_are_administrators": true,
        "id": -219911672,
        "title": "jlarky-dev",
        "type": "group"
      },
      "date": 1493246056,
      "from": {
        "first_name": "Test",
        "id": 107390199
      },
      "message_id": 100,
      "text": "test"
    },
    "update_id": 66470785
  },
  "channelId": "telegram",
  "conversation": {
    "id": "-219911672",
    "isGroup": true,
    "name": "jlarky-dev"
  },
  "entities": [
    {
      "mentioned": {
        "id": "JLarkyTestBot",
        "name": "jlarky_test"
      },
      "text": "JLarkyTestBot",
      "type": "mention"
    }
  ],
  "from": {
    "id": "107390199"
  },
  "id": "KxBlE8JsLfg",
  "recipient": {
    "id": "JLarkyTestBot",
    "name": "jlarky_test"
  },
  "serviceUrl": "https://telegram.botframework.com",
  "text": "test",
  "timestamp": "2017-04-26T22:34:17.4109674Z",
  "type": "message"
}
1
I can't get the question. Anyhow, the name property comes to the ChannelData not in from object. - OmG
@OmG from object always has id and name except in case of some bugs like this one, channelData is channel (third party service) specific data that bot framework sends you. - JLarky
So, you can get the name from ChannelData as you can see in the result. - OmG
use channelData.from.first_name - nilsw
@NilsW yes, I think that is probably the best way to go here, still would be cool to see this bug fixed. - JLarky

1 Answers

2
votes

Since @NilsW's comment I tested this again and it looks like from.name only exists when username of telegram profile was set (same can be looked up from channelData.message.from.username), so I guess it makes sense for it not to show username when username was not set :) and not having last_name part was not related here.