What I want is to announce the original comment poster, when someone has responded on his comment
It's a bit blurry on how to do this with triggers.
Has anybody done that, or is there another way to do this?
I'm not sure exactly how to do it with the core Triggers module, but this can definitely be done with the Rules Module (assuming Drupal 6... not sure of any issues with Drupal 7 version of Rules).
Download and install Rules
Navigate to admin/rules/trigger/add to create a new rule, name it whatever you like and under the Event dropdown, choose "After saving a new comment" and click Save
Click on the "Add a condition" link choose "Execute custom PHP code". In the PHP code area, add the following then click save:
if ($comment->pid != 0) {
return TRUE;
}
else {
return FALSE;
}
Click "Add an action" and choose "Load comment by id". In the Comment id field add: <?php echo $comment->pid; ?> and click Save
Click "Add an action" again and choose "Load a user account". In the User id field add: <?php echo $comment_loaded->uid; ?> and click Save
Click "Add an action" again and choose "Send a mail to an arbitrary mail address". In the Recipient field add: <?php echo $user_loaded->mail; ?> and fill in the other fields however you like to customize the email.
Now whenever a comment is replied to, an email will be sent to the "replied-to" comment author.
For Drupal 7 website
Here is the code you can import under rules and update your subject and body as per your requirement:
{ "rules_send_reply_notice_for_comments" : {
"LABEL" : "Send reply notice for comments",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "comments" ],
"REQUIRES" : [ "rules", "comment" ],
"ON" : { "comment_insert" : [] },
"IF" : [ { "NOT data_is_empty" : { "data" : [ "comment:parent" ] } } ],
"DO" : [
{ "mail" : {
"to" : [ "comment:parent:mail" ],
"subject" : "SUBJECT",
"message" : "Here is the message you want to send [comment:body] regards Gaurav",
"from" : "YOUR EMAIL ADDRESS",
"language" : [ "" ]
}
}
] } }
Related
I'm working on a dialogflow chatbot. It retrieves the user's name and email at the start of the conversation, and I have a sessions-vars output context with a lifespan of 60 to keep these parameters throughout the conversation. I know they are kept by checking diagnostic info and referring to them in chatbot replies as #context.parameter.
Near the end of my conversation path there in an intent called 110checklistemail.sendemail where my chatbot asks the user if they want information emailed to their email or sent in the chat. If the user says "Email it to me" I have webhook call enabled, where it redirects to fulfillment code, pasted below.
I followed a guide to integrate the chatbot with sendgrid, and the email is sent and does work if I prompt for the email at that specific intent. However, if I don't prompt for the email address (eg. the user says 'email it to me') then the agent is not able to send the email because the email parameter is now blank, despite being populated before in a context with a long lifespan.
Fulfillment code is the following:
'use strict';
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
const sgMail = require('#sendgrid/mail');
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
process.env.SENDGRID_API_KEY = 'SG._APIKEYHERE';
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
function sendEmail(agent) {
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const emailParam = agent.parameters.email;
const msg = {
to: emailParam,
from: 'tyler#mailfence.com',
subject: 'Just a quick note',
text: 'Just saying Hi ${agent.parameters.given-name} from Dialogflow...',
html: 'Just saying <strong>Hi Hi ${agent.parameters.given-name} from Dialogflow</strong>...',
};
console.log(msg);
sgMail.send(msg);
agent.add(`What a beauty!`);
}
// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set('110checklistemail.sendemail', sendEmail);
// intentMap.set('your intent name here', yourFunctionHandler);
// intentMap.set('your intent name here', googleAssistantHandler);
agent.handleRequest(intentMap);
});
Snippet from Diagnostic info:
{
"responseId": "130742d9-7453-41c6-8b27-ee8f91d9d02d-5a74d3f9",
"queryResult": {
"queryText": "Email it to me",
"parameters": {
"email": ""
},
"allRequiredParamsPresent": true,
"fulfillmentText": "What a beauty!",
"fulfillmentMessages": [
{
"text": {
"text": [
"What a beauty!"
]
}
}
],
"outputContexts": [
{
"name": "projects/tyler-vhyo/locations/global/agent/sessions/aef22896f9/contexts/1await_checklist_type",
"lifespanCount": 4,
"parameters": {
"Jobtype.original": "custom shower",
"email.original": "",
"Jobtype": "custom shower",
"email": ""
}
},
{
"name": "projects/tyler-vhyo/locations/global/agent/sessions/aef3d36-18d696f9/contexts/session-vars",
"lifespanCount": 54,
"parameters": {
"last-name.original": "",
"email.original": "",
"email": "",
"given-name.original": "Tim",
"Jobtype": "custom shower",
"Jobtype.original": "custom shower",
"given-name": "Tim",
"last-name": ""
}
I was wondering why it wasn't working unless I prompt for the email in that specific intent, and I realised it's because the email parameters are now all blank (and definitely populated before!) I don't want to reprompt for the email when the user already has to input it at the start of the conversation.
How can I solve this issue and get the email to send off the pre-existing email parameter?
Also, how can I get the ${agent.parameters.given-name} code to reference the name parameter correctly in the email body? It hasn't been working for me and I don't know if there is a better way to pull parameters in the email.
I'm an extreme novice at coding at the code above is something I made following a guide. I really do have no idea what is happening so any advice is very welcome and appreciated. Thank you in advance!
Managed to solve the issue. Steps that I think led to it working:
Added all the parameters to 'action and parameters' of the intent
Checkmarked 'Is list'
Added a default value for each parameter referring to itself from the earlier context in the form #session-vars.parametername
I don't understand 100% why it wouldn't work without the above steps, as the intent shouldn't modify or clear the parameters, but it seems to have done the trick.
When reading authentication flows with
kcadm.sh get authentication/flows -r master
I get this result for the builtin flows
{
"id" : "cee86f07-db10-4e84-9a5e-a9c6ae1c3703",
"alias" : "http challenge",
"description" : "An authentication flow based on challenge-response HTTP Authentication Schemes",
"providerId" : "basic-flow",
"topLevel" : true,
"builtIn" : true,
"authenticationExecutions" : [ {
"authenticator" : "no-cookie-redirect",
"authenticatorFlow" : false, <---
"autheticatorFlow" : false, <---
"requirement" : "REQUIRED",
"priority" : 10,
"userSetupAllowed" : false
}, {
"authenticatorFlow" : true,
"requirement" : "REQUIRED",
"priority" : 20,
"autheticatorFlow" : true,
"flowAlias" : "Authentication Options",
"userSetupAllowed" : false
} ]
}
That field is nowhere mentioned in the REST API documentation. Is there a deeper meaning in this, or is this just some leftover typo that is kept for compatibility (like HTTP Referer vs HTTP Referrer)? Do I have to set this undocumented field when creating a new flow via REST API?
Short story: Use "authenticatorFlow"
It would appear this is a long standing spelling typo. If you dig into the keycloak source code e.g. v15.1.1 here:
https://github.com/keycloak/keycloak/blob/15.1.1/core/src/main/java/org/keycloak/representations/idm/AbstractAuthenticationExecutionRepresentation.java#L71 You will see the misspelled "autheticatorFlow" is marked as deprecated.
#Deprecated
public void setAutheticatorFlow(boolean autheticatorFlow) {
this.authenticatorFlow = autheticatorFlow;
}
...snip...
public void setAuthenticatorFlow(boolean authenticatorFlow) {
this.authenticatorFlow = authenticatorFlow;
}
In other parts of the source you will see a setter for the correctly spelled property "authenticatorFlow" e.g. here:
https://github.com/keycloak/keycloak/blob/15.1.1/model/jpa/src/main/java/org/keycloak/models/jpa/RealmAdapter.java#L1649
(which shows the misspelling is down to the db column).
model.setAuthenticatorFlow(entity.isAutheticatorFlow());
It should be safe to use the correctly spelled "authenticatorFlow". However always evaluate for your specific version.
I’m trying to achieve the following configuration in my Ionic (3.9.2) app using the Ionic 2 DeepLinker, where I have regular versions of my pages at index.html, /terms, and /card, and differently styled versions at /club/index.html, /club/terms and /club/card:
#NgModule({
declarations: MyComponents,
imports: [
BrowserModule,
HttpClientModule,
// DeepLinker!!
IonicModule.forRoot(MyApp, { locationStrategy : 'path' }, {
links : [
{ component : HomePage, name : 'Home', segment : '' },
{ component : TermsPage, name : 'Terms of Use', segment : 'terms' },
{ component : CardPage, name : 'Savings Card', segment : 'card' },
// Club Aliases; these pages will have the same content as above,
// but slightly different styles, defined elsewhere.
{ component : HomePage, name : 'Home', segment : 'club' }
{ component : TermsPage, name : 'Terms of Use', segment : 'club/terms' },
{ component : CardPage, name : 'Savings Card', segment : 'club/card' },
//...
Is there a way to achieve this using the Ionic 2 DeepLinker?
Some notes:
We navigate to pages by following links (and preventing default):
Terms of Use
where openPage pushes a page onto the nav stack using NavController's Nav Component, like so:
$event.preventDefault();
this.nav.push(page.component, params);
We also had to setup our webserver to rewrite subdirectories (e.g. “/terms”) to index.html. Info: https://github.com/ionic-team/ionic/issues/10565#issuecomment-282659179
And I also forked #ionic-app-scripts to get this (rewrite to index.html) working on my local development (e.g. live reload) server:
https://github.com/senseijames/ionic-app-scripts
In the DeepLinkConfig links 'name' is simply a string identifier which can be used to resolve the page component by its string alias. I would recommend omitting whitespaces and capitalization and adjusting your implementation like so:
Refactor DeepLinkConfig
links : [
{ component : HomePage, name : 'home', segment : '' },
{ component : TermsPage, name : 'terms', segment : 'terms' },
{ component : CardPage, name : 'card', segment : 'card' },
{ component : HomePage, name : 'club', segment : 'club' }
{ component : TermsPage, name : 'club-terms', segment : 'club/terms' },
{ component : CardPage, name : 'club-card', segment : 'club/card' }
]
Refactor click handler
openPage(name: string, params: any) {
this.nav.push(name, params);
}
Refactor button markup
<button ion-button (click)="openPage('terms', {})">Terms of Use</button>
<button ion-button (click)="openPage('club-terms', {})">Club Terms</button>
<button ion-button (click)="openPage('club-card', { id: 1234, username: 'someuser', rewards: false })">Savings Card</button>
This way you can navigate by name and not have to import page components into each controller in order to link to the page component itself. Also ion-button attribute decorated button elements are the preferred navigation UI per IonicFramework documentation and using them would avoid the need to prevent the default behavior of vanilla html anchors.
I am working on backend with mongodb & php. I have stored message content in mongodb database.
My mongodb database content is this
.......some content.........
"content": "This is the test message",
"time_created": 1418813065,
"status": "read",
"agencyStatus": "read",
"reply": [
{
"email": "leon#accenture.com",
"name": "Accenture",
"content": "Thanks for your test message",
"time": 1418813145
}
]
In my program i am retriving the message content & reply content through foreach loop as is nested as a object inside.
<?php echo $mongoMessage['content'];?>
<?php foreach ($mongoMessage['reply'] as $mongoReply){ ?>
<?php echo $mongoReply['content']; ?>
My problem is when a record with reply exist i am retriving then it is displaying on browser but a record with no reply, i am retriving then it shows me notice on browser. How to get rid of this situation. This problm i am facing from last week plz help me guys...
If I could get you right then you are getting a notice in browser when you try to retrive a document where reply array does not have a value.
So to get rid of that you must check first if the reply array is not empty. Like this -
<?php
echo $mongoMessage['content'];
if (!empty($mongoMessage['reply'])) {
foreach($mongoMessage['reply'] as $mongoReply)
{
echo $mongoReply['content'];
}
}
?>
Hope this helps :-)
I've scoured the documentation but to no avail.
Where is src looking at in the settings? Is it the root of the site or the tiny_mce folder?
If my template was located at: /tiny_mce/templates/example.html, what would I put as the SRC?
template_templates : [
{
title : "Editor Details",
src : "editor_details.htm",
description : "Adds Editor Name and Staff ID"
},
{
title : "Timestamp",
src : "blank.htm",
description : "Adds an editing timestamp."
}
],
So it turns out the the location is relative to wherever the script is run from.
So if you are calling the script on the root file (MasterPage in this instance) the code is:
template_templates : [
{
title : "Base Home Page",
src : "/tiny_mce/temp/Base.htm",
description : "Basic Homepage, rotate, etc.."
}
],
So the html file is located in ./tiny_mce/temp/