I tried below code blocks to show videos :
dispatcher.utter_message(attachment = "https://www.youtube.com/embed/-F6h43DRpcU")
dispatcher.utter_message(video = "https://www.youtube.com/embed/-F6h43DRpcU")
dispatcher.utter_attachment(attachment = "https://www.youtube.com/embed/-F6h43DRpcU")
dispatcher.utter_attachment(attachment={
"type": "video",
"payload": {
"title": "Watch Below Video",
"src": "https://www.youtube.com/embed/-F6h43DRpcU"
}
})
but none of these worked.
what is correct format to get video as a response in rasa chat?
Related
I am having trouble creating a video ad on AdVideos platform. I am able to successfully create campaigns, ad sets, and ads, but am encountering an error #1487713 when uploading a specific 15-second MP4 video from Google Drive. Some other videos have uploaded successfully. What could be causing this issue and how can I resolve it?
When creating the video with the API/ using that id for the ad, i dont get any errors (i get a advideo ID back). only when i navigate to the business campaign manager it gives me the error "#1487713 check if your video is in the right format and try again"
here is the code im using to test, again some videos DO work (all around 10-20 seconds)
# creates advideo
params = {
"name": "TEST",
"file_url": drive_url_to_download(video_url),
"title": "TEST",
}
url = f"https://graph.facebook.com/v15.0/{act}/advideos?access_token={fb_token}"
rr = requests.post(url, params=params)
print(rr.json(), rr.status_code)
# exit()
# creates a campaign
campaign_params = {
"name": "TEST",
"objective": "REACH",
"status": "PAUSED",
"special_ad_categories": ["NONE"],
}
url = f"https://graph.facebook.com/v15.0/{act}/campaigns?access_token={fb_token}"
r = requests.post(url, params=campaign_params)
print(r.json())
adset_params = {
"name": "TEST",
"campaign_id": r.json()["id"],
"billing_event": "IMPRESSIONS",
"optimization_goal": "REACH",
"bid_amount": "100",
"daily_budget": "1000",
"targeting": str({
"geo_locations": {
"custom_locations": [
{
"address_string": "someaddr",
"radius": "5",
"distance_unit": "kilometer"
},
]
},
"facebook_positions": ["feed", "video_feeds", "instant_article", "marketplace", "video_feeds", "story", "search"],
}),
"status": "PAUSED",
}
url = f"https://graph.facebook.com/v15.0/{act}/adsets?access_token={fb_token}"
r = requests.post(url, params=adset_params)
print(r.json())
# create ad with video
ad_params = {
"name": "TEST",
"adset_id": r.json()["id"],
"creative": str({
"name": "TEST333",
"object_story_spec": {
"page_id": "someid",
"video_data": {
"image_url": "someurl",
"call_to_action": {
"type": "NO_BUTTON",
},
"title": "TEST",
"message": "TEST",
"video_id": rr.json()["id"]
}
}
}),
"status": "PAUSED",
}
what is going on??
1.We are debugging our smart home camera stream using Google Nest Hub.
2.We have access to device sync and passed the validator.This is our Device Sync response:
{
"payload": {
"agentUserId": "b4ad4e18-ab90-4b0e-bc02-264da5bb6469",
"devices": [{
"traits": ["action.devices.traits.CameraStream"],
"name": {
"defaultNames": ["Imilab"],
"name": "camera1",
"nicknames": ["camera1"]
},
"attributes": {
"cameraStreamNeedAuthToken": false,
"cameraStreamSupportedProtocols": ["hls"],
"cameraStreamNeedDrmEncryption": false
},
"id": "gejiayu2",
"type": "action.devices.types.CAMERA",
"deviceInfo": {
"model": "a1znn6t1et8",
"manufacturer": "Imilab"
}
}]
},
"requestId": "8664974301718985362"
}
3.We provide the HLS address, which can be played normally using ffplay ffplay info or HTML, This is our demo HLS URL: https://cdn.cnbj2.fds.api.mi-img.com/cloud-storage-test/test1.m3u8.
4.But we can't use Google Nest Hub to play it. I recorded the debug video in the attachment. This is our camera stream response:
{
"payload": {
"commands": [{
"ids": ["gejiayu2"],
"status": "SUCCESS",
"states": {
"cameraStreamReceiverAppId": "",
"cameraStreamAuthToken": "",
"cameraStreamAccessUrl": "https://cdn.cnbj2.fds.api.mi-img.com/cloud-storage-test/test1.m3u8"
}
}]
},
"requestId": "1625829984244045201"
}
I have tested Google Home and Google Home Mini and neither is capable of playing HLS streams. Our radio station is in the TuneIn database which supplies Google devices with radio streams. Our Icecast streams work but not HLS streams. So I'm sure that your Google Nest Hub has the same lack of ability to play HLS.
Magento version 2.2.5
Endpoint in question /V1/products/{sku}/media METHOD: POST
I am trying to add a video under a product sku using Magento's provided API endpoint.
{
"entry": {
"media_type": "external-video",
"label": "Video 2",
"position": 2,
"disabled": false,
"types": ["thumbnail"],
"content" : {
"base64_encoded_data": "encoded image data ",
"type": "image/jpeg",
"name": "0.jpg"
},
"extension_attributes": {
"video_content": {
"media_type": "external-video",
"video_provider": "youtube",
"video_url": "some youtube video url",
"video_title": "some title",
"video_description": "",
"video_metadata": ""
}
}
}
The response I get from this call is "invalid option value", I had debugged this in a local environment which leads me to failure during ProductRepository->save() within Magento\Catalog\Model\Product\GalleryGalleryManagement.php on line 70.
Is this an issue with my payload or actual magento bug?
Resolved this issue by adding videos directly using POST /V1/products or PUT /V1/products/{sku} endpoints.
post method example:
{
"product": {
"sku": "some-sku",
..... other product data,
"media_gallery_entries": {
"media_type": "external-video",
"label": "Video 2",
"position": 2,
"disabled": false,
"types": [],
"content" : {
"base64_encoded_data": "encoded image data ",
"type": "image/jpeg",
"name": "0.jpg"
},
"extension_attributes": {
"video_content": {
"media_type": "external-video",
"video_provider": "youtube",
"video_url": "some youtube video url",
"video_title": "some title",
"video_description": "",
"video_metadata": ""
}
}
}
}
I had no luck with Magento's MediaGallery POST endpoint (/V1/products/{sku}/media.
If you want to add a video to the product page then why you did not try using YouTube API?
You just need to follow these steps:
Generate a YouTube API Key by going goodle developer console
Then add Youtube API key to your Magento 2 by going to STORES --> Configuration
Then Add Video URL
I have been using Graph API for a while, but I am not able to figure this one out.
I have a group id, from whose feed I want to get the image urls for all available resolutions.
I know I can do that using the 'images' field of a photo id.
Here is a sample code which gets the id
<group-id>/feed?fields=attachments{target{id}}
I tried
<group-id>/feed?fields=attachments{target{id{images}}}
and also this
<group-id>/feed?fields=attachments.fields(target.fields(id{images}))
and this
<group-id>/feed?fields=attachments.fields(target.fields(id.fields(images)))
All of them return the JSON having the id, but not the images details I need.
I hope I have provided enough information.
You can use the below format while calling the API and it will return you with the images URL included in the post
<group-id>/feed?fields=created_time,attachments,message
You will get the response in the below format.
{
"created_time": "2017-11-16T06:21:37+0000",
"id": "543993212434753_1004360179731385",
"attachments": {
"data": [
{
"description": "Best #ethnic wear store for #women.
Shop Now>> sairandhri.com",
"media": {
"image": {
"height": 720,
"src": "https://scontent.xx.fbcdn.net/v/t1.0-9/s720x720/23519069_887109751445971_6170575397465061641_n.jpg?oh=170436ae447ec615f547d700017c67b4&oe=5AA4F844",
"width": 537
}
},
"target": {
"id": "887109751445971",
"url": "https://www.facebook.com/SairandhriShowroom/photos/a.302015823288703.1073741828.300462640110688/887109751445971/?type=3"
},
"type": "photo",
"url": "https://www.facebook.com/SairandhriShowroom/photos/a.302015823288703.1073741828.300462640110688/887109751445971/?type=3"
}
]
}
}
Its working and tested on Graph API Explorer
According to https://developers.facebook.com/docs/messenger-platform/send-api-reference/video-attachment I should be able to send video's via messenger. I ideally want to send youtube videos with a start and end time, but that does not seem to work.
I am currently trying to get it work in any such way, so i have the video on FB currently and even that isn't working.
python code
data = OrderedDict()
data['sender'] = {"id": APP_ID}
data['recipient'] = {"id": recipient}
data['message'] = {
"attachment": {
"type": "video",
"payload": {"url": "https://www.facebook.com/587721184763189/videos/596530243882283/"}
}
}
data = json.dumps(data)
print("data: ", data)
r = requests.post("https://graph.facebook.com/v2.6/me/messages",
params={"access_token": token},
data=data,
headers={'Content-type': 'application/json'},
timeout=60)
if r.status_code != requests.codes.ok:
print(r.text)
2016-12-20T23:45:40.685949+00:00 app[web.1]: data: {"sender": {"id": 744391742366207}, "recipient": {"id": "1297603110290455"}, "message": {"attachment": {"type": "video", "payload": {"url": "https://www.facebook.com/587721184763189/videos/596530243882283/"}}}}
2016-12-20T23:45:41.396419+00:00 app[web.1]: {"error":{"message":"(#100) Failed to fetch the file from the url","type":"OAuthException","code":100,"error_subcode":2018008,"fbtrace_id":"BjJzB1J8/42"}}
You need to supply the URL to the video file (for example MP4), not the URL of page containing the video (for example a YouTube URL).
This can be seen in the example code in Facebook's documentation
curl -X POST -H "Content-Type: application/json" -d '{
"recipient":{
"id":"USER_ID"
},
"message":{
"attachment":{
"type":"video",
"payload":{
"url":"https://petersapparel.com/bin/clip.mp4"
}
}
}
}' "https://graph.facebook.com/v2.6/me/messages?access_token=PAGE_ACCESS_TOKEN"
Sending Youtube videos in your Facebook Messenger bot is now possible if you use the open graph template.
A message object would then look like this:
"message": {
"attachment": {
"type": "template",
"payload": {
"template_type": "open_graph",
"elements": [
{
"url": "https://www.youtube.com/watch?v=whatever"
}
]
}
}
}
As of today, this works (you need to add the image url of the screenshot):
message: {
text,
attachment: {
type: "template",
payload: {
template_type: "generic",
elements: [
{
title: "El espĂa",
image_url: "https://i.ytimg.com/vi/yj2r6KPKV1w/hqdefault.jpg?sqp=-oaymwEcCOADEI4CSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLAGKGjilp1gvYUv6c5dL_oveZ8LYg",
default_action: {
type: "web_url",
url: "https://www.youtube.com/watch?v=yj2r6KPKV1w",
},
}
],
},
},
},