question

Rajeev Garg avatar image
Rajeev Garg asked Rajeev Garg commented

Post TeamMessaging on behalf of others (Impersonate messages)

Hi,

We are using User token \ Bot token to post the message using chatId.
When Bot token is used it is posted as the Bot and with User access token the message is shown that as the User posted the message.

For a particular use case we want to show the message is posted from an external user and not from Bot \ User
Is that possible to change the display name and avatar when we post the message ?


We created incoming webhooks using REST API to post the message . But it shows incoming webhook icon and name as below
1634563801665.png

Can we customize the icons and avatar ?

Thanks,

Raja



webhooks
1634563801665.png (12.1 KiB)
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Phong Vu avatar image
Phong Vu answered Rajeev Garg commented

Make the body of your post like this

var body = {
    icon: "http://www.somedomain.com/icons/avatar.png", // publicly accessible
    activity: "Display name ABC",
    title: "Some title",
    body: "Your message"
  }
3 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Rajeev Garg avatar image Rajeev Garg commented ·

Thanks @Phong Vu ,
We can able to change the displayName but icon is still showing from incoming webhook.
We created the incoming webhook using REST API with Bot Token.
1634628346360.png

Payload for the incoming webhook :

{

"icon":"https://i.stack.imgur.com/l60Hf.png",

"activity": "Jack",

"body": "Your message",

"text": "Welcome"

}

Note: It is not working for posting message through REST API.

Is there anything we need to add to change the image\icon ?

0 Likes 0 ·
1634628346360.png (7.5 KiB)
Phong Vu avatar image Phong Vu ♦♦ Rajeev Garg commented ·

You mentioned using incoming webhook, why did you use the REST post API? No, using the API is not possible to fake the avatar and name.

0 Likes 0 ·
Rajeev Garg avatar image Rajeev Garg Phong Vu ♦♦ commented ·

Hi @Phong Vu , We can create incoming webhooks in two ways,

Approach 1 : Through incoming webhooks app (Manual Way)
1.1 User has to manually add the app to the desired channel and share the incoming webhook.
1.2 For the webhook created in this way, the above payload is working good.
1634662162469.png

Approach 2. Through REST API (Automated way)
2.1 Bot app calls the following end point and gets the incoming webhook url in the response
POST https://platform.ringcentral.com/restapi/v1.0/glip/groups/<group-id>/webhooks

2.2 For the webhook created in this way, with the above payload the icon is not changing
1634662960060.png


. We are more interested on Approach 2 as it automates the flow.
Could you please help us to change the icon for the Approach 2


0 Likes 0 ·
1634662162469.png (6.2 KiB)
1634662960060.png (6.8 KiB)

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys