Extracting raw message in Gmail apps-script - email

In my Gmail-addon, I want to be able to read the raw (MIME) message of the current email.
How can I do that?

You can retrieve the message ID of the current message using e.messageMetadata.messageId at function buildAddOn(e){}. I cannot uderstand about raw (MIME) message in your question. So I propose 2 patterns.
If you want the raw data of Byte[], you can retrieve it from message ID using Gmail.Users.Messages.get() of Advanced Google Services as follows.
Gmail.Users.Messages.get("me", messageId, {format: "RAW"}).raw
If you use this, please enable Gmail App at Advanced Google Services and API console.
If you want the raw data of String, you can retrieve it from message ID using GmailApp.getMessageById() as follows.
GmailApp.getMessageById(messageId).getRawContent()
Note :
If you use this, please set "https://www.googleapis.com/auth/gmail.addons.execute", "https://mail.google.com/" to the scopes.
If other scopes are required to be added, please also add them.
References :
Gmail Add-on
Gmail.Users.Messages.get()
getMessageById(id)
If I misunderstand your question, I'm sorry.

Related

URL links in email - resolve correct url?

Before i start thinking about this programatically, does anyone know if it is possible to actually extract the correct url from an email link that is basically a tracking module?
Our work email system auto blocks tracking based urls from email, so i am thinking of writing something to extract the correct url so people can copy and paste the tracking link into a program and it will provide the correct url.
Is this even possible with the way that email tracking works?
Here is an example of a url in an email that i recently received:
http://t.dripemail2.com/c/eyJhY2NvdW50X2lkIjoiNTE0MTQ4NSIsImRlbGl2ZXJ5X2lkIjoiOTI0NzI2MTU0IiwidXJsIjoiaHR0cHM6Ly93d3cuYXhzaWVkLmNvbS9nY3NlLWNvbXB1dGVyLXNjaWVuY2Uvb2NyLW5lYS1ndWlkZS8_X19zPXphb2txcDVpaWN4NGkxZndtYmNnIn0
Our system blocks these. It eventually resolves to:
https://www.axsied.com/gcse-computer-science/ocr-nea-guide/?__s=zaokqp5iicx4i1fwmbcg
(got our network admin to check it for me)
I want a system that gets the right url from the ugly mess that is blocked so we can actually view links from emails.
Thanks in advance for any help.
The data in tracking URLs are typically a unique ID pointing to some entry in a database, or are encrypted with a private key, so there's no way to obtain any meaningful information from them. (see answers to this related question: Generate unique link for each website visitor)
More naive approaches will simply encode the data, in which case you may be able to extract useful information from them. Funnily enough, your example URL is a base 64 encoded JSON object containing the link itself:
{
"account_id": "5141485",
"delivery_id": "924726154",
"url": "https://www.axsied.com/gcse-computer-science/ocr-nea-guide/?__s=zaokqp5iicx4i1fwmbcg"
}
In this case you could actually resolve the URL on your own, but this type of approach is uncommon for that very reason.

Infusionsoft Form Submission API

I have been using Infusionsoft form embedded in html page but now I want to send data to Infusionsoft form using their API. I checked their APIs but could not figure out which one should be used to submit data to the Infusionsoft form. Can someone please help me with this?
https://developer.infusionsoft.com/docs/xml-rpc/
Thanks for looking into this.
Thank you, Naresh
Try to use REST API instead of XML RPC. Developer center already marked XML RPC to "legacy" module, and I guess they will replace "XML RPC" sooner or later.
Regarding to your question, you will need to define what data set you want to update.
For example, if your form is going to insert a new contact, you will need 2 things from your code.
First, prepare the parameters such like "email_addresses", "phone_numbers" and "given_name".
Second, POST request with parameters to this URL "https://api.infusionsoft.com/crm/rest/v1/contact?access_token=123abc" after authentication.
Ways to test:
Try REST API calls on page https://developer.infusionsoft.com/docs/rest/
Good luck.
To pull Webformvia API you will have to use following method, this will pull the HTML form:
Retrieve a Form's HTML
to submit a data to Infusionsoft via API
You will have to use Create contact and update contact API:
Create Contact
Update COntact
XML RPC is still in use but Infusionsoft suggests to use REST API methods
Create a Contact
Update a Contact
Single API call for two methods: Create or Update a Contact

FB Chatbot how to get the previous message

Is it possible to receive the previous message that the user have send to the chatbot (without using quick replies or postback buttons). Example:
User: "Can you call a friend?"
Bot: "Who should I call?"
User: "Tim"
In the API I now have just the information "Tim", without knowing if I should call him or text him or make him a sandwich or whatever. So I basically I want to add some Postbackdata or metadata additionally to the text "Can you call a friend" (intent: 'CALL'), so the message "Tim" will come with that data.
Is there a way without storing the data into a database? AWS Lambda with ClaudiaJs.
I found the metadata field in the FB API which turns out to be the wrong field for that since it is only for communicating between several apps?!
What you are looking for a called a "slot-based bot", or slot-filling, basically meaning that you have a "slot", or blank that needs to be filled in before your bot can perform an action. In your example you have two slots: action and person
Actions could be: call, text, message
Person: name of a person, friend, etc.
I don't think any of the message frameworks (Slack, Facebook, etc) will provide you with the information you need. You will need to build this logic out yourself.
You can look at using wit.ai stories to achieve this.
Look to this similar Stack Overflow question and answer.
You can reverse order of conversation, and at beginning user writes some text or send you something else. After receiving, you should send to user buttonsTemplate, where postbacks will be like "CallTo&Tim" where instead of Tim you can put every text you need to pass to next executor(and you also can store previous user message here). Than just make substring of postback, check it`s type and do whatever you want.

error: Failed to run the post merge process

I'm trying to generate documents using conga composer 8 from apex code but its failing with error Failed to run the post-merge process. I have looked into url and its same as the one I used initially in another salesforce org. I couldn't find any help online or on conga-composer form.
Here is my conga endpoint URL:
https://composer.congamerge.com/Composer8/Index.Html? sessionId=00D41000000dorw!ARQAQKbinH5TXMR_70s3XCShQh5GuSVdrFcq0Fg9OidZLo9MLxzWSby8QY1B4xM8e72DPawVziclnXBjTzpG41RiCAPKQqOt
&serverUrl=https://na35.salesforce.com/services/Soap/u/29.0/00D41000000dorwEAA
&id=a1J410000012BwS
&TemplateId=a0C41000000kg5GEAQ
&APIMODE=13
&ESAgreementName=Contract+for+Test
&queryid=a0441000001PwI7AAK,a0441000001PwICAA0
&ESSignatureType=2
&ESSignatureOrder=2
&ESVisible=1
&ESCustomField=cldocgen__App__c
&ESCustomFieldValue=a1J410000012BwSEAU
&ESRecipient1=00541000000Ke9pAAC
&ESRecipient2=003410000078zVbAAI
&ESRecipient3=003410000078zVhAAI, Method=GET]
Any insight what might be causing this issue.
I had the same problem and was able to solve it using permissions. In this case make sure the user id whose sessionID is passing to Conga has the correct CRUD access to the primary object in your conga call (id=a1J410000012BwS). My guess is that this is something to do with Conga not being able to write the attachment back to salesforce.
Apart from what Greg has mentioned, there are 2 more observations for this error:
Under Email Administration -> Deliverability -> Access to Send Email (All Email Services) should be set to All email.
In case you are using the EmailTemplateId parameter then the classic email template must be available for use.
Also mostly this error is also because of some discrepancy in the URL.

Nagios does not send the graph in email

So, I have been trying to make Nagios work with Graphite to send alert emails but that's not working right. I used the following URL to set everything up:
http://www.protocolostomy.com/2012/02/24/sending-alerts-with-graphite-graphs-from-nagios/
The sendgraph.py alone, with the correct parameters sends a correct email with the graph properly displayed. But if I use nagios to send the graph it sends the correct message but the graph does not show up. I only get a file name which when tried to open gives me this message: "It may be damaged or use a file format that Preview doesn’t recognize." I have no idea why. All the work of sending the graph is done by sendgraph.py and it has all the correct parameters to it for sure because the URL gives the correct values from Graphite and then I get the email (so the email is correct) and I get the description and state of the graph correctly.
Could anyone please suggest me a way out of this?
Thanks!
In the Nagios documentation for macros it states:
"Additionally, any macros that contain custom variables are stripped for safety and security."
In you nagios.cfg file, try removing the '&' from this line:
illegal_macro_output_chars=`~$^&"|'<>