MS Bot Framework VideoCard - botframework

Can someone please explain how you use the MediaUrl for the VideoCard?
I've tried just adding the video url to the CardMedia which loads the media player but I can't play the video.
And whatever I try with MediaUrl I just get an error saying MediaUrl is not a funtion.
var url = new MediaUrl("Test", "https://www.youtube.com/watch?v=0i4v0Texqco");
var vid = new builder.Message(session)
.textFormat(builder.TextFormat.xml)
.attachments([
new builder.MediaCard(session)
.title("Test title")
.media([
builder.CardMedia.create(session, url)
])
]);
session.send(vid);
Thanks for any help!

For the Javascript solution the following code works pretty well, please note that it has been tested in bot framework emulator.
const {ActivityTypes } = require('botbuilder');
async playYoutube(context)
{
const reply = { type: ActivityTypes.Message };
reply.attachments = [this.getInlineAttachment()];
await context.sendActivity(reply);
}
get the object:
getInlineAttachment() {
return {
name: 'YoutubeVideo',
contentType: 'video/mp4',
contentUrl: 'https://www.youtube.com/watch?v=-2JRiv3Mycs'
}
hope this helps. Cheers

Per the VideoCard documentation and the MediaUrl documentation the url must be the one to the source of the video.
Using a YouTube URL in the VideoCard is not supported.
However, recently a "YouTube Card" was recently added to the WebChat/Emulator. If you are using WebChat, you might consider using that. See this and this for more information.

Related

TokBox screen sharing audio is not working

I'm using the TokBox / OpenTok screen sharing API for web browser, and when publishing a screen I'm using "publishAudio: true", but the subscriber does not receive any audio. The subscriber does receive the screen video though.
Does anyone know how to solve this audio issue? I'm using Google Chrome on macOS Catalina.
I need see more of you concrete case code but i hope this can help you.
You need to send the audioSource. Example:
if (videoSource) { // in my case, i'm using null or 'screen'
opts.videoSource = videoSource;
}
console.log('micStream getAudioTracks:');
console.log(micStream.getAudioTracks());
opts.audioSource = micStream.getAudioTracks()[0]; //you can choose you audio source
const target = document.getElementById(targetId);
const pub = OT.initPublisher(target, opts, err => {
if (err) {
console.log('err');
reject(err);
} else {
console.log('resolve');
resolve(pub);
}
});
I

How do I return a Typing activity from my v4 Bot

I'm trying to add a Typing activity to a long-running action in my bot, but I keep getting a "BadGateway" error. Most of the samples I've found seem to be for bot framework v3, so the types or methods don't appear any more, and I've tried a few options for v4 (using C#), like the following:
await turnContext.SendActivityAsync(new Activity() { Type = ActivityTypes.Typing });
or
var typingActivity = new Activity()
{
Type = ActivityTypes.Typing
//RelatesTo = turnContext.Activity
};
typingActivity.ApplyConversationReference(typingActivity.GetConversationReference());
or
var act2 = MessageFactory.Text(null);
act2.Type = ActivityTypes.Typing;
await turnContext.SendActivityAsync(act2);
all of these result in a BadGateway error.
Can someone guide me on where I'm going wrong?
Your implementation is close, but needs a couple minor adjustments. Also, the text property is optional. If it's not needed, then you can simply remove it (same for the delay). This is what I use which adheres to the documentation (variable is used to match your code). You can reference the docs here.
var typingActivity = new Activity[] {
new Activity { Type = ActivityTypes.Typing },
new Activity { Type = "delay", Value= 3000 },
//MessageFactory.Text("Some message", "Some message"),
};
await turnContext.SendActivitiesAsync(typingActivity, cancellationToken);
Hope of help!
The answer of Steven Kanberg has the right code, but unfortunately this is a service issue at the moment, as confirmed in this issue on Github.
When the issue is resolved, it should be posted in the Github issue above.
Please try out this code to send a typing activity from your bot:
protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
var typingActivity = MessageFactory.Text(string.Empty);
typingActivity.Type = ActivityTypes.Typing;
await turnContext.SendActivityAsync(typingActivity);
}

addFileAttachmentAsync() is not functioning as expected on Outlook Desktop on Windows 10 machine

I am trying to add inline image to mail body through Outlook Add-in. It works fine in OWA but Desktop app fails to attach it inline, instead I get the image as a regular attachment, and broken image icon on email body.
I contacted Microsoft Devchat, they don't seem to able to repro it, I tried the code they sent me , and it behaves the same.
Here is the code:
function AttCallback(asyncResult) {
if (asyncResult.status == Office.AsyncResultStatus.Failed) {
console.log(asyncResult.error);
} else {
var szCID = asyncResult.asyncContext.UniqueName;
var szAddBodyData = "<p>Here's a cute bird!</p><br><div><img src='cid:" + szCID + "'></div><br>";
Office.context.mailbox.item.body.setSelectedDataAsync(
szAddBodyData,
{ coercionType: Office.CoercionType.Html });
console.log("Attachment added");
}
}
function insertAttachment() {
var szName = "cute_bird.png";
var options = { isInline: true, ContentId: szName, 'asyncContext': { UniqueName: szName } };
//var options = { asyncContext: null };
Office.context.mailbox.item.addFileAttachmentAsync(
"http://i.imgur.com/WJXklif.png",
szName,
options,
AttCallback);
}
Here is what is happening on my machine.
Note: As you can see from the code, by the time callback function gets hit, attachment was already added. However I do have inline property set to true.
Has anyone experienced it before? Any suggestions would be appreciated.
See from the documentation:
https://learn.microsoft.com/en-us/office/dev/add-ins/reference/objectmodel/requirement-set-1.5/outlook-requirement-set-1.5
that inline image addition support shipped with Outlook requirement set 1.5. You should specify this capability in your manifest.xml to ensure your add-in is only appearing in clients where it can work and not show up if it can't.

Upload photos to Google Photos API - Error 500

I'm getting the error below while trying to upload media to Google Photos API, following the docs
This is how i retrieve my bytes array:
And this is how i make the request:
I've tried a lot of things and none of it work...
Note: I'm consuming other Google Photos API endpoints, such as Get Albums, Create Albums, Get Media and everything work as expected. The upload media is the only one i'm having trouble with.
Note 2: The token is being sent correctly.
Note 3: All the origin endpoints were configured in the google console (localhost included) so much so that other endpoints are working correctly.
Anyone can give me a light?
I am writing something similar in C# and was able to work with the photo api. My best advice is to double check headers. I hope this helps, additionally I added a postman screenshot of a successful call to the api:
public async Task<GoogleApiResponse> UploadPhoto(StorageFile photo)
{
var userInfo = UserInfoVault.GetUserInfo();
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", userInfo.AccessToken);
client.DefaultRequestHeaders.Add("X-Goog-Upload-File-Name", photo.DisplayName);
var fileStream = await photo.OpenAsync(FileAccessMode.Read);
var reader = new DataReader(fileStream.GetInputStreamAt(0));
await reader.LoadAsync((uint)fileStream.Size);
byte[] pixels = new byte[fileStream.Size];
reader.ReadBytes(pixels);
var httpContent = new ByteArrayContent(pixels);
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
HttpResponseMessage photoResponse = client.PostAsync(ApiEdnpoints.UploadPhoto, httpContent).Result;
string strResponse = await photoResponse.Content.ReadAsStringAsync();
return null;
}
Postman screenshot of successful call to upload a photo

Is it possible to launch native apps using Microsoft bot framework?

I am creating a Cortana skill on the Cortana canvas, I have a button.
I wanted to know if it possible to have an 'imback' type of button to open a webpage.
Ye, for example
var message = context.MakeMessage() as IMessageActivity;
message.ChannelData = JObject.FromObject(new
{
action = new { type = "LaunchUri", uri = "skype:echo123?call" }
});
await context.PostAsync(message);
this code will start a call with echo123 user on skype
Reference: https://learn.microsoft.com/en-us/cortana/tutorials/bot-skills/bot-entity-channel-data
You can supply an openUrl to a card action, or even use ChannelData to send a LaunchUri command, deep linking to an application. (I haven't tried this, but I assume 'http://websitename.com' will launch in the Cortana host platform's default browser.)
activity.ChannelData = new {
action = new { type = "LaunchUri", uri = "http://websitename.com"}
};

Resources