How to Add Call-to-Action Button Inside Tweets via Twitter API - twitter

Will be very thankful if somebody could share their experience how to add call-to-action button inside tweets which posted through Twitter API:
POST statuses/update
Expected result
Subscribe button inside tweet
After clicking on this button Subscription dialog appears
Thanks for any help

https://dev.twitter.com/ads/reference/post/accounts/%3Aaccount_id/cards/website
{
"data": {
"name": "Test Website Card 1",
"id": "g9z",
"preview_url": "https://cards.twitter.com/cards/abc1/g9z",
"created_at": "2014-05-18T21:29:18Z",
"card_type": "WEBSITE",
"updated_at": "2014-05-18T21:29:18Z",
"website_cta": "READ_MORE",
"account_id": "abc1"
},
"data_type": "card",
"request": {
"params": {
"name": "Test Website Card 1",
"card_type": "WEBSITE",
"account_id": "abc1",
"image": "https://pbs.twimg.com/peacock/398520248267071488/image.jpg",
"website_url": "https://support.twitter.com/",
"website_title": "Twitter Help Center",
"website_cta": "SUBSCRIBE",
}
}
}
enter code here
The bottom line, "website_cta": "SUBSCRIBE", will set the call-to-action (cta) to subscribe.

Related

Microsoft Teams: Messaging extension on query result select item is not invoked on iOS

I'm building a Microsoft Teams bot with Compose Extension (Search extension) functionality. As soon as the user opens the search extension it fetches results from the backend. I'm using thumbnail cards to show the result list. I have also added tap functionality into thumbnail cards. That means when a user selects a result a backend invoke call will be triggered with some specific data and with that data I build an adaptive card.
This feature works well in Teams mac, web, and android apps. But with the native iOS app, the invoke call is never triggered when a user selects a result. Instead, it sends a thumbnail card on the Teams compose area.
This is the response I'm building for the Search extension
{
"composeExtension": {
"type": "result",
"attachmentLayout": "list",
"attachments": [
{
"contentType": "application/vnd.microsoft.card.thumbnail",
"content": {
"images": [
{
"url": "https://localhost:8080/Public/img3-a68ff7.jpeg"
}
],
"subtitle": "Thumbnail card subtitle",
"tap": {
"type": "invoke",
"value": {
"type": "IDEA_SELECT_CALLBACK",
"selectedItemId": 7082
}
},
"text": "Thumbnail card text",
"title": "Title"
}
}
]
}
}
image from ios where a thumbnail card is thrown in compose area
ideal result from PC/mac where invoke command triggered and the adaptive card is built
Mac/PC screenshots
Android screenshots
iOS screenshots
Code example from ms github
Well, I have made some changes to the response object. I've added the review property and instead of setting tap to the content, I'm setting it to the review. Doing so, invoke is triggered on selecting a search result but it also pastes the Hero Card on the compose area on my iOS device.
Here is the exact same response I'm building...
{
"composeExtension": {
"type": "result",
"attachmentLayout": "list",
"attachments": [
{
"contentType": "application/vnd.microsoft.card.thumbnail",
"content": {
"images": [
{
"url": "https:/localhost/93/937083/Public/img3-a68ff7.jpeg"
}
],
"subtitle": "Subtitle",
"text": "Sample text",
"title": "Thumbnail card title"
},
"preview": {
"contentType": "application/vnd.microsoft.card.hero",
"content": {
"buttons": null,
"images": [
{
"url": "https:/localhost/93/937083/Public/img3-a68ff7.jpeg"
}
],
"subtitle": "Subtitle",
"tap": {
"type": "invoke",
"value": {
"type": "SELECT_CALLBACK",
"selectedItemId": 1001
}
},
"text": "Sample text",
"title": "Thumbnail card title"
}
}
}
]
}
}
hero card on the compose area and adaptive card on the background built by invoked value

Microsoft Graph API - send message in channel by using team tagging

This graph API send a message in the channel
POST https://graph.microsoft.com/v1.0/teams/{team-id}/channels/{channel-id}/messages
{
"body": {
"content": "Hello world"
}
}
Also, following the docs from https://learn.microsoft.com/en-us/graph/api/resources/chatmessagemention?view=graph-rest-1.0 I can mention user, channel or team
But I am looking for how I can mention Tags while sending message in a channel.
After doing some research, came up with a solution thought of posting here for others:
Graph API
POST https://graph.microsoft.com/v1.0/teams/{team-id}/channels/{channel-id}/messages
Body here is critical
{
"subject": "This is very urgent!",
"importance": "urgent",
"body": {
"contentType": "html",
"content": "Programatically mentioning of Tagged users <at id=\"0\">String_1234</at>"
},
"mentions": [
{
"id": 0,
"mentionText": "String_1234",
"mentioned": {
"tag": {
"#odata.type": "#microsoft.graph.teamworkTagIdentity",
"id": "", //tag id
"displayName": "" //tag name
}
}
}
]
}

Slack Bot Interactive Message. Showing "Oh no, something went wrong. Please try that again." on button click

I have a slack bot where I am sending structured message using Tester on chat.postMessage() using Developer account for Slack App.
Message gets sends smoothly, but when button is clicked it shows-
"Oh no, something went wrong. Please try that again." in the chat window and nothing recieved on Interactive Message Request URL.
I am out of clue what is happening, Any help will be appreciated.
Message attachment
[
{
"title": "The Further Adventures of Slackbot",
"fields": [
{
"title": "Volume",
"value": "1",
"short": true
},
{
"title": "Issue",
"value": "3",
"short": true
}
],
"author_name": "Stanford S. Strickland",
"author_icon": "http://a.slack-edge.com/7f18/img/api/homepage_custom_integrations-2x.png",
"image_url": "http://i.imgur.com/OJkaVOI.jpg?1"
},
{
"title": "Synopsis",
"text": "After #episod pushed exciting changes to a devious new branch back in Issue 1, Slackbot notifies #don about an unexpected deploy..."
},
{
"fallback": "Would you recommend it to customers?",
"title": "Would you recommend it to customers?",
"callback_id": "comic_1234_xyz",
"color": "#3AA3E3",
"attachment_type": "default",
"actions": [
{
"name": "recommend",
"text": "Recommend",
"type": "button",
"value": "recommend"
},
{
"name": "no",
"text": "No",
"type": "button",
"value": "bad"
}
]
}
]
it is sorted now. Actually I was using wrong token, test token, where a bot access token or user access token obtained through the app's OAuth flow must be used.

Bot User Events API for Direct Messages

I created a slack app with a Bot User that uses the Events API to listen to messages in channels the bot hangs out.
Oauth scope: bot,chat:write:bot
I subscribed to the following Bot Events:
message.channels
message.groups
message.im
message.mpim
When I invite my bot to join a channel, I receive a POST request as follows:
{
[...]
"event": {
"user": "U24BYHV19",
"inviter": "U03BN91GN",
"text": "<#U24BYHV19|my_bot> has joined the channel",
"type": "message",
"subtype": "channel_join",
"ts": "1472139425.000019",
"channel": "C24UWQE85",
"event_ts": "1472139425.000019"
},
"type": "event_callback",
[...]
}
When I send a message in a channel where the bot hangs out, I receive a POST request as follows:
{
[...]
"event": {
"type": "message",
"user": "U03BN91GN",
"text": "hello <#U24BYHV19>",
"ts": "1472139444.000021",
"channel": "C24UWQE85",
"event_ts": "1472139444.000021"
},
"type": "event_callback",
[...]
}
When I send a direct message to my bot, I receive a POST request as follows:
{
[...]
"event": {
"type": "message",
"user": "U03BN91GN",
"text": "hello pager",
"ts": "1472139450.000032",
"channel": "D24DC8UTG",
"event_ts": "1472139450.000032"
},
"type": "event_callback",
[...]
}
The problem is, how can I determine that someone is talking to my bot via direct message? :) Because I want to respond if someone talks to my bot.
Channels of Direct Messages start with an D instead of an C.

How to get larger thumbnails for Facebook page link posts?

I've been successfully fetching only photos posted at my Facebook page via Opengraph api and now I want to display some links shared at the page through the similar method that I've been using to fetch photos.
The problem is that type=link posts don't contain object_id, which can be used to fetch a bigger thumbnail for photos like https://https://graph.facebook.com/<%= post['object_id'] %>/picture. What a type=link post returns is as follows.
Response
"id": "127100524044142_757791214308400",
"from": { ... },
"to": { ... },
"message": "...",
"message_tags": { ... },
"picture": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQA5ofIEKR1dK6_T&w=158&h=158&url=http\u00253A\u00252F\u00252Fyeondoo.kr\u00252Fassets\u00252Fstaffs-88e474e70d16794e898d5f4bb200f710.jpg",
"link": "...",
"name": "...",
"caption": "...",
"description": "...",
"icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yD/r/aS8ecmYRys0.gif",
"privacy": {
"value": ""
},
"type": "link",
"status_type": "shared_story",
"created_time": "2015-01-25T06:08:11+0000",
"updated_time": "2015-01-25T07:54:28+0000",
"likes": { ...
],
"paging": { ... }
},
"comments": { ...
],
"paging": { ... }
}
I could get the url for "small" thumbnails via picture property, but this is too small to display on the website. Is there any solution to get a larger thumbnail for Facebook page, if that matters although I don't think it would, link posts via Opengraph API?
I happen to find a field which is not specified as default. It is full_picture and it returns the url for the "larger" thumbnail.
/posts?fields=full_picture
"full_picture": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQBHe3GKoga49ZHw&url=http%3A%2F%2Fyeondoo.kr%2Fassets%2Fstaffs-88e474e70d16794e898d5f4bb200f710.jpg",
"id": "127100524044142_757791214308400",
"created_time": "2015-01-25T06:08:11+0000"

Resources