Redirecting to Bot from URL - json

I am working on a .Net core Bot application where I have created an adaptive card and when user clicks it would be redirected to a new URL. Once, redirected I want to add a functionality that after user posts in the URL, he should be redirected back to the BOT with the posted data. Can anyone guide me how to approach this. Below is the sample JSON we have created for redirecting user to URL.
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"text": "This card's action will open a URL"
}
],
"actions": [
{
"type": "Action.OpenUrl",
"title": "Action.OpenUrl",
"url": "https://adaptivecards.io"
}
]
}

if you are asking about a Teams bot then you should follow the pattern for a Bot Task Module
Bot message + Card
Activate Task module (aka pop-up window)
task module can display another Adaptive Card
or a HTML page
Task Module completes and sends back info to your bot using task/submit

Related

Slack JSON - Custom Bot Username and Icon

I'm looking to send out a Post json request using Zapier's webhook function, together with Slack's incoming webhook set up.
I'm using block kit to develop the message style, and so far that's worked great. However, I'd like my bot to display with a custom username and emoji/icon and I'm having trouble.
Here is the JSON payload I'm trying, based off this tutorial https://api.slack.com/methods/chat.postMessage#args
The post seems to ignore the first two lines and posts as the standard bot name
{
"as_user": false,
"username": "test",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*78 Varet St #14*\n 2 Bed / $2300 \n <#ben> \n 3rd Deposit This Month"
},
"accessory": {
"type": "image",
"image_url": "https://p.sharinpix.com/3/3521a32/YXBwLnNoYXJpbnBpeC5jb20vaW1hZ2VzL2I2M2RkZTY4LWZkMDMtNGZlYy04OGUxLWYwZjA0N2E4NjQ3NS90aHVtYm5haWxzL29yaWdpbmFsLWI5MTdlNzAzY2U2LmpwZw/77-varet-st-building.jpg?timestamp=1639154285",
"alt_text": "cute cat"
}
},
{
"type": "divider"
}
]
}
Any help would be greatly appreciated!
If you just want to modify the icon and name of your bot ( will be the same throughout the app ), you should be able to do that on https://api.slack.com/apps/{YOUR_APP_ID}/general? under the Display Information section.
If you want to be able to change it from message to message, you will have to grant your app additional permissions scopes. See https://api.slack.com/methods/chat.postMessage#authorship

In MS Team Adaptive Card, how do I specify the server it post to?

I am trying to use Action.Submit in my adaptive card to hit my Google Cloud Function. Where do I specify where to send the submission to? The reason I am doing this is I want to skip building a full chat server due to time constraint.
Example of Adaptive Card, no property to specify post URL:
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"text": "Present a form and submit it back to the originator"
},
{
"type": "Input.Text",
"id": "firstName",
"placeholder": "What is your first name?"
},
{
"type": "Input.Text",
"id": "lastName",
"placeholder": "What is your last name?"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Action.Submit",
"data": {
"x": 13
}
}
]
}
Adaptive cards aren't developed specifically for bot service.
so working with them needs some tricks , in your case if you are trying to send a request that contain adaptive card inputs you need to know :
when the user click the submit button the adaptive card will send a message to bot activity handler on behalf of the user, this message contains a JSON object (you can view this object by adding this line in the bot onMessage function.
console.log(context.activity)
you can get the data from this meesage by using :
context.activity.value.firstName (to get the firstName sent by the adaptive card)
Now you can send your request to the server i prefer using Axios .

imback functionaliy not returning value to the bot

I am trying to show some adaptive card buttons when loading the bot.
It is displaying title in the bot. When clicking on title it is returning null to the bot. I want to submit value mentioned in msteams to be submitted.
Code:
{
"type": "Action.Submit",
"title": "Click me for imBack",
"data": {
"msteams": {
"type": "imBack",
"value": "Text to reply in chat"
}
}
}
My new blog post may clear up some things about how to use Adaptive Cards with the Bot Framework: https://blog.botframework.com/2019/07/02/using-adaptive-cards-with-the-microsoft-bot-framework/
Of particular interest should be the Submit Actions section. You can see that your submit action's data has to be a string in order to trigger the imBack behavior. Your action could look like this:
{
"type": "Action.Submit",
"title": "Click me for imBack",
"data": "Text to reply in chat"
}
This will only work if you don't have any input fields in your card. If you want to have both input fields and imBack submit actions, use multiple cards.
Please remember to add action ID and title, see the following:
"selectAction": {
"type": "Action.Submit",
"id": "0",
"title": "action0",
"data": {
"DataParam": " DataValue"
}
}
In addition when related actions and card elements does not contain ID Teams mobile client will ignore those cards and won't display them at all.

Can embeded browser (chrome) use GCM for Push Notification

I have embeded browser in my windows application using CEF.Can this browser which is rendered in my application window, use GCM(google cloud messaging) for receiving Push notification.
You may want to check the documentation about Web Push Notifications. Push is based on service workers because service workers operate in the background. This means the only time code is run for a push notification (in other words, the only time the battery is used) is when the user interacts with a notification by clicking it or closing it. If you're not familiar with them, check out the service worker introduction.
With a service worker registration you call showNotification on a registration object.
serviceWorkerRegistration.showNotification(title, options);
The title argument appears as a heading in the notification. The options argument is an object literal that sets the other properties of a notification. A typical options object looks something like this:
{
"body": "Did you make a $1,000,000 purchase at Dr. Evil...",
"icon": "images/ccard.png",
"vibrate": [200, 100, 200, 100, 200, 100, 400],
"tag": "request",
"actions": [
{ "action": "yes", "title": "Yes", "icon": "images/yes.png" },
{ "action": "no", "title": "No", "icon": "images/no.png" }
]
}
Check this documentation for additional information.

Graph API: Check if feed post was made by a Page or User

When using the /page/feed endpoint in the Facebook Graph API I can't figure out how to know if the post was made by a Page or a User
Here's how I call the endpoint right now:
HTTP GET https://graph.facebook.com/v2.8/{page_id}/feed?fields=is_published,from,message
This yields the following JSON response:
{
"data": [
{
"from": {
"name": "Chad Smith", # <-- This is a User
"id": "806273209398023"
},
"message": "A really magical place! Best Christmas...",
"id": "103988597020_1445496708809010"
},
{
"from": {
"name": "Tivoli", # <-- This is a Page
"id": "103988597020"
},
"message": "Hello everybody...",
"id": "103988597020_10154040865527021"
},
]
}
How can I know if the post was from a Page or User without making additional API calls? I've tried using subfields, but can't figure out if they work on the from field.
I solved it by using ?fields=from{name,about} and marking it as a Page if the from JSON contains about.
This is not the best solution, but about is currently the only subfield of from that doesn't fail on User. (e.g. if I was using ?fields=from{fan_count} the Graph API will fail for posts made by User objects.