Custom Facebook chat message template? - facebook-graph-api

Seems it is not possible to add custom message template to Facebook Chat, or do I miss something?
https://developers.facebook.com/docs/messenger-platform/send-messages/templates#available_templates
I would use a template where user can express the importance of things, and can reorder rows in a list.
How could I impelement it?

Related

Sitecore 9.3 Experience Analytics - tracking logged users and users roles

Can anyone provide me with working example how to show analytics (Visits, Page views, Page views per visit, etc) for logged users? As I understand there is no OOB solution, so I've tried to implement flexible dimensions, but didn't find any good examples and failed.
First of all you have to identify your logged in contact by calling the Sitecore.Analytics.Tracker.Current.Session.IdentifyAs() method, see more details here. When the contact logs in you can use their username to identify them upon the successful login.
Note, that the identification and authentication are separate unrelated events. Contacts are identified against the xDB and authenticated against the authentication mechanism used by the website.
When the contact identifies, it is saved to xConnect with a known identifier based on the information passed into theIdentifyAs() method: Identifier, Source and
IdentifierType will be set to ContactIdentifierType.Known (it is set to ContactIdentifierType.Anonymous for anonymous contacts). Then you can use IsKnown property on the Sitecore.XConnect.Contact that returns true if a contact has any known identifiers.
If you want to track some custom events for the logged in users to then use them for reporting needs you can add user interactions by calling the client.AddInteraction() extension method. I have given an example here.
If you want to extend the contact with your own custom data then you can create custom contact facets, read more here.
In order to implement your custom report with flexible filtering by logged in and not users, of course, you will need to define your custom dimensions and metrics, read more here.

How to update campaigns content with template in mailchimp

I want to use mailchimp to send mail when something happen automatically , so i use mailchimp restful api to do this:
1.Create a campaign with api /campaigns
2.Update the campaign with api /campaigns/{campaign_id}/content
3.Send the campaign
in this second step, i found the API /campaigns/{campaign_id}/content can update the campaign's content with plaintext or html easy with http body like this:
{"html": "<p>The HTML to use for the saved campaign<./p>"}
but i am not sure how to use a template to update the content.
In the API document(https://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/content/#), if you want to use template update content, you need fill the template id and template sections, but how do i know the sections in a template?
I try to use the template api to get a template detail information, in the response, the section filed is empty array.
any suggestion? or give me example!
thank you guys
Regard to great developers
Not sure if you ever found an answer, but I am struggling with this API too. The sections can be retrieve from the GetDefaultContent API which will return an MailChimp Response with a sections object. That object, in turn, will have all the sections that you have specified in your template by name and their default content.
I am still trying to figure out the updating part, myself, but hope this helps a bit.

Allow staff to edit email data via django admin site?

I would like to give staff the ability to manage the fields from, subject, and body when sending emails without having to edit the html file. Ideally they would be able to do this via the admin site. My thought process is:
Create email table with the requested fields
Add send_email on admin.py classes when they perform a certain action. When they do, I can get the values for sending emails by getting object from email table based on primary key.
I haven't come across any documentation to set this up and am concerned it's considered bad to do.
I'm almost certain to be missing something crucial as to why this is a terrible idea... can anyone comment on cases when this would blow up, or that it's odd but shouldn't be an issue? Most of the emails staff edit will be of static text.
Any suggestions/comments/criticism is very much appreciated.
I personally use Django DB Templates for such purpose like email editing in Admin Area.
It's simple and you can save your existing templates to DB templates table.

Tastypie - Queryset or filters

Im using tastypie and i just ran into a problem.
My problem:
Users can post messages and if other users are subscribed to that user they can see those message on their homepage. Its exactly like twitter users tweeting and followers looking at their tweets.
I have a public api for all messages.
I can filter a particular users messages using ?userid=1
Bad solution to problem:
I can filter multiple users messages (and thus solve the problem) using
?userid__in=1&userid__=5&...
But this is not a good way because the url length is going to increase to a possibly unallowed amount. (2000 characters)
Is there a better way of doing this?
Is there a way I can use request.user in a queryset to do a join?
Or should I use some sort of advanced filtering?
Thank YOU!
Tastypie already supports this via __in filtering (everything that ORM supports Tastypie exposes, except negations). No coding is necessary.
Look here: http://django-tastypie.readthedocs.org/en/v0.9.11/resources.html#basic-filtering
path/to/api/resource/?user_id__in=1,2,3,4,5,6
However, you can still have the problem of your URL becoming huge with someone subscribed to many users. What you can do instead is keep this information in the DB model (which user is subscribed to which user as a recursive ManyToMany relationship within the model through a separate joint model).
Then you could expose this through your resource without ever having to specify subscriptions through your URL as a parameter and/or filter. Instead your base queryset in the resource would be:
userids = request.user.subscription_userset.values(id)
provided that you have a self ManyToManyRelationship in your User model. Look here, and here.
What if you had someone pass in a list of user_ids they wanted to see updates for, and then filtered on that? Something like this:
URL: your/api/messages.json?user_ids=5,8,10,25
And then in the code you'd convert that into an actual list, and query:
Message.objects.filter(user__id__in=user_ids)

IS there any Django app that notify the user about something that happened in your web, and ask him to perform an action?

I mean, there's any generic app that you can use to make notifications like when in Facebook, someone adds you as friend, or invite you to an event?
Basically, I need to show to the user this type of notification for different contents type, with the possibility to do some custom actions (ignore, accept, etc) different for each one.
I wonder if someone have done this before, so I can plug it and create a type of notification simply passing the text of the notification, the options that must show and the views to call for each option.
Thanks.
django-notifications is a GitHub notifications alike app, and it's based on Django Activity Stream.
If you familia with django-activity-stream, the the usage of django-notifications almost the same.
django-notifications also provide notifications_unread templatetag to display unread notifications of current login user.
Django Activity Stream does this, for the most part. It's a generic relationship manager that watches for save events in the datbase, and when a condition is met it puts an "event happened!" record into its own tables.
It would be incumbent upon you to then present that feed of events to the user, along with links to the actions (specific to your project) that you want him to take.
Even if it's not what you want, it's an excellent example of how to start.
Maybe this is more closer to my needs:
django-notification
https://github.com/jtauber/django-notification
any experience with that?
There is also django-notify: http://code.google.com/p/django-notify/