Question

Trigger an API call when an email arrives

  • 23 March 2022
  • 6 replies
  • 2835 views

I need what would seem to be a simple Zap but it’s over my head.  I need to trigger an API call when an email arrives.  I have to take a variable that will appear in the Subject line of the email and then send it to a predefined URL using predefined credentials.  

If you can assist I’m willing to pay.  


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

6 replies

Userlevel 7
Badge +14

Hi @TextPowerCEO 

Good question.

The configuration will depend on the API documentation.

Are you able to share that?

App APIs can be used in Zaps with the Webhooks app as an action step: https://zapier.com/apps/webhook/help

Userlevel 7
Badge +12

Hi @TextPowerCEO 

I would suggest building out inbox rules to forward the specific emails to an email parser like Parser by Zapier or Mailparser to start the automation. 
Outlook: https://support.microsoft.com/en-us/office/use-rules-to-automatically-forward-messages-45aa9664-4911-4f96-9663-ece42816d746

Gmail: https://support.google.com/mail/answer/6579 

Once Zapier knows about the emails, you can use the webhook action Troy mentioned to send the API call

 

Thanks very much for your response.  Getting the emails to the right location isn’t the issue.  I’ve set up aliases in our mail server to route to specific Zapier email addresses so I’m getting the emails to the right place.  It’s what happens with them afterwards that I am trying to figure out.  

That said, I will certainly look at Parser and Mailparser to extract the specific data that I need from either the Subject line or the headers (I’m presuming these apps can read the full headers).  That is a very helpful suggestion and is much appreciated.  

@Troy Tessalone - Thanks for that very helpful suggestion.  I am aware of the web hooks functionality but will need to dig a little deeper to figure out how to extract the data I need (by using Parser/Mailparser as described above) and then move it to the right place(s) in the web hooks portion. The API call is relatively straightforward.  It is a call to our system to send a text message and is essentially like this:

{
    "method": "SendSMS",
    "msgcredentials": {
        "UID": "UserID",
        "PWD": "Password",
        "Campaign": "CampaignName",
        "Keyword": "Keyword"
    },
    "CellNumber": "9876543210",
    "Message": "Body of text message goes here",
    "ForceOptIn": “0”,
    "DelaySend": “0” ,
    "SendTime": "0",
    "Queued": 0,
    "LangEncoding": 0,
    "IsMultiPartMsg": 0
}

 

The cell phone number would be in the Subject line of the email.  I’d need to extract that and enter it into the “CellNumber” parameter.  The body of the intended message would be in the body of the email and I’d have to extract/copy that from the email and insert it into the “Message” parameter.

The ultimate goal is to be able to take a customer’s email sent to a unique email address and then parse it as described, putting it all into an API call and then using the customer’s credentials to send the API call to our system to send the message. 

Thanks again for your very helpful comments.  

Userlevel 7
Badge +14

@TextPowerCEO

Check out the Formatter > Text options:

Add the Formatter app

 

 

Also, a Code step can be used to do email parsing:

 

@Troy Tessalone - My apologies for the delay and my appreciation for your response.  Based on your description of the Formatter app it looks like that will take me a large step closer to accomplishing this.  I’m going to work on it and test a few things and will follow-up will some comments here.  

Thanks to all for your participation.  It is very much appreciated.