How can I make carousel Flex Message in Line Bot with Django? - django

I know how to show carousel message with using carousel template, however ,it can't show in Line when using computer. So I want to try not to use carousel template, I have seen these code for carousel Flex Message in JSON ,how can I switch these code to Django format?
{
"type": "carousel",
"contents": [
{
"type": "bubble",
"body": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "text",
"text": "First bubble"
}
]
}
},
{
"type": "bubble",
"body": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "text",
"text": "Second bubble"
}
]
}
}
]
}

Related

I got this error (#132000) Number of parameters does not match the expected number of params

enter image description here
Here this is my custom template which I have created. Using this template am
trying to send what's app msg but i got 132000 error
{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "917760569250",
"type": "template",
"template": {
"name": "media_messages",
"language": {
"code": "en_US"
},
"components": [
{
"type":"header",
"parameters":[
{
"type":"document",
"document":{
"id": "1195808994372455"
}
}
]
},
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "Document"
}
]
}
]
}
}

Dialogflow Messenger List Response Type Issue

I am using Dialogflow Messenger's list response type for a list of 8 services people can select from.
Can Dialogflow not handle more than 3 clicks in the list?
Click service 1: fires fine.
Click service 2: fires fine.
Click service 3 or after that: "I don't understand."
However, people can type in the service and the bot responds just fine. Or people can click 1 service, ask the question again and select a different service and the bot responds fine. But we want people to be able to click all the services in the whole list.
Code used:
{
"richContent": [
[
{
"type": "list",
"event": {
"parameters": {},
"name": "Fire-Application-Development-Intent",
"languageCode": ""
},
"title": "Application Development"
},
{
"title": "Business Intelligence",
"event": {
"name": "Fire-Business-Intelligence-Intent",
"languageCode": "",
"parameters": {}
},
"type": "list"
},
{
"type": "list",
"title": "Digital Assistants (AI)",
"event": {
"parameters": {},
"languageCode": "",
"name": "Fire-Digital-Assistants-Intent"
}
},
{
"type": "list",
"title": "Mobile Development",
"event": {
"languageCode": "",
"parameters": {},
"name": "Fire-Mobile-Development-Intent"
}
},
{
"event": {
"languageCode": "",
"parameters": {},
"name": "Fire-Websites-Intent"
},
"title": "Websites",
"type": "list"
},
{
"type": "list",
"title": "ChatBeacon",
"event": {
"name": "Fire-ChatBeacon-Intent",
"languageCode": "",
"parameters": {}
}
},
{
"title": "Asset Location Tracking",
"event": {
"languageCode": "",
"parameters": {},
"name": "Fire-Asset-Location-Tracking-Intent"
},
"type": "list"
},
{
"event": {
"name": "Fire-NRS-Forms-Intent",
"languageCode": "",
"parameters": {}
},
"type": "list",
"title": "NRS Forms"
}
]
]
}

Logstash keep creating field despite the dynamic_mapping being deactivated

I have defined my own template to be used by logstash where I have deactivate the dynamic mapping:
{
"my_index": {
"order": 0,
"template": "my_index",
"settings": {
"index": {
"mapper": {
"dynamic": "false"
},
"analysis": {
"analyzer": {
"nlp_analyzer": {
"filter": [
"lowercase"
],
"type": "custom",
"tokenizer": "nlp_tokenizer"
}
},
"tokenizer": {
"nlp_tokenizer": {
"pattern": ""
"(\w+)|(\s*[\s+])"
"",
"type": "pattern"
}
}
},
"number_of_shards": "1",
"number_of_replicas": "0"
}
},
"mappings": {
"author": {
"properties": {
"author_name": {
"type": "keyword"
},
"author_pseudo": {
"type": "keyword"
},
"author_location": {
"type": "text",
"fields": {
"standard": {
"analyzer": "standard",
"term_vector": "yes",
"type": "text"
},
"nlp": {
"analyzer": "nlp_analyzer",
"term_vector": "yes",
"type": "text"
}
}
}
}
}
}
}
}
To test if elasticsearch won’t generate new field I try to let a field in my events that is not present in my mapping, let’s say that I have this event:
{
“type” => “author”,
“author_pseudo” => “chloemdelorenzo”,
“author_name” => “Chloe DeLorenzo”,
“author_location” => “US”,
}
Elasticsearch will generate a new field in the mapping when indexing this event:
"type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
I know that Logstash is using my template because in my mapping I use a custom analyser and I can find it back into the mapping generated. But apparently it doesn’t take into consideration that the dynamic field is disabled.
I want elasticsearch to ignore fields that are not present in my mapping but to index the field that have a defined mapping. How can I avoid logstash to create new field?
You should enforce the mapping at the document type level.
https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-mapping.html
Regardless of the value of this setting, types can still be added
explicitly when creating an index or with the PUT mapping API.
So your mapping will look like:
"mappings": {
"author": {
"dynamic": false,
"properties": {
"author_name": {
"type": "keyword"
},
"author_pseudo": {
"type": "keyword"
},
"author_location": {
"type": "text",
"fields": {
"standard": {
"analyzer": "standard",
"term_vector": "yes",
"type": "text"
},
"nlp": {
"analyzer": "nlp_analyzer",
"term_vector": "yes",
"type": "text"
}
}
}
}
}
}
This answer is not exactly what you are requesting, but you can manually remove fields with a logstash filter like this:
filter {
mutate {
remove_field => ["fieldname"]
}
}
If your events have a defined list of fields, you could solve your problem this way.

ElasticSearch (AWS): How to use another index as a query/match parameter?

Basically I am trying to implement this strategy.
Sample Data:
PUT /newsfeed_consumer_network/consumer_network/urn:viadeo:member:me
{
"producerIds": [
"urn:viadeo:member:ned",
"urn:viadeo:member:john",
"urn:viadeo:member:mary"
]
}
PUT /newsfeed/news/urn:viadeo:news:33
{
"producerId": "urn:viadeo:member:john",
"published": "2014-12-17T12:45:00.000Z",
"actor": {
"id": "urn:viadeo:member:john",
"objectType": "member",
"displayName": "John"
},
"verb": "add",
"object": {
"id": "urn:viadeo:position:10",
"objectType": "position",
"displayName": "Software Engineer # Viadeo"
},
"target": {
"id": "urn:viadeo:profile:john",
"objectType": "profile",
"displayName": "John's profile"
}
}
Sample Query:
POST /newsfeed/news/_search
{
"query": {
"bool": {
"must": [{
"match": {
"actor.id": {
"producerId": {
"index": "newsfeed_consumer_network",
"type": "consumer_network",
"id": "urn:viadeo:network:me",
"path": "producerIds"
}
}
}
}]
}
}
}
I am getting the following error:
"type": "query_parsing_exception",
"reason": "[match] query does not support [index]"
How can I use an index to support a matching query? Is there any way to implement this?
Basically I just want to use another document as the source of the matching parameter for my query. Is this even possible with ElasticSearch?

Django AJAX looping data

In my view I'm trying to loop all pages and extract the name for each using the code below. But it does not appear to work.
How can I achieve this?
view.py
json_dict = json.loads(request.POST['site'])
for item in json_dict['pages']:
item.json_dict['name']
the JSON data
{
"someitem": "xaAX",
"pages": [
{
"id": "1364484811734",
"name": "Page Name",
"type": "basic",
"components": {
"img": "",
"text": ""
}
},
{
"id": "1364484812918",
"name": "Contact",
"type": "contact",
"components": {
"text": "Send us an email using the form below.",
"contact-form": {
"contact-name": "zzz",
"contact-email": "zz"
}
}
},
]
}
This should work:
json_dict = json.loads(request.POST['site'])
for item in json_dict['pages']:
print item['name']